Hey, so I was under the belief that the maximum size of data one can include in a BLE packet is 20 bytes (23 bytes total, 3 bytes overhead, so 20 total for custom data). With this constraint, I was evaluating how to send data that would be larger than 20 bytes if sent as human-readable ASCII digits. An example of the data would be as follows:
2.25,21.0, 24.0,1342,2512,0873,36.6,2899
If I encode every digit as an ASCII char to be human readable, including commas (and a '\n' at the end), this comes to 40 bytes total. So, I was considering pros and cons of sending two packets each 20 bytes long per "set of data", and having my custom mobile app handle this accordingly. I was also considering a more complicated packing strategy, where I do something along the lines of multiply float values by 100 then cast all values to uint16_t, store into packet without commas, and have mobile app unpack accordingly. This would fit everything into 20 bytes, but would no longer be human readable and be more difficult to debug.
Just a few minutes ago, I wanted to see what happens if I try to send all 40 bytes as human readable ASCII. I made the following call:
uint8_t test_packet[] = {48,48,48,48,44,48,48,48,48,44, 48,48,48,48,44,48,48,48,48,44, 48,48,48,48,44,48,48,48,48,44, 48,48,48,48,44,48,48,48,48,10}; uint16_t size = 40; ble_nus_data_send(&m_nus, test_packet, &size, m_conn_handle);
to test sending a packet that would look like "0000,0000,0000,0000,0000,0000,0000,0000\n". I did not change anything else in my nRF application, nor change any settings in the central device. I used the Adafruit Bluefruit LE Connect generic UART plotter/receiver app, and this is what I got:
To my surprise, it worked perfectly fine. After doing some more reading, it appears like only BLE 4.1 devices have the 20 byte constraint. Is there anything I should be concerned about when sending 40 bytes in one package? Does anybody have more information on what central devices (specifically mobile phone models) will be constrained to BLE 4.1 or the 20 byte payload restriction? If sending 40 bytes per packet is a "safe" thing to do, then for my application this is the optimal design choice for right now. Any input would be greatly appreciated.
I am using nRF 52 DK, but plan to flash this firmware onto an nRF52810 on a custom board. Developing with SDK V 15.2.0, and using Nordic UART Service to transmit data.