BLE: Why only 7 user characteristics possible?

Trying to use the new BLE api with 1.3.0-rc.1 (on a Boron). My application needs a custom BLE service with 10 characteristics. Adding the 8th characteristic with BLE.addCharacteristic() and higher logs this error:

[hal.ble] ERROR: characteristics_.size() < 10 failed: -200

This error seems to come from here: https://github.com/particle-iot/device-os/blob/v1.3.0-rc.1/hal/src/nRF52840/ble_hal.cpp#L2188

CHECK_TRUE(characteristics_.size() < BLE_MAX_CHAR_COUNT, SYSTEM_ERROR_LIMIT_EXCEEDED);

BLE_MAX_CHAR_COUNT is defined as 10 in https://github.com/particle-iot/device-os/blob/v1.3.0-rc.1/hal/src/nRF52840/ble_hal_impl.h#L112

If the limit is 10, why can I add no more than 7? Using the nRF connect Android app shows a Particle BLE service with already 3 characteristics. So #define BLE_MAX_CHAR_COUNT 10 seems to be the limit for the overall characteristic count of all services.
Changing the define lets create me more characteristics, but I’m not sure about any side effects.

Is there a reason for limiting the user generated characteristic count to only 7?

@nils, chatting with the Particle folks, as you have discovered, the TOTAL number of characteristics is currently limited to 10. Increasing that number does impact the RAM used. To better understand where the characteristics limit could be, can you explain your use case for the Particle folks?

4 Likes

The application at the other end is already in use at the customer site and not changeable at the moment. It uses a single characteristic for each of 10 sensors. It’s easy to solve this using fewer characteristics, but only if I can change both sides, which is not the case here.

I would like to replace an external UART bluetooth module connected via SPI over a SC16IS740 with the internal solution which could replace two libraries and a lot of code, taking off a lot of potential sources of errors.

Just read that the limit was increased to 20 user characteristics with release 1.3.1-rc.1

Thank you! :slightly_smiling_face:

  • Supports up to 23 local characteristics, 20 of them are available for user application