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

error add multi characteristic to service

Hi all, 

I want to add 5 characteristic to my custom service . But when I add 2 characteristic , it worked fine . When I add 3 characteristic ,In funtion sd_ble_gatts_characteristic_add of characteristic 3 get error 4 : NRF_ERROR_NO_MEM . And then I change BLE_GATTS_ATTR_TAB_SIZE_DEFAULT from 1408 to 2048 . But It still error 4 . Please show me solution . Thank you very much !!!

  • Hi,

    The BLE_GATTS_ATTR_TAB_SIZE_DEFAULT define is from a SoftDevice header file (ble_gatts.h), and it does not change anything if you redefine it to another value. The define is there only to tell you what attribute table size the SoftDevice uses if you do not configure it from your application to use another value.

    If you use the SoftDevice Handler library, and use nrf_sdh_ble_default_cfg_set() to configure the SoftDevice, then you can set the attribute table size by the NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE define in sdk_config.h.

    If you configure the SoftDevice by direct calls to sd_ble_cfg_set(), then the following code example shows how to set the attribute table size:

    uint32_t ret_code;
    ble_cfg_t ble_cfg;
    
    // Assuming that application RAM base is defined in APP_RAM_BASE, which is also the value passed to sd_ble_enable().
    // Set GATTS attribute table size to MY_ATTRIBUTE_TABLE_SIZE
    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
    ble_cfg.gatts_cfg.attr_tab_size.attr_tab_size = MY_ATTRIBUTE_TABLE_SIZE;
    ret_code = sd_ble_cfg_set(BLE_GATTS_CFG_ATTR_TAB_SIZE, &ble_cfg, APP_RAM_BASE);
    APP_ERROR_CHECK(ret_code);

    Regards,
    Terje

  • It worked fine . I want to ask . If I want to increase number characteristic and still encounter this error , I will increase NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE  ? And What is its greatest value? Thank very much!!!

  • Hi,

    Glad to hear it works. It will increase SoftDevice RAM usage, which means less RAM for the shared stack and for the application. It also means you may have to change RAM start and RAM size for the application after the increase, and the maximum is limited by total RAM on the SoC. See also this thread.

    Regards,
    Terje

Related