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

wants to know that device will go sleep or it just stop advertise after timeout occurs

Hi i am using nrf52840 DK and i am trying out sleep_mode after timeout happens. but i had a doubt in ble_adv_evt_idle i.e if i use this case the device goes into sleep and i fi use ble_adv_evt_fast then after timeout i could not able see any advertisement packet. is so because device gone into sleep or system is still on but advertisement is not happening.

  • Hi

    Due to the Easter holiday we are understaffed and you will have to expect delayed replies. Sorry for the inconvenience!

    ble_adv_evt_idle does not make your device go to sleep. To make your device go to sleep, use the __WFE function for example. The rest of your question I am having some trouble understanding. Does your device not start advertising after the connection with the central times out? Try resetting the central to confirm whether or not the peripheral device is the problem.

    Best regards and happy Easter,

    Simon

  • Thanks for you reply. Actually in ble_app_uart peripheral there is an function called on_adv_evt in that two switch cases were defined one is BLE_ADV_EVT_FAST and another one BLE_ADV_EVT_IDLE. so the example code starts advertising and i reduce the timeout from 180sec to 10sec. After the timeout i cannot able to discover any advertisement in my nrfConnect app. so i want to advertise till timeout then go to sleep then wake up and advertise. i have read some post recently and what they said was use RTC1 timer to wake up device, if so tell me how to use rtc timer or suggest me some examples and i am trying to implement system_power_on() instead of system_power_off to run cpu but if i change to system_power_on() compile error as undefined system_power_on(nrf SDK 15.3.0). Tell me is there any alternative function to make cpu on while sleep.

  • Hi

    As I said, __WFE is one way to go to sleep (in system on mode). This function looks nicer, if that's what you want. 

    /** @brief Function for placing the application in low power state while waiting for events. */
    static void power_manage(void)
    {
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }

    To see how it is implemented in the main loop, you can have a look at the usbd_ble_uart example project.

    Best regards,

    Simon

  • while i am testing ble_app_uart peripheral example in main for loop there is an idle_state_handle() function called, so inside that pwr_mgnt function was called. if you look into it the same whatever you said before for sleep sd_app_evt_wait() was called but device not sleeping its still advertising for 10 sec.

    can you explain me what functionality will be disabled if i call sd_app_evt_wait()? basically i want to put device in sleep then wake up using rtc0 timer. now i can implement rtc timer, when the timer expires i am advertising again but there is no advertising data.

  • Hi

    Please see the Infocenter on what the sd_app_evt_what() function does, and how it is used. I am having a little trouble understanding what you are struggling with. I am guessing your application is set to advertise for 10 seconds before going to sleep, which is why the sd_app_evt_wait() isn't working right away. It will wait for your application to finish advertising before putting it to sleep. As for why you can't discover the advertising data after sleep, I am not quite sure. How are you waking up your device? And how are you sure you are advertising if there is no advertising data?

    Best regards,

    Simon

Related