dpatino
dpatino

Reputation: 109

XBee node discovery using python API without response

I'm trying to get the data of a XBee network (API mode) using python, so I'm using the python-xbee library and the AT 'ND' command to try to discover all XBee units (I'll paste my code just for ND command below):

#!/usr/bin/python
from xbee import ZigBee 
import serial

ser = serial.Serial('COM7', 9600)
xbee = ZigBee(ser)

xbee.at(command='ND')
xbeeAddrs = []
while True:
    try:
        newXBeeR = xbee.wait_read_frame()
        print newXBeeR
        xbeeAddrs.append(newXBeeR['parameter']['source_addr_long'])
    except KeyboardInterrupt:
        break
ser.close()

But there is NO response message and the code hangs on waiting for a frame.

For the easiest test I've a XBee Router API board connected to an Arduino Uno with a 7 segments display, and a XBee Coordinator API board connected to the computer using sparkfun uart board.

Other AT commands work properly, however I need to discover all the possible XBee Router units before send commands. If I use the X-CTU software the discover function works perfect...

What could I do? Thanks a lot,

UPDATE:

Solved in comments...

Upvotes: 0

Views: 1052

Answers (1)

Azizou Ogbone
Azizou Ogbone

Reputation: 11

Change xbee = ZigBee(ser) to xbee = ZigBee(ser, escaped=true)

Explanation: By default the API frame are not escaped, i.e the zigbee/xbee object operate in ATAP1 mode. This might not be the case for the actual device (the coordinator). So one fix is to pass escaped=true argument when creating the xbee/zigbee object or configure your device to be in ATP1 mode xbee = ZigBee(ser) should be xbee = ZigBee(ser, escaped=true)

Upvotes: 1

Related Questions