weliem / bluez_inc

A C library for Bluez (BLE) that hides all DBus communication. It doesn't get easier than this. This library can also be used in C++.
MIT License
84 stars 19 forks source link

Correct approach for reading data that has a size greater than the MTU? #11

Closed lizziemac closed 1 year ago

lizziemac commented 1 year ago

Howdy! I have the following characteristic:

    binc_application_add_characteristic(app, SERVICE_UUID,
                                        BIG_DATA_CHAR_UUID,
                                        GATT_CHR_PROP_READ);

Where BIG_DATA_CHAR_UUID should returns data greater in length than the MTU. Unsurprisingly, this truncates when sent as one value; would the correct approach be to use the GATT_CHR_PROP_NOTIFY to send over to the central device?

I tried "chunking" the data and then making multiple calls to binc_application_set_char_value in my on_local_char_read callback, but only the last chunk wins.

If using notifications is the standard/expected behavior, do the notifies happen in the read callback? I'm pretty new to BLE so I appreciate any feedback.

Small disclaimer - the "big data" is about 750 bytes worth of data.

Thanks!

weliem commented 1 year ago

When doing a read operation the max length is 512 bytes. Normally, you'd use notifications to send a large amount of data. Simply chunk the data and send mutiple notifications. The receiver then needs to merge all chunks to form the complete data.

lizziemac commented 1 year ago

Thanks!