lhemmen / python-xbee

Automatically exported from code.google.com/p/python-xbee
MIT License
0 stars 0 forks source link

ZigBee tx_long_addr #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I've been using this awesome lib for the last week in the receive mode 
(Raspberry PI acting as an XBee gateway, submitting data to a remote web 
service). Excellent work!

What steps will reproduce the problem?
1. Version 2.1.0 of lib
2. Code using ZigBee object rather than XBee object
3. Calling tx_long_addr

What is the expected output? What do you see instead?
Send data to a remote XBee

Stack trace is:

Traceback (most recent call last):
  File "./test2.py", line 23, in <module>
    main()
  File "./test2.py", line 15, in main
    zb.tx_long_addr(dest_addr=xbaddr, data="test")
  File "/usr/local/lib/python2.7/dist-packages/xbee/base.py", line 420, in __getattr__
    raise AttributeError("XBee has no attribute '%s'" % name)
AttributeError: XBee has no attribute 'tx_long_addr'

What version of the product are you using? On what operating system?
2.1.0, Python 2.7.4

Please provide any additional information below.

#! /usr/bin/python

import serial
from xbee import XBee, ZigBee
import sys

def main():
        ser = serial.Serial('/dev/ttyAMA0',9600)

        zb = ZigBee(ser, escaped=True)

        xbaddr = "\x00\x13\xA2\x00\x40\xA2\x5C\x50"

        zb.tx_long_addr(dest_addr=xbaddr, data="test")

        zb.halt()
        ser.close()

if __name__ == '__main__':
    main()

Background info:
All XBee's are series 2 (ZB)
Controller running API mode (receiving fine)
Number of endpoint XBee's running endpoint profile, AT mode

Original issue reported on code.google.com by Steve.bo...@gmail.com on 7 May 2014 at 9:32

GoogleCodeExporter commented 9 years ago
Hi Steve,

I'm glad the library is working well for you.

It turns out the message you are trying to send does not exist for XBee ZB 
devices; for these, you use the standard "tx" message with a long address. 
Don't forget to set the dest_addr field to b"\xFF\xFE" to tell the device to 
use the long address instead.

For a listing of the messages you can send for ZB devices, see 
https://code.google.com/p/python-xbee/source/browse/xbee/zigbee.py

Original comment by pmalms...@gmail.com on 8 May 2014 at 10:39