This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sleep Immediately after Beacon Advertisement

I'm using the following code to make the beacon sleep:

static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t        err_code;
    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
        {
            break;
        }
        case BLE_GAP_EVT_TIMEOUT:
        {
            if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISING)
            {
                sd_ble_gap_adv_stop();
                ble_fsm_set_state(Ble_Fsm_State_Idle);
            }
            break;
        }
        default:
        {
            break;
        }
    }
}

Once the state is set to idle, the nrf51 chip goes to sleep and the current draw drops to the order of uA. My only problem here is that the minimum timeout value is 1s and this means that the chip is burning power for 1s. Ideally, I would like the beacon to just advertise once and then go to sleep immediately. What is the best way to do this? Adding a synchronous delay of 5 ms? Any callback that I can use instead?

Parents
  • What do you mean by "sleep"? I assume that nRF5x chip is going to POWER ON SLEEP (wait for event/interrupt) always when nothing is running on MCU so even between adv. events. If you mean POWER OFF state then sure you can do it but no BLE activity can be running during that time, you need to manage wake-up by some external GPIO interrupt line (button or some RTC capable chip if you expect to wake-up periodically).

  • Hmm.. my suspicion is that sd_ble_gap_adv_start() actually sets the radio into RX on because it will wait for a device to connect (but joke's on them since beacons are unconnectable). So, that's why it draws 20 mA for the time when the radio is ON (measured with a scope.. and verified my other claims with a scope too). You don't buy this explanation, do you?

Reply
  • Hmm.. my suspicion is that sd_ble_gap_adv_start() actually sets the radio into RX on because it will wait for a device to connect (but joke's on them since beacons are unconnectable). So, that's why it draws 20 mA for the time when the radio is ON (measured with a scope.. and verified my other claims with a scope too). You don't buy this explanation, do you?

Children
No Data
Related