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

BSP_BUTTON_ACTION_LONG_PUSH does not work after a CONNECTION

Hi,

After a connection long push event does not work! But before a connection long push works fluently.

I could not found the error.

Thank you for your interest.

I am initializing with this

static void buttons_leds_init( void )
{
    uint32_t err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    APP_ERROR_CHECK(err_code);

    err_code = bsp_event_to_button_action_assign(BSP_BOARD_BUTTON_0, BSP_BUTTON_ACTION_PUSH, BT0_SHORT_PUSH);
    APP_ERROR_CHECK(err_code);

    err_code = bsp_event_to_button_action_assign(BSP_BOARD_BUTTON_0, BSP_BUTTON_ACTION_LONG_PUSH, BT0_LONG_PUSH);
    APP_ERROR_CHECK(err_code);

    
}

Parents
  • Hi,

    When you connect, you get the event BLE_GAP_EVT_CONNECTED. In bsp_btn_ble.c, the function connection_buttons_configure() is then called. It looks like this:

    static uint32_t connection_buttons_configure()
    {
        uint32_t err_code;
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
                                                     BTN_ACTION_SLEEP,
                                                     BSP_EVENT_DEFAULT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
                                                     BTN_ACTION_WHITELIST_OFF,
                                                     BSP_EVENT_WHITELIST_OFF);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
                                                     BTN_ACTION_DISCONNECT,
                                                     BSP_EVENT_DISCONNECT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        return NRF_SUCCESS;
    }

    A long push on button 0, will then be configured to generate the event "BSP_EVENT_DISCONNECT" instead. I.e. your long push button0 event,BT0_LONG_PUSH, is replaced with "BSP_EVENT_DISCONNECT" event.

Reply
  • Hi,

    When you connect, you get the event BLE_GAP_EVT_CONNECTED. In bsp_btn_ble.c, the function connection_buttons_configure() is then called. It looks like this:

    static uint32_t connection_buttons_configure()
    {
        uint32_t err_code;
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_SLEEP,
                                                     BTN_ACTION_SLEEP,
                                                     BSP_EVENT_DEFAULT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_WHITELIST_OFF,
                                                     BTN_ACTION_WHITELIST_OFF,
                                                     BSP_EVENT_WHITELIST_OFF);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
    
        err_code = bsp_event_to_button_action_assign(BTN_ID_DISCONNECT,
                                                     BTN_ACTION_DISCONNECT,
                                                     BSP_EVENT_DISCONNECT);
        RETURN_ON_ERROR_NOT_INVALID_PARAM(err_code);
    
        return NRF_SUCCESS;
    }

    A long push on button 0, will then be configured to generate the event "BSP_EVENT_DISCONNECT" instead. I.e. your long push button0 event,BT0_LONG_PUSH, is replaced with "BSP_EVENT_DISCONNECT" event.

Children
No Data
Related