/* Function for extracting the BSP event valid at startup. 
When a button was used to wake up the device, the button press will not generate an interrupt. This function reads which button was pressed at startup, and returns the appropriate BSP event. */
static uint32_t startup_event_extract(bsp_event_t *p_startup_event)
/* Function for extracting the BSP event valid at startup. 
When a button was used to wake up the device, the button press will not generate an interrupt. This function reads which button was pressed at startup, and returns the appropriate BSP event. */
static uint32_t startup_event_extract(bsp_event_t *p_startup_event)
{
    uint32_t err_code;
    bool wakeup_button_is_pressed, bond_erase_button_is_pressed;
    err_code = bsp_button_is_pressed(BTN_ID_WAKEUP, &wakeup_button_is_pressed);
    RETURN_ON_ERROR(err_code);
    err_code = bsp_button_is_pressed(BTN_ID_WAKEUP_BOND_DELETE, &bond_erase_button_is_pressed);
    RETURN_ON_ERROR(err_code);
    if (bond_erase_button_is_pressed)
    {
        *p_startup_event = BSP_EVENT_CLEAR_BONDING_DATA;
    }
    else if (wakeup_button_is_pressed)
    {
        *p_startup_event = BSP_EVENT_WAKEUP;
    }
    else
    {
        *p_startup_event = BSP_EVENT_NOTHING;
    }
    return NRF_SUCCESS;
}