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. Coordinator discovers every Router joined, and inside the ND function, every Router sends back a packet which has its Address. So I'm able to store those addres 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));
  • xbee.send(zbTx);

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) {
         xbee.getResponse().getAtCommandResponse(response);
         if (response.isOk()) {
           nodeCount++;
           for (int i = 2; i < 10; i++) {
             devices[nodeCount-1][i]=response.getValue()[i]; //Stores the addres of the Nodes found
             Serial.print(devices[nodeCount-1][i],HEX);
           }

           Serial.println("");

         }
       }
      }

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 apreciate it.

Regards