XBee: Send data to specific Node in a Mesh

Hi mates.

I’m working on a mesh network made up of 1 Coordinator and several Routers (every XBee S2, API mode), that can join the network at any time. That’s why I’m using the NodeDiscovery function. The coordinator discovers every Router joined, and inside the ND function, every Router sends back a packet that has its Address. So I’m able to store those addresses in a matrix: for example, int devices[50][17] 50 maximum devices.

I know the way to send data from Coordinator to one specific Router:

-XBeeAddress64 addr (0x0013a20040a1f246)
-ZBTxRequest zbTx = ZBTxRequest(addr, payload, sizeof(payload));

But instead of doing this last step, is there a way in which I could use the stored address of some XBee Router in the previous matrix?

int devices[100][17];

//Once inside the NodeDiscovery function

while(xbee.readPacket(timeout)) { // should be receiving AT command responses
if (xbee.getResponse().getApiId() == AT_COMMAND_RESPONSE) {
if (response.isOk()) {
for (int i = 2; i < 10; i++) {
devices[nodeCount][i]=response.getValue()[i]; //Stores the addres of the Nodes found



The code may not be correct at all. I’m a beginner. My apologies.

To sum up, I’m trying to find a way to store the address of every Router found in order to use it later to send data. For example ‘Hi1’ to Router1, ‘Hi2’ to Router 2, etc.

If anyone has some advice I would appreciate it.


No, not really. Not unless you want to off load the routing to your code.

First of all, thank you very much for responding, I appreciate it. I’m a student and I’m kind of stuck right now.

Well how should I proceed to do something like this? If I have a network with routers that can join at any time, would it be impossible to save their addresses in some way and use them later?

It is a university project in which I do not know the routers that I will have in the network.

I would suggest using API mode along with the Join Notification (JN) function. This way when a node joins, an API frame comes out with its 64 bit MAC address.

I’m not sure, but I think I got the JN enabled. Using the Node Discovery, every Router sends an API frame including is 64 bit MAC. I can print these addresses (the part of the code I wrote does), but not store them.
And what about the SL and SH. Would there be some way to save them in two array variables of 10 devices, for example, like the following?

uint32_t Msb();

uint32_t Lsb();

XBeeAddress64 remoteAddress = XBeeAddress64(uint32_t Msb,uint32_t Lsb);

Sorry if I bother you.
Perhaps the best way is to create XBeeAddress64 variables, as many as routers the network has , and add by hand the rest when they join.

I am Spanish, maybe my English is not good sometimes. sorry.

I am not sure I can answer that one as that is dependent on your processor and what language it uses. But in most cases, you should be able to.

Thanks for your time, mvut. I appreciate it. I’ll try to find out more about it.