Description
Currently I'm utilizing the XBee ZigBee Mesh modules to send and receive a broadcast message over a network. I have the modules attached to the grove boards that come with the ZigBee Mesh kit connected via USB to a PC. I'm using the Digi Python library for this task. I've configured the devices using XCTU software making sure they're on the same network, in API 1 mode, and that one device is the coordinator and the other is the router. I was able to successfully broadcast a message using the library and receive the message using the XCTU console as instructed in the "Hello World" introductory exercise. Next, I was able to send and receive a message running python from the terminal in Ubuntu. It wasn't until I created .py files for sending and receiving a broadcast packet that I started to have issues. Each time I try running the receive .py file, it gives me a TimeoutException() error. Not quite sure why this is at the moment.
The code used in the broadcast python script is the following:
#Python script to broadcast message over network
from digi.xbee.devices import XBeeDevice
#Instatiate an object and open serial connection to local device
device = XBeeDevice("/dev/ttyUSB1",9600)
device.open()
#Broadcast message over network
device.send_data_broadcast("Hello XBee World!")
device.close()
The code in the receive.py is the following
from digi.xbee.devices import XBeeDevice
#Instatiate an object and open serial connection to local device
device = XBeeDevice("/dev/ttyUSB0",9600)
device.open()
#Receive message over network
xbee_message = device.read_data(10)
print(xbee_message)
#Remote Device that sent the packet, timestamp, data and if it was broadcast
#remote_device = xbee_message.remote_device
data = xbee_message.data
#is_broadcast = xbee_message.is_broadcast
#timestamp= xbee_message.timestamp
print(data)
#print(is_broadcast)
#print(timestamp)
#print(remote_device)
device.close()
The error that I'm getting is the following
traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/digi/xbee/reader.py", line 908, in get
return Queue.get(self, True, timeout)
File "/usr/lib/python3.4/queue.py", line 175, in get
raise Empty
queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Receive.py", line 11, in
xbee_message = device.read_data(10)
File "/usr/local/lib/python3.4/dist-packages/digi/xbee/devices.py", line 1791, in read_data
return self.__read_data_packet(None, timeout, False)
File "/usr/local/lib/python3.4/dist-packages/digi/xbee/devices.py", line 1028, in dec_function
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/digi/xbee/devices.py", line 2285, in __read_data_packet
packet = self.__data_queue.get(timeout=timeout)
File "/usr/local/lib/python3.4/dist-packages/digi/xbee/reader.py", line 910, in get
raise TimeoutException()
digi.xbee.exception.TimeoutException