Could you give me an example how to restart advertising after timeout.
thank.
sorry, i need on the button event to restart advertising.
Could you give me an example how to restart advertising after timeout.
thank.
sorry, i need on the button event to restart advertising.
In on_ble_evt()
function add
case BLE_GAP_EVT_TIMEOUT:
if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
{
advertising_start();
}
break;
Hi,
just start advertising again upon BLE_ADV_EVT_IDLE in advertising event handler.
static void on_adv_evt(ble_adv_evt_t ble_adv_evt) {
ret_code_t err_code;
switch (ble_adv_evt) {
case BLE_ADV_EVT_IDLE:
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
break;
}
}
Yurii
Then in your hids_mouse example you probably using, in bsp_event_handler()
under lets say button 0 have:
case BSP_EVENT_KEY_0:
if (m_conn_handle == BLE_CONN_HANDLE_INVALID)
{
advertising_start();
}
break;
Use any button, just make sure it is defined properly
This worked for me !!! But there was slight change in this
static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
uint32_t err_code;
switch (ble_adv_evt)
{
case BLE_ADV_EVT_IDLE:
err_code = ble_advertising_start(&m_advertising,BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
break;
case BLE_ADV_EVT_FAST:
err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
APP_ERROR_CHECK(err_code);
break;
default:
break;
}
}
Thank you so much!!!!!