h2zero / esp-nimble-cpp

C++ library for the esp32 NimBLE stack based on and mostly compatible with @nkolban cpp_utils BLE library.
https://h2zero.github.io/esp-nimble-cpp/
Apache License 2.0
181 stars 62 forks source link

Is there a fixed length for NimbleDescriptor setValue()? #195

Closed RootDev4 closed 4 days ago

RootDev4 commented 2 months ago

Hello everyone,

NimBLEDescriptor *ble_description = ble_data_characteristic->createDescriptor(NimBLEUUID((uint16_t)0x2901), NIMBLE_PROPERTY::READ); ble_description->setValue("foobar"); NimBLE2904 *ble_characteristic_descriptor = (NimBLE2904*)ble_data_characteristic->createDescriptor(NimBLEUUID((uint16_t)0x2904), NIMBLE_PROPERTY::READ); ble_characteristic_descriptor->setFormat(NimBLE2904::FORMAT_UTF8);

Setting the value to “fooba” (5 Bytes or less) or to "foobar1" (7 Bytes or more) for the descriptor results in an empty value ("No value") for 0x2904 descriptor in the LightBlue app. However, if I set it to “foobar” (6 Bytes), it works.

Maybe it's a problem with LightBlue? Or does setValue() need a length of exactly 6 bytes? Does anyone have an idea?

h2zero commented 2 months ago

The 2904 value should not be set to anything other than what can be specified through the special member functions for it. Calling setValue is not supported.