Xbee API Mode - Coordinator -> Router -> End Device

Hi All,

Right now I have a setup in API mode where I am able to send my sensor data from my end device (Arduino attached to an XBee Shield) directly to my router (Also an Arduino/Shield combo). With this code:

#include <XBee.h>
XBee xbee = XBee();
uint8_t data[2] = {0,0};
XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x4198E12F);//Router MAC Address
ZBTxRequest zbTx = ZBTxRequest(addr64, data, sizeof(data));


Then, I have code running in the Router to send that same message directly to my coordinator MAC address. This really is the same code as above, but with the Coordinator MAC Address.

Am I doing this correctly? I am manually coding the E → R → C network, which works but I am not sure if it is correct. I believe in API mode I have to do this, but I am not 100% sure. Isn’t the Zigbee network supposed to handle the forwarding? Or is that only in non-API mode?

So, now, I want to send messages from the Coordinator back out to the end device. My first thought was to now have the Coordinator send the message to the Router and then to the End Device. Great, but this only works if I have one end device. How does the Router know which one to send to? The only way, which seems overly complex, is to embed that information (maybe the MAC of the end device or some key) in the data of the message. I must be doing something wrong.

After a few tests, I have suddenly found that the Coordinator itself can send a message directly to the End Device, using this code (Python on Raspberry PI):

from digi.xbee.devices import RemoteXBeeDevice
from digi.xbee.devices import XBee64BitAddress
coordinator = XBeeDevice(SERIAL_PORT, BAUD_RATE)
end_device = RemoteXBeeDevice(coordinator,XBee64BitAddress.from_hex_string("0013A2004198E12F"))


This in a way defies my earlier implementation, as it seems to bypass the Router.

What is actually happening here in the above implementation? Is the Router XBee getting the message and not telling me? I see no System.out showing a message was received by it, so this must not be the case. Instead the Coordinator seems to be bypassing the Router.

In XcTU tool, my network for my Coordinator shows that the Router is in-between it and the end devices, so I think it should have to go through the Router. Does it have another connection to the end devices I don’t know about, directly?

I am sure that my issue is a lack of understanding of how this all works. Can any one shed any light on my problems? How do I get data back to my end devices in a proper way?


Answered here: