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

Possibility to change advertising timeout

Hello,

I want to change the advertising timout during runtime. We have two use cases for our device:

  1. Batterie mode --> advertising timeout = 2min

  2. Power supply --> no advertising timeout (advertising timeout = 0)

Is it possible to change this sofdevice parameter during runtime? If yes, how to do that? ;-)

I am using S120 on a nRF51822.

Regards, BTprogrammer

Parents
  • Hey, sorry, but I didn`t get it running with the suggested solution. This is my advertising_init() function:

    static uint32_t 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}};
    
    // 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_GENERAL_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.
    	
    	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);
    	return err_code;}
    

    It is pretty much the same than in the ble_app_uart example. But if I set APP_ADV_TIMEOUT_IN_SECONDS to zero, the device isn`t accessible via BLE anymore...

    To switch between the two modes, I believe I will need the sd_ble_gap_adv_start() function. But in my current implementation, this is handled by the ble_advertising_start() function in ble_advertising.c So where do I get the needed adv_params during runtime? BR

Reply
  • Hey, sorry, but I didn`t get it running with the suggested solution. This is my advertising_init() function:

    static uint32_t 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}};
    
    // 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_GENERAL_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.
    	
    	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);
    	return err_code;}
    

    It is pretty much the same than in the ble_app_uart example. But if I set APP_ADV_TIMEOUT_IN_SECONDS to zero, the device isn`t accessible via BLE anymore...

    To switch between the two modes, I believe I will need the sd_ble_gap_adv_start() function. But in my current implementation, this is handled by the ble_advertising_start() function in ble_advertising.c So where do I get the needed adv_params during runtime? BR

Children
No Data
Related