Receiving data from multiple XBee Series 2B EndPoints

最后都变了- 提交于 2019-12-11 13:55:23

问题


I'm working on a project that involves the XBee Series 2B radios and could use some advice in regards to determining what end device the data packets are coming from. The setup includes a Python 2.7 application running on a Raspberry Pi Model B.

The Python-XBee 2.1.0 documentation states: ZigBee devices extend this behavior to include automatic parsing of “ND”, Node Discover, AT command responses. The parameter field of a ND AT response will assume the following format:

{"source_addr": two bytes,
"source_addr_long": eight bytes,
"node_identifier": string,
"parent_address": two bytes,
"device_type": one byte,
"status": one byte,
"profile_id": two bytes,
"manufacturer": two bytes,
}

I take this to mean that the I/O sample messages for the ZigBee's contains the above parameter field.

Is source_addr == the 16 bit MY parameter of the end point radio?

Can it be gotten with:

ser = serial.Serial('/dev/ttyUSB0', 9600)
xbee = ZigBeer(ser)
myID = xbee.source_addr

Thanks!


回答1:


I think the I/O samples are responses to a remote ATIO command, so they'll follow the format of a remote AT response, and include a short and long address.

On the XBee module, the short address is ATMY, and the long address is a combination of ATSH and ATSL. I don't know python-xbee well enough to say where they are stored in the ZigBee object.

Additional information:

Node discovery is different than sending I/O samples. When the host sends ATND to its local XBee, the XBee module sends a broadcast discovery message and passes the responses back to the host. The host can parse the response for addresses and the "node identifier" (ATNI string) from the remote module.

From this address list, the host could send ATIO commands to remote nodes and parse the responses.

I'm not familiar with the Python-XBee library, so I don't know how it implements node discovery, management of the node table, and sending "remote AT commands" to discovered nodes.




回答2:


The xbee packet is a dict

from xbee import ZigBee 
import serial

ser = serial.Serial('/dev/ttyAMA0', 9600)
xbee_conn=ZigBee(ser)
xbee_conn.at(command='ND')
while True:
    try:
        packet = xbee.wait_read_frame()
        print packet
    except KeyboardInterrupt:
        break
ser.close()

To get to the data access it as a dict:

source_address_long = packet['parameter']['source_addr_long']

Hope this helps.



来源:https://stackoverflow.com/questions/19408264/receiving-data-from-multiple-xbee-series-2b-endpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!