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

nRF52840 DK, implementing Board Button event handler, but no response on button press.

Hi, 

I am trying to do some tasks based on a particular button press, below attached is the buttons_init() function and the button_evt_handler() function. Code compiles and runs successfully, but nothing happens on button press. Please let me know if I am missing out on something. 

Thanks in advance.

static void buttons_init(void)
{
    uint32_t err_code;

    static app_button_cfg_t buttons[] = 
    { 
        {BSP_BUTTON_0, false, BUTTON_PULL, button_evt_handler},
        {BSP_BUTTON_1, false, BUTTON_PULL, button_evt_handler}
    };

    err_code = app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DEBOUNCE_DELAY);
    APP_ERROR_CHECK(err_code);

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

static void button_evt_handler(uint8_t pin_no, uint8_t button_action)
{
    if(button_action == APP_BUTTON_PUSH)
    {
        switch(pin_no)
        {
            case BSP_BUTTON_0:
                NRF_LOG_INFO("Sending blood pressure data\r\n");
                break;
            case BSP_BUTTON_1:
                NRF_LOG_INFO("Sending temperature data\r\n");
                break;
            default:
                NRF_LOG_INFO("Default case\r\n");
                break;
        }
        
    }
}

Parents
  • Hi ,

    Sorry for the delay.

    Well, you have a lot of issues in your ble service and characteristics. And I think this is where the issue come from.

    I have fixed lot of issues there, also added a function to get the SOC temperature and send it over the temperature characteristic. Also added another characteristic, I called it the command char, it can be used to send commands from the central to the application.

    The temperature char has the notify and the read property enabled, and can be used to send temperature values to the connected and subscribed central device.

    The command char has the write property enabled, and can be used to receive data from the central device.

    Try to use the UART, to see the application logging.

    Please find the project files in this github repos.

    Best regards,

    rmptxf

  • Hi again, 

    Thanks for the help, I was following a tutorial for creating a custom service and characteristic. I ll have a look at the code, thanks a lot again for this!

    Regards, 

    Paarth

Reply Children
No Data
Related