Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Button inturrpt works only once

Hi,

We have added support to button click in our design but the intruppt only works once at the first time it is pressed.

What am I missing here? why is the button_evt_handler working only for the first button push?

static void button_evt_handler(uint8_t pin_no, uint8_t button_action)

{

//todo something

}

static void button_init(void)
{
ret_code_t err_code;
const uint8_t buttons_cnt = 1;
static app_button_cfg_t buttons_cfgs =
{
.pin_no = BUTTON_1, 
.active_state = APP_BUTTON_ACTIVE_LOW,
.pull_cfg = NRF_GPIO_PIN_PULLUP,
.button_handler = button_evt_handler
};

err_code = app_button_init(&buttons_cfgs, buttons_cnt, APP_TIMER_TICKS(100));
APP_ERROR_CHECK(err_code);

err_code = app_button_enable();
APP_ERROR_CHECK(err_code);
}

int main(void){

....

button_init();

....

}

Parents Reply Children
  • The link is about button push or realese.

    Im my case I care only about Push and the button_evt_handler is called only once in the first push and not working(no function call to button_evt_handler) in any of the follwoing push buttons 

    Is there a command that needs to be registred after every usage of the button_evt_handler?

  • Try this example :SDK\examples\ble_peripheral\experimental_ble_app_blinky

    and edit the function like below (static void button_event_handler(uint8_t pin_no, uint8_t button_action))

    static void button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
            uint32_t err_code;
      
        switch (pin_no)
        {
               	case LEDBUTTON_BUTTON_PIN:
                          switch (button_action)
                          {
                                 case APP_BUTTON_PUSH:
                                      // Do your task
                                 break;
                                case APP_BUTTON_RELEASE:
                                      // Do your task
                                break;
    		  default:
                                    break;
                           }
                  break;
                  default:
                  APP_ERROR_HANDLER(pin_no);
                  break;	
        }
    }

  • i want to remove this button push (registration)..and want function "nrf_ble_es_on_start_connectable_advertising()"

    to be called directly...

    i tried commenting "app_button_init(&buttons_cfgs, buttons_cnt, APP_TIMER_TICKS(100));"

    and then called "nrf_ble_es_on_start_connectable_advertising()"   directly in button_init()..but eddystone is not advertising...i am using sdk15.3 and nrf52832...

    can you help me out

    Thank you

  • Hi.

    Could you create a new ticket for this issue?

    Since this question is not the same as the one asked in the start of this ticket, this ticket is also over one year old, and it will be hard for other community members to find it when they are searching.

    Best regards,

    Andreas

Related