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

what is max num all of Characteristics in the project?

my project use s110 8.0.0;I'm using nRF51422_xxAC.

And my project have 7 services.all the Characteristics is 81.

But after I had add 23 Characteristics ,I can't add any Characteristics,but the function sd_ble_gatts_characteristic_add is return NRF_SUCCESS,and Characteristic's value_handle is 0.

This means adding Characteristics is fail. So it will return attribute not found when the app request. This is my code :

static uint32_t ADMIN_char_add(ble_admin_t * p_admin,ble_char_t *ble_char)

{

ble_gatts_char_md_t char_md;

ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t    attr_char_value;
ble_uuid_t          ble_uuid;
ble_gatts_attr_md_t attr_md;

memset(&cccd_md, 0, sizeof(cccd_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);

cccd_md.vloc = BLE_GATTS_VLOC_STACK;

memset(&char_md, 0, sizeof(char_md));
if(ble_char->char_r_d == char_read_en)
{
	char_md.char_props.read   = 1;
	char_md.char_props.notify = 1;
	char_md.p_char_user_desc  = NULL;
	char_md.p_char_pf         = NULL;
	char_md.p_user_desc_md    = NULL;
	char_md.p_cccd_md         = &cccd_md;
	char_md.p_sccd_md         = NULL;
}
else if(ble_char->char_r_d == char_write_en)
{
    char_md.char_props.write   = 1;
	char_md.p_char_user_desc  = NULL;
	char_md.p_char_pf         = NULL;
	char_md.p_user_desc_md    = NULL;
	char_md.p_cccd_md         = &cccd_md;
	char_md.p_sccd_md         = NULL;
}
else if(ble_char->char_r_d == char_r_w_en)
{
	char_md.char_props.write  = 1;
    char_md.char_props.read   = 1;
	char_md.char_props.notify = 1;
	char_md.p_char_user_desc  = NULL;
	char_md.p_char_pf         = NULL;
	char_md.p_user_desc_md    = NULL;
	char_md.p_cccd_md         = &cccd_md;
	char_md.p_sccd_md         = NULL;
}


ble_uuid.type = p_admin->uuid_type;
ble_uuid.uuid = ble_char->uuid;

memset(&attr_md, 0, sizeof(attr_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

attr_md.vloc    = BLE_GATTS_VLOC_STACK;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen    = 1;

memset(&attr_char_value, 0, sizeof(attr_char_value));

attr_char_value.p_uuid    = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len  = 1;
attr_char_value.init_offs = 0;
attr_char_value.max_len   = ble_char->char_val_max_len;

return sd_ble_gatts_characteristic_add(p_admin->service_handle,
                                       &char_md,
                                       &attr_char_value,
                                       &ble_char->handles);

}

So what is the max num of all Characteristic ?

What else is there that I can try?

Parents
  • It is not an exact number. It depends on different factors.

    I'm a bit suprised that you get NRF_SUCCESS if the attribute table is full, I would expect NRF_ERROR_NO_MEM. Please confirm, and I will check it out.

    You can set the size of the attribute table when you enable the SoftDevice, examine the struct given to sd_ble_enable()

    Another trick is to store the attribute value in user memory, instead of stack memory. Use BLE_GATTS_VLOC_USER instead of BLE_GATTS_VLOC_STACK. Then you of course need to ensure that the value has a valid location in user memory.

  • Yes, i confirm it return NRF_SUCCESS. If I use BLE_GATTS_VLOC_USER instead of BLE_GATTS_VLOC_STACK,it also to .And i had make the ble_enable_params.gatts_enable_params.attr_tab_size = 0x700; it also to .

    It maybe has no attribute memory .

    Then I reference RK answer.RK 'S ANSWER I Configuration my project IROM1 size from 0x28000 to 0x28200,and set ble_enable_params.gatts_enable_params.attr_tab_size = 0x900; it successs,I can add Characteristic. thanks for your answer.

Reply
  • Yes, i confirm it return NRF_SUCCESS. If I use BLE_GATTS_VLOC_USER instead of BLE_GATTS_VLOC_STACK,it also to .And i had make the ble_enable_params.gatts_enable_params.attr_tab_size = 0x700; it also to .

    It maybe has no attribute memory .

    Then I reference RK answer.RK 'S ANSWER I Configuration my project IROM1 size from 0x28000 to 0x28200,and set ble_enable_params.gatts_enable_params.attr_tab_size = 0x900; it successs,I can add Characteristic. thanks for your answer.

Children
No Data
Related