This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there a code example of how to use uuids_more_available

Hello,

at the moment I try to add some more services to my BLE device. This goes wrong with err_code = 12 (NRF_ERROR_DATA_SIZE). With some search in the devZone I found out, that it is not possible to advertise more than two uuids because of the size limitation. Also I found out, that if I want to have more than two Services, I have to use uuids_more_available. But I didt found a simple code example of how to do that. I tried it like this:

static void advertising_init(void){
uint32_t      err_code;
ble_advdata_t advdata;
	ble_advdata_t scanrsp;
	
	ble_uuid_t adv_uuids[] = {{BLE_UUID_DEVICE_SERVICE, GRL_DEV_SERVICE_UUID_TYPE},{BLE_UUID_SERVICE_COMMAND, GRL_COM_SERVICE_UUID_TYPE}};

// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type             = BLE_ADVDATA_FULL_NAME;
	advdata.include_appearance      = true;
advdata.flags                 = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
	
	memset(&scanrsp, 0, sizeof(scanrsp));
//scanrsp.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
//scanrsp.uuids_complete.p_uuids  = adv_uuids;
	scanrsp.uuids_more_available.uuid_cnt = 3; // new
	scanrsp.uuids_more_available.p_uuids  = adv_uuids;
	
	ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);}

But that doesn`t work. Anyway I get the NRF_ERROR_DATA_SIZE when I come to my services_init() function and try to add my service with sd_ble_uuid_vs_add(&com_base_uuid, &p_com->uuid_type);.

Thanks for any help.

Regards, BTprogrammer

Parents
  • Hello Petter, thanks for your reply. For now, I also belive that there is no problem with the length of the advertising data. Im able to add one custom service. I can also add a second custom service. But when I trie to add a characteristic to this service, I get an NRF_ERROR=12 (NRF_ERROR_DATA_SIZE). But I dont know how I can solve this issue... :-( Can someone have a look on my ble_command_init() function? The second custom service is called command...

    uint32_t ble_command_init(ble_command_t * p_com, const ble_command_init_t * p_com_init){
    uint32_t   err_code;
    ble_uuid_t ble_uuid;
    
    // Initialize service structure
    p_com->conn_handle = BLE_CONN_HANDLE_INVALID;
    //p_com->type   = p_com_init->temp_type;
    
    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SERVICE_COMMAND);
    
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_com->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    	
    	err_code = direction_char_add(p_com, p_com_init);
    	if (err_code != NRF_SUCCESS)
    {
        printf("err_code_direction_add=%d\r",err_code);
    			return err_code;
    }
    	
    return NRF_SUCCESS;}
    

    Thanks, BTprogrammer

Reply
  • Hello Petter, thanks for your reply. For now, I also belive that there is no problem with the length of the advertising data. Im able to add one custom service. I can also add a second custom service. But when I trie to add a characteristic to this service, I get an NRF_ERROR=12 (NRF_ERROR_DATA_SIZE). But I dont know how I can solve this issue... :-( Can someone have a look on my ble_command_init() function? The second custom service is called command...

    uint32_t ble_command_init(ble_command_t * p_com, const ble_command_init_t * p_com_init){
    uint32_t   err_code;
    ble_uuid_t ble_uuid;
    
    // Initialize service structure
    p_com->conn_handle = BLE_CONN_HANDLE_INVALID;
    //p_com->type   = p_com_init->temp_type;
    
    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SERVICE_COMMAND);
    
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_com->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    	
    	err_code = direction_char_add(p_com, p_com_init);
    	if (err_code != NRF_SUCCESS)
    {
        printf("err_code_direction_add=%d\r",err_code);
    			return err_code;
    }
    	
    return NRF_SUCCESS;}
    

    Thanks, BTprogrammer

Children
No Data
Related