Hi,
I've been working on the hrs example for nRF52840 DK and I wanted to add buttons to the project. For the first button (I took from app_blinky), it is working perfectly fine. I thought it worked perfectly fine for the second as well until I noticed that unlike the case with only one button, the advertising wasn't starting again after APP_ADV_DURATION.
The sd_power_system_off() starts returning the error code 8198. I read somewhere that it was normal as this function isn't suppose to work in debug mode. It will enter its emulated state, which was working fine with one button. I wonder why adding as second button changed its behaviour:
static void buttons_init(void)
{
ret_code_t err_code;
//The array must be static because a pointer to it will be saved in the button handler module.
static app_button_cfg_t buttons[] =
{
{START_BUTTON, false, BUTTON_PULL, button_event_handler},
{STOP_BUTTON, false, BUTTON_PULL, button_event_handler},
};
err_code = app_button_init(buttons, ARRAY_SIZE(buttons),
BUTTON_DETECTION_DELAY);
APP_ERROR_CHECK(err_code);
}
Did I need to change something in sdk_config.h in order to add one more button ? I didn't see anything important while looking into the file. Why is sd_power_system_off() returning something now while it wasn't previously ?
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,
FM