For value for BLECharacteristic, bytes after a 0x00 byte are not sent. This is probably because BLECharacteristic uses char for payload and 0x00 is being treated as the '\0' character.
What it means is that custom binary data cannot be sent. For example, 0x00 0xF0 0x00 is received as an empty message.
With FixedLength size of 20, here is the output I get: 0x32 0x99 0x1b 0xc3 0xfe 0x9f 0xed 0xfc 0x24 0x00 0x00 0x00 0xfc 0xff 0xff 0xff 0x34 0x23 0x00 0x20. This doesn't change even when payload changes.
For value for
BLECharacteristic
, bytes after a0x00
byte are not sent. This is probably becauseBLECharacteristic
useschar
for payload and0x00
is being treated as the'\0'
character.What it means is that custom binary data cannot be sent. For example,
0x00 0xF0 0x00
is received as an empty message.Here is an example sketch. You can check notifications via Web-Bluetooth at this url https://googlechrome.github.io/samples/web-bluetooth/notifications-async-await.html?service=0xfff0&characteristic=0xfff1.
The same output as Web-Bluetooth is received in Nordic nRF Connect app as well.
Using
BLEFixedLengthCharacteristic
instead sends wrong data. For example, for0x00 0xF0 0x00
as payload, I receive0x32 0x99 0x1B
.Other details
I'm using the
nrf51-indicate-fix
branch.My chip is NRF52832, the issue with fixed length is probably not related to the chip, I don't have an NRF51 chip to verify.
I'm using platformIO ide on vscode. Here is my platformio.ini file
With FixedLength size of 20, here is the output I get:
0x32 0x99 0x1b 0xc3 0xfe 0x9f 0xed 0xfc 0x24 0x00 0x00 0x00 0xfc 0xff 0xff 0xff 0x34 0x23 0x00 0x20
. This doesn't change even when payload changes.