I'm trying to send and receive data from coordinator xbee connected to my computer. The router xbee is connected to my arduino and is supposed to send a message back upon receive.
Here's the code for my python script running on the computer:
#!/usr/bin/python
#this code runs on the xbee coordinator that is set to API mode 2
import serial
from xbee import ZigBee
from xbee.helpers.dispatch import Dispatch
import time
PORT = '/dev/tty.usbserial-A900UF4T'
BAUD_RATE = 9600
UNKNOWN = '\xff\xfe'
WHERE = '\x00\x13\xA2\x00\x40\x98\xDA\x08'
dataString='Hello\n'
# Open serial port
ser = serial.Serial(PORT, BAUD_RATE, interCharTimeout=0.5)
#sends data to xbee address
def sendData(address, datatosend):
zb.send('tx', dest_addr_long = address, dest_addr = UNKNOWN, data = datatosend)
def recvData (data):
print data
zb = ZigBee(ser, callback=recvData)
#test data sending method
ack = '0013A2004098DA02'
while True:
try:
sendData(WHERE, dataString)
except KeyboardInterrupt:
break
zb.halt()
ser.close()
And here's the response I got:
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}
{'retries': '\x00', 'frame_id': '\x01', 'deliver_status': '\x00', 'dest_addr': '\x03\xb1', 'discover_status': '\x00', 'id': 'tx_status'}