NRF52, ble_blinky example: advertising timeout event and sleep calls, how?

Hi,

I am using the ble_blinky example as a template to develop my project, with nRF52832  and SDK 17.0.2.

My first goal is to reduce consumption, so I have changed the advertising time to 5 seconds, after this time it is automatically powered off. I need to configure a button before it goes to sleep to enable waking up.

For the blinky example, the question is what function is getting this timeout event and putting the device to sleep? 

i.e., in the ble_app_uart example, as mentioned in this thread, I can find it in the ble_advertising.c file, but for the blinky example, it doesn´t use this file, so I am not able to identify where the event detection and the sleeping function call is happening.

Thanks in advance!

Parents
  • Hi

    If you're connecting to the central device the advertiser won't go to sleep after 5 seconds, as it will stay in a connected state until it either is disconnected from the central or peripheral side or the connection supervision time runs out.

    To see how you can set up wakeup buttons, please check out the sleep_mode_enter() function which is present in multiple example projects in the nRF5 SDK. The ble_app_gls example for instance.

    /**@brief Function for putting the chip into sleep mode.
     *
     * @note This function will not return.
     */
    static void sleep_mode_enter(void)
    {
        ret_code_t err_code;;
        err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

    Best regards,

    Simon

Reply
  • Hi

    If you're connecting to the central device the advertiser won't go to sleep after 5 seconds, as it will stay in a connected state until it either is disconnected from the central or peripheral side or the connection supervision time runs out.

    To see how you can set up wakeup buttons, please check out the sleep_mode_enter() function which is present in multiple example projects in the nRF5 SDK. The ble_app_gls example for instance.

    /**@brief Function for putting the chip into sleep mode.
     *
     * @note This function will not return.
     */
    static void sleep_mode_enter(void)
    {
        ret_code_t err_code;;
        err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        APP_ERROR_CHECK(err_code);
    
        // Prepare wakeup buttons.
        err_code = bsp_btn_ble_sleep_mode_prepare();
        APP_ERROR_CHECK(err_code);
    
        // Go to system-off mode (this function will not return; wakeup will cause a reset).
        err_code = sd_power_system_off();
        APP_ERROR_CHECK(err_code);
    }

    Best regards,

    Simon

Children
Related