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

bsp_event handler not seeing button presses

I'm running the app_uart_c example on a nRF52832 with softdevice 132 installed.

I'm trying to alter it so that the board only searches for peripheral devices upon a button press. However, it doesn't seem to register when I press a button. I have a global variable tied to the event returned by pressing button 3, but it doesn't change when I press the button.

I have called bsp_buttons_enable() and app_button_enable(), but still have this issue.

I added this line to the led and button init method: bsp_event_to_button_action_assign(2, BSP_BUTTON_ACTION_PUSH, BSP_EVENT_KEY_3);

Then in the bsp_event handler I added this case: case BSP_EVENT_KEY_3: printf("Button 3 pressed"); if (accepting_cmds) { send_test_msg(); } but_3_pressed = 1;

Then in my main method I have the following: //add wait for response to start printf("Press button 3 to start scanning..\n\r");

while(but_3_pressed == 0)
{
  //wait until button is pressed
}
// Start scanning for peripherals and initiate connection
// with devices that advertise Levi UUID.
printf("Uart_c Scan started\r\n");
but_3_pressed = 0;
scan_start();

What might I be missing? Do I need to call something else to trigger interrupts on button presses?

Related