Hi,
I'm having trouble stopping advertising after starting. I started with the ble_app_peripheral example and modified it so that it would only advertise after pressing a button for 5 seconds. When the timer stops after 5 seconds and the callback function is called I then try to stop advertising. I've tried many different methods and have been unsuccessful...
In order to only start advertising I have commented out anywhere with a call to user_app_adv_start( ), and modified the struct below, then call user_app_adv_start( ) in my 5 sec button press function.
// Default Handler Operations
static const struct default_app_operations user_default_app_operations = {
//.default_operation_adv = user_app_adv_start,
.default_operation_adv = NULL,
To stop advertising I have tried calling any of the below function but advertising continues and I can still connect even after calling:
- app_easy_gap_advertise_stop( )
- app_easy_timer_cancel(app_adv_data_update_timer_used)
- app_advertise_stop_op( )
I've even tried using the app_easy_gap_undirected_advertise_with_timeout_start( ), but still advertising never stops.
Please advise, thanks.
you can call app_easy_gap_advertise_stop( ) for stop adv.
meanwhile, after calling the function above, you will enter "user_app_adv_undirect_complete".
delete user_app_adv_start();
Then no adv will restart.
void user_app_adv_undirect_complete(uint8_t status)
{
// If advertising was canceled then update advertising data and start advertising again
我f (status == GAP_ERR_CANCELED)
{
//user_app_adv_start();
}
}