How to change the advert interval in NRF connect sdk project?

Hi All,

I am working with NRF beacon project currently, and I explored many other NRF connect SDK sample projects like, Ble peripheral, ibeacon etc. But I am unable to find, how and where I can change the ble advert interval.  

So, please help me in changing the BLE advert interval.

Thanks & Regards,

Pradeep 

Parents
  • Hi Pradeep

    The advertising interval is included in the bt_le_adv_param struct, which is the first argument to the bt_le_adv_start(..) function. In the beacon example it will simply use one of the standard advertising parameter defines, setting all the parameters for you, but it is possible to define the fields of this struct yourself. 

    Please find some code attached, showing a way to modify the standard settings before passing them to the bt_le_adv_start(..) function:

    /* Make a local copy of the BLE advertising parameters */
    struct bt_le_adv_param adv_params = *(BT_LE_ADV_NCONN_IDENTITY); 
    adv_params.interval_min = 1000;
    adv_params.interval_max = 1000;
    
    /* Start advertising */
    err = bt_le_adv_start(&adv_params, ad, ARRAY_SIZE(ad),
    		      sd, ARRAY_SIZE(sd));
    if (err) {
    	printk("Advertising failed to start (err %d)\n", err);
    	return;
    }

    Best regards
    Torbjørn

Reply
  • Hi Pradeep

    The advertising interval is included in the bt_le_adv_param struct, which is the first argument to the bt_le_adv_start(..) function. In the beacon example it will simply use one of the standard advertising parameter defines, setting all the parameters for you, but it is possible to define the fields of this struct yourself. 

    Please find some code attached, showing a way to modify the standard settings before passing them to the bt_le_adv_start(..) function:

    /* Make a local copy of the BLE advertising parameters */
    struct bt_le_adv_param adv_params = *(BT_LE_ADV_NCONN_IDENTITY); 
    adv_params.interval_min = 1000;
    adv_params.interval_max = 1000;
    
    /* Start advertising */
    err = bt_le_adv_start(&adv_params, ad, ARRAY_SIZE(ad),
    		      sd, ARRAY_SIZE(sd));
    if (err) {
    	printk("Advertising failed to start (err %d)\n", err);
    	return;
    }

    Best regards
    Torbjørn

Children
No Data
Related