I just updated my project from SDK 15.3 to 16.0. I am using the nRF52840.
I am not receiving the APP_BUTTON_RELEASE event when waking up from a button press. It used to work on 15.3.
To help isolate the problem, I recreated it in the ble_app_template example project and ran it in both SDK 15.3 and 16.0 on the Nordic dev board. I made the following changes in each SDK:
In bsp.c, in the bsp_button_event_handler() , I added the following serial debug line of code:
case APP_BUTTON_RELEASE: (void)app_timer_stop(m_bsp_button_tmr); NRF_LOG_RAW_INFO("button release\r\n");
In main.c, I modified the sleep_mode_enter() with a serial debug line of code and removed the APP_ERROR_CHECK() to simulate sleep while debugging:
static void sleep_mode_enter(void) { ret_code_t err_code; NRF_LOG_RAW_INFO("sleep_mode_enter\r\n"); NRF_LOG_FLUSH(); 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); while (1){} }
In main.c, I also decreased advertising time to 10 seconds for convenience so that it will go to sleep sooner:
#define APP_ADV_DURATION 1000
I run the app by:
- Start the ble_app_template example.
- Allow advertising to time out so that it goes into sleep mode.
- Press the button to wake it back up.
When I run the ble_app_template example in 15.3, I get the following Debug Terminal Output:
<info> app: Template example started.
<info> app: Fast advertising.
sleep_mode_enter
<info> app: Template example started.
<info> app: Fast advertising.
button release
sleep_mode_enter
The app resets upon button press as expected. Notice "button release". This means that I get the button release event.
When I run the ble_app_template example in 16.0, I get the following Debug Terminal Output:
<info> app_timer: RTC: initialized.
<info> app: Template example started.
<info> app: Fast advertising.
sleep_mode_enter
<info> app_timer: RTC: initialized.
<info> app: Template example started.
<info> app: Fast advertising.
sleep_mode_enter
The app resets upon button press as expected. Although, I do not get a button release event.
It is very important to my project to get this event. I need to detect the release event so that I can differentiate between a short and long press upon wakeup from a button press.