Hi Nordic Team,
My requirement is-
Advertise -> Connect to 1 device -> Send packet -> Disconnect -> Delay(1min) -> Advertise -> Connect to 2 device...
I am using Timer to make some delay to restart the advertisement for connecting to another peripheral, But if 2 peripheral is not connected within ADVERTISING_INTERVAL, its going to nrf breakpoint condition. Timer is not repeating for advertising again.
/*Timer init */
static void timers_init(void)
{
// Initialize timer module.
ret_code_t err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
/*creating timer */
err_code = app_timer_create(&advertising_timer_id, APP_TIMER_MODE_REPEATED, advertising_timeout_handler);
APP_ERROR_CHECK(err_code);
}
/*Timer Handler */
static void advertising_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
bool erase_bonds;
advertising_start(erase_bonds);
}
/*BLE event handler*/
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
ret_code_t err_code = NRF_SUCCESS;
bool erase_bonds;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_DISCONNECTED:
printf("Disconnected.\n");
NRF_LOG_INFO("Disconnected.");
err_code = app_timer_start(advertising_timer_id, ADVERTISING_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
break;
case BLE_GAP_EVT_CONNECTED:
err_code = app_timer_stop(advertising_timer_id);
APP_ERROR_CHECK(err_code);
...
}
Kindly Suggest the correct way to use advertising start() for periodical advertisement.