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

SDK13 NRF_ERROR_NO_MEM at sd_ble_gatts_characteristic_add()

Hello, when starting a new project I took the nice Heart-Rate-Example which works fine at my PCA10040. Then I started to add services and characteristics by copying and adapting the HRS - I know that I will have to declare them as vendor specific services and characteristics - this is not already done. One new service with 11 characteristics works fine, but adding a second will lead to a NRF_ERROR_NO_MEM as return value at the sd_ble_gatts_characteristic_add() function and then a Reset is executed. In one post in this forum I saw that adding

memset(&ble_cfg, 0, sizeof(ble_cfg));
ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_MIN;
err_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, ram_start);
APP_ERROR_CHECK(err_code);

could help, but in my project this is not the case. I tried already various RAM-settings in the linker configuration file, but all without success. What can I do next?

  • Hi Hung Bui, I agree absolutely with you that the amount of characteristics has to be reduced, only in 4 weeks at a big exhibition some functions should do and the optimization has to wait for the time after the exhibition... Finally it's working now with all my self-created services and characteristics; I have increased the attribute table size to 4096 and increased the BLE stack part of the RAM in the Linker file to 0x4000; then it runs...

    MEMORY { FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 RAM (rwx) : ORIGIN = 0x20004000, LENGTH = 0xC000 }

    Why did I create so much services and specially characteristics? One service is for transmitting measured values like a temperature, a motor speed, an analogue value, the actual battery status and a time stamp (like the CTS). For the time stamp the idea is to get the system time and date from the BLE master just after pairing, then set the RTC in the nRF52832 and read and add the actual date and time whenever measured data are built. Probably I should use the cts_c service, but I did not already check that and I will additionally need to know how to integrate SDK characteristics (cts_c, probably also the battery level characteristic) in a self-created service which contains also other self-created charactersitics... Are there any examples in SDK13? Would you mix-up all the measured values like motor speed, temperature and analogue value in one characteristic? If yes, is there a document where this is decribed? Thanks a lot for your help; this is very usefull for me!

  • I don't see any problem mixing the measured data in one characteristic. They are just an array of bytes. You can use the first byte to determine which type of data is in the array. Says first byte = 1 mean the next byte is motor speed. First byte = 2 means next byte is temperature. You then can also group them together , first byte = 2 means next byte is temperature. Third byte = 1 mean forth byte is motor speed, and so on. (the length of the sensor data is determined so you should be able to extract them from the array)

  • Hello Hung Bui, the optimization will be done after the exhibition in September... Now I would like to send the actual speed value, but I get error message 13313 when using sd_ble_gatts_hvx() and I'm pretty sure having done the same as the Heart-Rate-Service uses for sending the heart-rate-value. Searching in the forum I see only comments for Softdevice 110 or very old SDKs, so I will post a new one with the right topic... Thanks for your help!

Related