hello there i want to put my nrf51822 in sleep mode when it is not advertising. can you tell me how to do it?
hello there i want to put my nrf51822 in sleep mode when it is not advertising. can you tell me how to do it?
you can see it in most demo.
I can tell you most of this operation occur is when the ADV (fast ADV / Slow ADV / direct ADV, etc.) time out. So you can find it in the adv time out call back function. And slow ADV is always the last ADv type, then go to sleep. You can find what you want by search BLE_ADV_EVT_IDLE.
case BLE_ADV_MODE_SLOW:
m_adv_evt = BLE_ADV_EVT_IDLE;
LOG("[ADV]: Timed out from slow advertising, stopping advertising.\r\n");
if (m_evt_handler != NULL)
{
m_evt_handler(m_adv_evt);
}
break;
static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
uint32_t err_code;
switch (ble_adv_evt)
{
case BLE_ADV_EVT_FAST:
err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
APP_ERROR_CHECK(err_code);
break;
case BLE_ADV_EVT_IDLE:
sleep_mode_enter();
break;
default:
break;
}
}
Just for clarification:
__WFE(): Short for Wait For Event. Will put the CPU in system ON sleep mode. This is done in sd_app_evt_wait() function (located in power_manage() in the SDK examples). The CPU will wake up on any event.
sd_power_system_off(): Will put the CPU in system OFF sleep mode. The CPU can only wake up on gpio (which is configured in bsp_btn_ble_sleep_mode_prepare()).
See this post for and the Product Specifcation more info and for how much current is consumed in the different modes.
Just for clarification:
__WFE(): Short for Wait For Event. Will put the CPU in system ON sleep mode. This is done in sd_app_evt_wait() function (located in power_manage() in the SDK examples). The CPU will wake up on any event.
sd_power_system_off(): Will put the CPU in system OFF sleep mode. The CPU can only wake up on gpio (which is configured in bsp_btn_ble_sleep_mode_prepare()).
See this post for and the Product Specifcation more info and for how much current is consumed in the different modes.