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

    Just to make sure, in order to have "changed the advertising time to 5 seconds" you edited the #define APP_ADV_DURATION last for 5 seconds, or alternatively changed the adv_params.duration to 5 seconds in your advertising_init() function, correct? This means it will advertise for 5 seconds before going to sleep (likely without connecting at all, since 5 seconds is not much time for a central to discover it and connect to it. The ble_app_blinky uses the sd_ble_gap_adv_start function in the SoftDevice to start advertising, and according to the message sequence chart it will go to IDLE mode if it times out before connecting to a device.

    I strongly recommend that you increase this somewhat so a central has the chance to connect to your device, as this example project is designed to connect to a device. If not I would check out the ble_app_beacon project instead, which is designed to only advertise.

    Best regards,

    Simon

Reply
  • Hi

    Just to make sure, in order to have "changed the advertising time to 5 seconds" you edited the #define APP_ADV_DURATION last for 5 seconds, or alternatively changed the adv_params.duration to 5 seconds in your advertising_init() function, correct? This means it will advertise for 5 seconds before going to sleep (likely without connecting at all, since 5 seconds is not much time for a central to discover it and connect to it. The ble_app_blinky uses the sd_ble_gap_adv_start function in the SoftDevice to start advertising, and according to the message sequence chart it will go to IDLE mode if it times out before connecting to a device.

    I strongly recommend that you increase this somewhat so a central has the chance to connect to your device, as this example project is designed to connect to a device. If not I would check out the ble_app_beacon project instead, which is designed to only advertise.

    Best regards,

    Simon

Children
  • Hi Simon,

    Thanks for your reply. Yes, I am using #define APP_ADV_DURATION 500. So far is connecting to the central, I will increase it if I find issues with that. 

    I need to connect to the central, I am just powering it off quickly to save power.

    I guess I can't or shouldn´t modify the softdevice code. My intention is to set up the button to wake up when is pressed.

    I added this case into the ble_evt_handler and it prints the message.

            case BLE_GAP_EVT_ADV_SET_TERMINATED:
            	NRF_LOG_INFO("AdvTimeout!");
            	break;

    I have now to add the code to prepare the button before going to sleep, which I haven´t done before, if you had a simple piece of code for it would be much appreciated, or some indications.

    Another question is, when it wakes up, does it reset or continue in the infinite loop? 

    Thanks!

Related