This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Too many services and characteristics --> NRF_ERROR_NO_MEM

Hello,

i create a custom profile with two services and with 30 characteristics. The first service has 29 characteristics. Up to this point everything is ok, but when I want to create the next service, NRF_ERROR_NO_MEM is returned. I already read that there is a static 1.5 kB of memory allocated for the GATT table internally in the softdevice. All my characteristics are located in BLE_GATTS_VLOC_USER. But the message NRF_ERROR_NO_MEM will nevertheless returned. What can I do to reduce the size in stack memory?

  • What else is stored in the 1,5 kB stack? Is there any aother way to reduce the size than with BLE_GATTS_VLOC_USER? Is there an optimized way to create characteristics?

  • Has anyone an idea?

    When I use the BLE_UUID_TYPE_BLE UUID instead of the vendor ID all services and characteristics can be created. Why the vendor UUID requires more memory as the Bluetooth SIG UUID?

  • There isn't any other way to reduce ATT Table memory use than to use VLOC_USER for all values. Which exact method is it that returns the NO_MEMORY error? The softdevice have room for only 5 (with version 5.2.1) or 10 (with version 6.0.0) vendor specific base UUIDs, so could it be that you are confused by a sd_ble_uuid_vs_add() call returning this error, and not the actual service adding?

    Please note that it is unnecessary to add a separate base for each service, you can use the same base for all your services and characteristics, and just set the .uuid of the ble_uuid_t to be different.

  • The Method sd_ble_gatts_characteristic_add returns the NO_MEMORY error. As you describe, I create the vendor specific base UUID only once with the function sd_ble_uuid_vs_add. Then I use the returned UUID type for all services and characteristics. But if I use as ble_uuid_t.type the BLE_UUID_TYPE_BLE and not the generated UUID Vendor Type, then I can create all the services and characteristics. Does a vendor UUID type needs more memory?

    If I use a vendor UUID type and create all characteristics with cccd_md.vloc = BLE_GATTS_VLOC_STACK instead of BLE_GATTS_VLOC_USER, I can create 1 service and 24 charertersitics. If I use attr_md.vloc = BLE_GATTS_VLOC_USER I can create 1 services with 29 characteristics and a second service with 0 characteristics. So with the VLOC_USER option I can create 5 characteristics and 1 service more before NO_Memory error is returned. Is it normal that the difference is so small here?

  • I have a few more tests for version with vendor UUID and with BLE_UUID_TYPE_BLE. With vendor UUID i can create 29 charateristics and with BLE_UUID_TYPE_BLE I can create 45 charateristics.

    We have now optimized our protocol to less characteristics. Is it planned in the future to increase the static 1.5 kB of memory allocated for the GATT table or outsource this in the user area?

Related