8 years, 1 month ago.

Sending Large Data Packages (> 255 Bytes) via XBee API

Hello Everyone,

I am currently trying to modify the "XBeeLib" (see https://os.mbed.com/teams/Digi-International-Inc/code/XBeeLib/) to be able to send data packages with more than 255 Bytes. The Library itself is limiting the data by only using a "uint8_t" datatype and therefore limiting the maximum data sent.

Using the "XCTU" program the maximum Package size should be 65536 Bytes, so I tried modifying the Library to allow bigger packages. So far I have failed, due to the Library being very large and complex.

The following shows the code used to read the Data from a Textfile and then sending via the "send_data_to_coordinator" command. Due to this, sending back large amounts of data takes a lot of time and I was wondering if anyone ran into similar problems.

Read Data from File and Send via XBee API

while (File_Size) {
            if (File_Size >= 250) {
                fread(Data_Buffer, 250, 1, fp);     // Read Data into Buffer

                txStatus = XBee.send_data_to_coordinator((const uint8_t *) Data_Buffer, 250);
                if (txStatus != XBeeLib::TxStatusSuccess)
                    PC.printf("send_data_to_coordinator() failed with error %d\n", (int) txStatus);
                File_Size = File_Size - 250;
            } else {
                fread(Data_Buffer, File_Size, 1, fp);     // Read Data into Buffer

                txStatus = XBee.send_data_to_coordinator((const uint8_t *) Data_Buffer, File_Size);
                if (txStatus != XBeeLib::TxStatusSuccess)
                    PC.printf("send_data_to_coordinator() failed with error %d\n", (int) txStatus);
                File_Size = 0;
                
                PC.printf(" Done! - Time taken: %d ms\n", TimeStamp.read_ms());
                PC.printf("------------------------------------\r\n");
                Ticker_ReceiveXBee.attach(queue.event(&ReceiveXBee), 0.5);
                TimeStamp.stop();
            }
        }

2 Answers

8 years, 1 month ago.

Xbee packets seem to be limited by the protocol to be max. 256 bytes. But (like you show above) you can do fragmentation yourself.

If you're not closing the file between every read, that's good already, and won't make it much slower.

However, sending the data to the module goes at 9600 bits per second, so that's probably where much of the slowness comes from. Sending 65K through the module at 1.2 bytes per sec is 54 seconds transmit time. Maybe the module supports a higher baud rate? That would help.

I am currently running the XBee Modules on 230.400 Baud in API Mode. I tried sending the Data without reading it from the SDCard (I'll do that after sending the Data via XBee) and got slightly faster (22 seconds for 22 kB). But it still feels like the maximum of 256 bytes is limiting my data throughput.

posted by Michael Schmidt 12 Nov 2017

So, as far as I know 256 bytes is the max. payload size for Xbee packets, so no way of getting around it. There's probably some rate-limiting on the xbee side to ensure there's time between packets.

posted by Jan Jongboom 13 Nov 2017
7 years, 11 months ago.

Good day,

Just a heads up that not all Xbee modules support payloads as large as 255 bytes. For example the Digimesh Xbees limit the payload size to 73 bytes, etc. It would be a good idea to use the Xbee "NP" (Max RF Payload Bytes) command to see what the Xbee responds with... as I imagine this value may change with the Xbee's firmware and version.

Cheers !