OpenBluetoothToolbox / SimpleBLE

SimpleBLE - the all-in-one Bluetooth library for MacOS, iOS, Windows, Linux and Android.
https://www.simpleble.org
Other
655 stars 110 forks source link

Notify on single byte #256

Closed Rasmus-Fink closed 1 year ago

Rasmus-Fink commented 1 year ago

Hi, Following the example notify.cpp: I get notified when I send a string via the serial terminal if I send a CR/LF. This is useful for sending a string. I need, however, to sends/receive binary data, so I essentially need the callback in notify.cpp to fire on every byte received. Is that possible using this library? BR Fink

eriklins commented 1 year ago

From the Bluetooth/BLE procotol perspective a notification is raised when a peripheral device did update a GATT characteristic and only one notification will be propagated from the underlying BLE stack towards any higher level library like SimpleBLE. This is fully independent on how many characters of the characteristic did change. The only (BLE protocol compliant) chance to get one notification per byte would be to write/notify single bytes instead of multiple into the characteristic on your peripheral subsequently. If you plan to transfer binary data, a terminal would not be the proper implementation. You can update a characteristic with binary data without issues and no need for CR/LF. This is just for demonstrating in the sample application for ease of usage.