Hello,
I am using PAwR (Periodic Advertsing with Response) in coded PHY (S8) with SDK 2.7.0, following the Nordic demo :
I want to change, in run time, the advertising interval ".interval_min" and ".interval_max" initialised with the structure "static const struct bt_le_per_adv_param per_adv_params"
More precisely I want to change it frequently between fast and slow advertising.
Is it possible to do so in the case of PAwR ? Is there any example for illustration ? Should I go through the whole process of sync (initialisation connexion disconnexion) to be able to change it whenever I want ? Or should I just use the following snippet which stops advertising resets the new parameters and starts advertising :
struct bt_le_ext_adv *pawr_adv; struct bt_le_adv_param *params = BT_LE_EXT_ADV_NCONN; params->options |= BT_LE_ADV_OPT_USE_IDENTITY | BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_CODED; params->sid = 0; /* Create a non-connectable non-scannable advertising set */ err = bt_le_ext_adv_create(params, &adv_cb, &pawr_adv); //BT_LE_EXT_ADV_NCONN //BT_LE_EXT_ADV_CODED_NCONN if (err) { LOG_ERR("Failed to create advertising set (err %d)\n", err); return 0; } // Stop periodic advertising err = bt_le_per_adv_stop(pawr_adv); if (err) { LOG_INF("Failed to stop periodic advertising (err %d)\n", err); return; } // Set new adv parameters struct bt_le_per_adv_param per_adv_param = { .interval_min = min_int, .interval_max = max_int, .options = 0, .num_subevents = NUM_SUBEVENTS, .subevent_interval = 120, .response_slot_delay = 5, .response_slot_spacing = 40, .num_response_slots = NUM_RSP_SLOTS, }; /* Set periodic advertising parameters */ err = bt_le_per_adv_set_param(pawr_adv, &per_adv_params); if (err) { LOG_ERR("Failed to set periodic advertising parameters (err %d)\n", err); return 0; } /* Enable Periodic Advertising */ err = bt_le_per_adv_start(pawr_adv); if (err) { LOG_ERR("Failed to enable periodic advertising (err %d)\n", err); return 0; } LOG_DBG("Start Periodic Advertising\n"); err = bt_le_ext_adv_start(pawr_adv, BT_LE_EXT_ADV_START_DEFAULT); if (err) { LOG_ERR("Failed to start extended advertising (err %d)\n", err); return 0; }