Fastest way of sending strings to 4 routers from a coordinator?

Hello,

I have 5 Xbee S2B radios, 1x set as Zigbee Coordinator AT and 4x set as Zigbee Router AT. The aim is to send strings to each of the routers from the coordinator. the strings are generated on a laptop and are different for each router.

AT the moment, I am using multiple unicast transmissions switching the DH and DL parameter of the Coordinator every time I need to send a String to a different router.

Is there a fastest way of transmitting the strings? Broadcast?

Does anybody have any ideas?

Thanks!

Michele

Sure, use API mode. This way each TX request packet includes in it the 64 bit address of who you want the data to be sent to. This keeps you from having to enter command mode and change the address each time.

Thanks mvut,
I thought about doing that but I am not totally clear about two things:

  • How I include a string (or a byte and an int for instance, say for example A100) into an API frame.
  • This means the routers have to send a Tx request correct? Do they have to send a specific request for every string or can they just send a specific request? And how do they know when there is new data for them?

Sorry if I what I am asking sounds wrong, not an expert (yet!!!)

Many Thanks,
Michele

The API frame that the XBee module uses is pretty straight forward.

You have a Start Delimiter (7E), Some length bytes (xx xx), a Frame ID (17), a packet ID(xx), the 64 bit address of who you want to send it to, the network address (FFFF), the option byte and then the data payload. This is where you would put your A100 or anything else you want to send, followed by a checksum.

Hi mvut,
thank so much for your help, really appreciated!
I was looking at the manual and If I understood correctly, I should send a ZigBee Transmit Request, Frame type: 0x10, where the max payload size is defined by the NP parameter. Correct?

Sounds pretty straight forward! A couple more questions:

  • Can I just send a ZigBee Transmit Request API frame at any time form the coordinator and the receiving router will get it?
  • Do I have to setup the receiving routers as API routers in order to read the API frames coming form the coordinator?
  • Can the coordinator be set as coordinator AT or does it need to be API too?
  • Isn’t it a bit inconvenient having to calculate the checksum for every single API frame I send? I may have about 100 different ones.

Many thanks for you help!
Michele

Yes that is correct.
Yes, you can send a TX request packet any time you want and the node that has the matching address will out put it on its UART.

The coordinator can be either or. Just note that if you want to issue an API frame from your processor to the Coordinator that is connected to it via the UART, that coordinator or node must be in API mode.

If you do it right your code should be able to assemble the packet and calculate the checksum properly all on its own.

Hi mvut,

I tried setting the coordinator as API and the routers as AT. The coordinator is connected via UART to my computer running processing. The AT routers are connected to Arduinos listening for incoming serial messages.

Does it matter what the DH and DL parameters of the API coordinator are set to? It shouldn’t right? As the destination id is stated in the API frame, correct?

Also, can I leave the 16-bit address as 0xFFFE (Unknown)?

I tried formatting the API frame to send via the coordinator this way (see below) but didn’t manage to receive it at the router’s end. I set the 5th byte as 0x00 (no response). Should I set it to 0x01 to help troubleshooting? Can you see anything plainly wrong?

       xbee.write(0x7E);
       xbee.write(0x00); //length
       xbee.write(0x12); //length
       xbee.write(0x10); //API transmit request
       xbee.write(0x00); //no response
       xbee.write(0x00); //destination 64-bit address
       xbee.write(0x13);
       xbee.write(0xA2);
       xbee.write(0x00);
       xbee.write(0x40);
       xbee.write(0xBB);
       xbee.write(0x71);
       xbee.write(0xE0);
       xbee.write(0xFF); //destination 16-bit address
       xbee.write(0xFE);
       xbee.write(0x00); //radius
       xbee.write(0x00); //options
       xbee.write(0x46); //Payload (F100);
       xbee.write(0x31);
       xbee.write(0x30);
       xbee.write(0x30); //end of payload
       long sum = 0x10 + 0x13 + 0xA2 + 0x40 + 0xBB + 0x71 + 0xE0 + 0xFF + 0xFE + 0x46 + 0x31 + 0x30 + 0x30;
       long checksum = (0xFF - (sum & 0xFF));
       xbee.write((byte)checksum); //Checksum

Sorry if I am making silly mistakes here!

Thanks,
Michele

No it does not matter what the DL and DH of the API module is as your API frame will over write that value with the 64 bit address in your API Frame.

Yes by all means you can leave the 16 bit address to 0xFFFE. That is what that value is for.

If it was me, I would set byte 5 to a value for each packet so that I can see the response or status of that frame.