<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65624/nrf52840-dk-implementing-board-button-event-handler-but-no-response-on-button-press</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 12 Sep 2020 21:57:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65624/nrf52840-dk-implementing-board-button-event-handler-but-no-response-on-button-press" /><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/269255?ContentTypeID=1</link><pubDate>Sat, 12 Sep 2020 21:57:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2335a707-d87c-453d-98d3-5190b2fd5ab5</guid><dc:creator>Paarth_Ved23</dc:creator><description>&lt;p&gt;Hi again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;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!&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Paarth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/269253?ContentTypeID=1</link><pubDate>Sat, 12 Sep 2020 21:49:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae309e33-52df-40e8-84d3-f1463411086a</guid><dc:creator>rmptxf</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/paarth_5f00_ved23"&gt;Paarth_Ved23&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Sorry for the delay.&lt;/p&gt;
&lt;p&gt;Well, you have a lot of issues in your ble service and characteristics. And I think this is where the issue come from.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;The command char has the write property enabled, and can be used to receive data from the central device.&lt;/p&gt;
&lt;p&gt;Try to use the UART, to see the application logging.&lt;/p&gt;
&lt;p&gt;Please find the project files in this &lt;a href="https://github.com/rmptxf/ble_app_temperature" rel="noopener noreferrer" target="_blank"&gt;&lt;strong&gt;github repos&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;rmptxf&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268926?ContentTypeID=1</link><pubDate>Thu, 10 Sep 2020 10:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d601ece0-d9fe-4e3e-bb1f-4d49bafb1929</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Paarth&lt;/p&gt;
&lt;p&gt;What pins are your buttons (1-4) configured to? The onboard buttons on the nRF52840 DK are connected to pins P0.11, P0.12, P0.24, and P0.25.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268421?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 07:56:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:381b38ab-dea9-48a8-96ac-8092a5a31cfb</guid><dc:creator>Paarth_Ved23</dc:creator><description>&lt;p&gt;Sure, i have added to the ble_app_template example, here is the main.c:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/84216.main.c"&gt;devzone.nordicsemi.com/.../84216.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2. our_service.c: For a custom service and characteristics:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6116.our_5F00_service.c"&gt;devzone.nordicsemi.com/.../6116.our_5F00_service.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3. our_service.h: Header for custom service and characteristics:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5633.our_5F00_service.h"&gt;devzone.nordicsemi.com/.../5633.our_5F00_service.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Paarth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268282?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 11:47:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd720fe8-8a93-4256-8085-381997a37dd0</guid><dc:creator>rmptxf</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Would you mind sending your project files here, or email them. To look into the issue ?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268278?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 11:42:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f275d18-f2ad-4488-b973-7c170fea14ac</guid><dc:creator>Paarth_Ved23</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;bsp_event_handler&amp;nbsp;&lt;/strong&gt;is handling&amp;nbsp;BSP_EVENT_SLEEP,&amp;nbsp;&amp;nbsp;BSP_EVENT_DISCONNECT and&amp;nbsp;BSP_EVENT_WHITELIST_OFF.&lt;/p&gt;
[quote userid="93005" url="~/f/nordic-q-a/65624/nrf52840-dk-implementing-board-button-event-handler-but-no-response-on-button-press/268246"]ou&amp;#39;re using the nRF logging. Is the uart logging already working ?[/quote]
&lt;p&gt;I am only using the nRF logs for debugging.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Paarth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268246?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 09:52:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f243b5e-33a4-46f9-9fcf-750478ab6994</guid><dc:creator>rmptxf</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How do you check whether a button is responding or not ? I mean, in the code snippet you provided, you&amp;#39;re using the nRF logging. Is the uart logging already working ?&lt;/p&gt;
&lt;p&gt;What bsp events the &lt;strong&gt;bsp_event_handler &lt;/strong&gt;is used for ?&amp;nbsp; for handling the buttons events too ?&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
&lt;p&gt;rmptxf&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268199?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 07:30:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3234f62-78e0-434b-ac87-442b3d1301bf</guid><dc:creator>Paarth_Ved23</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for your response, I tried to implement it using the code snippets you have provided. But still no response on button press. I have tried the following:&lt;/p&gt;
&lt;p&gt;1. Changed the button_event_handler as per the above.&lt;/p&gt;
&lt;p&gt;2. Changed the&amp;nbsp;app_button_cfg_t structure to as defined above&lt;/p&gt;
&lt;p&gt;3. Called timer_init() before buttons_init()&lt;/p&gt;
&lt;p&gt;4. BUTTON_ENABLED was already set.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, as a footnote, I am implementing this button handler along with a bsp_event_handler already defined, would it be affecting this handler or are they completely independent? Please let me know.&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Paarth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 DK, implementing Board Button event handler, but no response on button press.</title><link>https://devzone.nordicsemi.com/thread/268163?ContentTypeID=1</link><pubDate>Sun, 06 Sep 2020 23:41:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c112d53-fa17-412b-b49e-c94adc7d52c6</guid><dc:creator>rmptxf</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/paarth_5f00_ved23"&gt;Paarth_Ved23&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Here is a better way to do it!&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define UART_PRINTING_ENABLED   // comment it to disable the uart logging

static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
  ret_code_t err_code;

  switch(pin_no)
  {
   case BUTTON_1:
     if(button_action == APP_BUTTON_PUSH) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button1 pressed.&amp;quot;);
        #endif
     }
     else if(button_action == APP_BUTTON_RELEASE) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button1 released.&amp;quot;);
        #endif
     }
     break;

   case BUTTON_2:
     if(button_action == APP_BUTTON_PUSH) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button2 pressed.&amp;quot;);
        #endif
     }
     else if(button_action == APP_BUTTON_RELEASE) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button2 released.&amp;quot;);
        #endif
     }
     break;

   case BUTTON_3:
     if(button_action == APP_BUTTON_PUSH) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button3 pressed.&amp;quot;);
        #endif
     }
     else if(button_action == APP_BUTTON_RELEASE) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button3 released.&amp;quot;);
        #endif
     }
     break;

   case BUTTON_4:
     if(button_action == APP_BUTTON_PUSH) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button4 pressed.&amp;quot;);
        #endif
     }
     else if(button_action == APP_BUTTON_RELEASE) {
        #ifdef UART_PRINTING_ENABLED
        NRF_LOG_INFO(&amp;quot;button4 released.&amp;quot;);
        #endif
     }
     break;
     default:
        return; // no implementation needed
  }

}

/**@brief Function for buttons configuration.
 *
 */
static const app_button_cfg_t app_buttons[BUTTONS_NUMBER] = 
{
// BUTTONS_NUMBER,
// BUTTON_PIN,
// BUTTONS_ACTIVE_STATE,
// BUTTON_PULL,
// are all declared in your components/boards/Ppca10056.h file

    {BUTTON_1, BUTTONS_ACTIVE_STATE, BUTTON_PULL, button_event_handler},
    {BUTTON_2, BUTTONS_ACTIVE_STATE, BUTTON_PULL, button_event_handler},
    {BUTTON_3, BUTTONS_ACTIVE_STATE, BUTTON_PULL, button_event_handler},
    {BUTTON_4, BUTTONS_ACTIVE_STATE, BUTTON_PULL, button_event_handler}
}; 

/**@brief Function for initializing the buttons with the app_button library.
 *
 */
 void buttons_init(){

    ret_code_t  err_code;                        
// BUTTONS_NUMBER  is declared in your components/boards/Ppca10056.h file
    err_code = app_button_init((app_button_cfg_t *)app_buttons,
                                                BUTTONS_NUMBER,
                                         BUTTON_DETECTION_TIME);
    APP_ERROR_CHECK(err_code);

    err_code = app_button_enable();
    APP_ERROR_CHECK(err_code);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Make sure you initialize the timer before calling the &lt;em&gt;buttons_init()&lt;/em&gt; in the main.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 *@brief Function for initialising the timers. 
 * It is necessary for the buttons to work when using the app_button library. 
 */
static void timers_init(void)
{
    // Initialize timer module.
    ret_code_t err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    timers_init();
    leds_init();
    buttons_init();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also make sure to enable the app button module in the&lt;em&gt; sdk_config.h&lt;/em&gt; file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
// &amp;lt;q&amp;gt; BUTTON_ENABLED  - Enables Button module
 

#ifndef BUTTON_ENABLED
#define BUTTON_ENABLED 1
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And here is 4 key keyboard based off the &lt;strong&gt;nRF52840-DK&lt;/strong&gt;. You can test it, or just re-use the button handling part for your case.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/rmptxf/nRF52_USB_Keyboard" rel="noopener noreferrer" target="_blank"&gt;The github repos&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;rmptxf&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>