<?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>BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63784/bluetooth-connection-issue</link><description>Hi, 
 
 we developed a 2D-3D mouse .It contains a 2D sensor and a 3D sensor and 4 touchpads for left click,right click and 3D motion enabling. 
 The SDK we are using for developing our application is &amp;quot; nRF5_SDK_16.0.0_98a08e2 &amp;quot; and examples &amp;quot; ble_app_hids_mouse</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Jul 2020 12:45:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63784/bluetooth-connection-issue" /><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260019?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 12:45:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74c76181-948f-4dcf-b490-282ff3f2fc6c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Glad to hear, Nandhu.&lt;/p&gt;
&lt;p&gt;Please check this before creating a ticket the next time. It has been the solution to quite a few of your tickets so far. It would be quicker for you if you check this instead of waiting for our reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260018?ContentTypeID=1</link><pubDate>Tue, 14 Jul 2020 10:04:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cff18014-c544-4ce9-a2ad-7c86a000e9fc</guid><dc:creator>NANDHU</dc:creator><description>&lt;p&gt;Hi&amp;nbsp; Edvin,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Edvin Holmseth"]I guess you already know all the tricks, but does the log say anything? It may be an APP_ERROR_CHECK(err_code) or a hardfault.[/quote]
&lt;p&gt;&amp;nbsp;Edvin you are absolutely right .The issue is due&amp;nbsp; &amp;quot;&lt;span&gt;APP_ERROR_CHECK(err_code)&amp;quot; .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3651d96b95724bae9be355a997609984/Screenshot-2020_2D00_07_2D00_14-15.24.47.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If we call &amp;quot;&lt;strong&gt;ble_hids_inp_rep_send&lt;/strong&gt;&amp;quot; while BLE events taking place this function will return error. we removed the APP_ERROR_CHECK(err_code) from there, now every thing is working fine without&amp;nbsp; any timer delay.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks a lot for your support.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260017?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2020 13:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:996d0ad8-6092-4892-9653-30a7d78db7b4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Well, I assumed that the trace named PC_WITH_CONNECTION_ISSUE contained the issue. Apparently it did not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So from the last sniffer trace, that actually shows the issue, you can see that the peripheral (nRF) stops responsing. There is your issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I guess you already know all the tricks, but does the log say anything? It may be an APP_ERROR_CHECK(err_code) or a hardfault.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are you able to reproduce this while debugging? does the log say anything? Does the execution stop, or is the application still running?&lt;/p&gt;
&lt;p&gt;Possibly right after you receive the encryption event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260016?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2020 09:19:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:642e00b4-874a-431b-9434-17faba2a8712</guid><dc:creator>NANDHU</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
[quote user="Edvin Holmseth"]I have checked the sniffer trace. I can&amp;#39;t see any obvious reasons for why the PC disconnects.[/quote]
&lt;p&gt;&amp;nbsp;I already told you that after we changed the timer interrupt delay to 5sec connection issue was not showing . Both the traces i posted to you have this change that is why you can&amp;#39;t&amp;nbsp; see any issue but did you notice the time difference&amp;nbsp;&amp;nbsp;to complete the&amp;nbsp;&amp;nbsp;BLE softdevice events(Service discovery, MTU update, data length update, PHY update, etc) in both trace&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you want a sniffer trace with PC is disconnecting . Please refer the below trace (from number 2800).In this trace two times our device shows the connection problem.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-3651d96b95724bae9be355a997609984/CONNECTION_5F00_PROBLEM.pcapng"&gt;devzone.nordicsemi.com/.../CONNECTION_5F00_PROBLEM.pcapng&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Edvin Holmseth"]You say that the issue goes away if you delay the peripheral initialization with 5 seconds instead of 1 second, is that correct?[/quote]
&lt;p&gt;&amp;nbsp;yes.&lt;/p&gt;
[quote user="Edvin Holmseth"]what IRQ is your app_timer running?[/quote]
&lt;p&gt;&amp;nbsp;Inside the &amp;quot;&lt;strong&gt;ble_evt_handler&lt;/strong&gt;&amp;quot; . Now peripherals_enable() is used to start the timer . Please refer the below code&amp;nbsp; for better clarification.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for enabling all peripherals.
 *
 * @details This function will be called after 1s in the device connected to the host pc.
 *
 * @param[in]   p_context   Pointer used for passing some arbitrary information (context) from the
 *                          app_start_timer() call to the timeout handler.
 * void peripherals_enable_timeout_handler(void * p_event_data, uint16_t event_size)  
 **/
 
 
static void peripherals_enable_timeout_handler(void * p_context)  
{
     
     ret_code_t err_code;
     
     nrf_gpio_pin_set(BSP_LED_2);       /* Green led will off */
     
     err_code = app_spi_enable();       /* Enabling  2D movement */
     APP_ERROR_CHECK(err_code); 

     motion_3d_module_enable();         /* Enabling  3D movement */ 

     saadc_timer_enable();              /* SAADC timer will enable so the saadc conversion will start */
     
     if (nrf_gpio_pin_read(PIN_BASE_SENSE) == false)   /* Docked Event*/
     {
           DOCKED   = true;
           touchpad_disable();  /* Disable touchpad   */
     }
     else                                              /* Un_docked Event */
     {  
           DOCKED   = false;
           touchpad_enable();  /* Enable touchpad     */
     }


}




/**@brief Function for the Timer initialization.
 *
 * @details Initializes the timer module.
 */
static void peripherals_enable_timer_init(void)
{
        ret_code_t err_code;

        // Create battery timer.
        err_code = app_timer_create(&amp;amp;peripherals_enable_timer_id,
                                    APP_TIMER_MODE_SINGLE_SHOT,
                                    peripherals_enable_timeout_handler);
        APP_ERROR_CHECK(err_code);
}

/** Function for enabling the peripherals_enable timer**/
static void  peripherals_enable(void)
{
    ret_code_t err_code;
    err_code = app_timer_start(peripherals_enable_timer_id, PERIPHERALS_ENABLE_DELAY_INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);   
 
}




/** Function for disabling the peripherals_enable timer **/
static void  peripherals_enable_stop(void)
{
    uint32_t err_code;  
    err_code = app_timer_stop(peripherals_enable_timer_id);
    APP_ERROR_CHECK(err_code); 
 
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Edvin Holmseth"] What is&amp;nbsp;APP_TIMER_CONFIG_IRQ_PRIORITY in your sdk_config.h?[/quote]
&lt;p&gt;&amp;nbsp;APP_TIMER_CONFIG_IRQ_PRIORITY = 6&lt;/p&gt;
[quote user="Edvin Holmseth"]Just for testing, can you try something like this:[/quote]
&lt;p&gt;&amp;nbsp; We did the test but same issue was showing . The connection was not establishing with PC.&lt;/p&gt;
[quote user="Edvin Holmseth"]So does any of the peripherals you initialize use the priority below 5?[/quote]
&lt;p&gt;&amp;nbsp;No. The peripherals are only using gpio and timer interrupts and both of its priority level is 6.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260015?ContentTypeID=1</link><pubDate>Mon, 13 Jul 2020 07:46:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42a40c2c-c02c-4a7b-9f96-b45c6366ab3c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I am fine thank you &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I have checked the sniffer trace. I can&amp;#39;t see any obvious reasons for why the PC disconnects. Since the PC sends the LL_TERMINATE_IND packet, the connection is not timing out. It should have said that there was a timeout reason if there was something that wasn&amp;#39;t replied to, but since it says &amp;quot;Remote User Terminated Connection&amp;quot;, that suggests that there is no timeout. However, I checked the usual suspects (5 seconds and 30 seconds before the timeout), and there is nothing that isn&amp;#39;t replied to, as far as I can tell.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You say that the issue goes away if you delay the peripheral initialization with 5 seconds instead of 1 second, is that correct?&lt;/p&gt;
&lt;p&gt;If you are using an app_timer to trigger this, what IRQ is your app_timer running? What is&amp;nbsp;APP_TIMER_CONFIG_IRQ_PRIORITY in your sdk_config.h?&lt;/p&gt;
&lt;p&gt;Just for testing, can you try something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;volatile bool m_init_periph = false;


...


static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    switch()
        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO(&amp;quot;connected&amp;quot;);
            //peripherals_enable();
            m_init_periph = true;
            ...
            break;
        ...
        
        
}


int main(void)
{
    ...
    
    for(;;)
    {
        if(m_init_periph)
        {
            m_init_periph = false;
            peripherals_enable();
        }
        idle_state_handle();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This will move the peripheral initialization to the main context, allowing all other incoming events to interrupt this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What IRQ are your peripherals running? Is it possible that any of these can delay the softdevice? In S132 interrupt priorities 5, 6 and 7 should be fine to use. 4 is reserved for the softdevice, while 2 and 3 can be used for time critical peripherals, but you should not spend too much time in these interrupts. anything below 1 is off limits.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So does any of the peripherals you initialize use the priority below 5?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260014?ContentTypeID=1</link><pubDate>Sat, 11 Jul 2020 07:36:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee023c9-3fc0-425c-9046-fb057b6cdfc1</guid><dc:creator>NANDHU</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I am doing well what about you?. Thanks for the quick reply .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLUETOOTH CONNECTION ISSUE</title><link>https://devzone.nordicsemi.com/thread/260013?ContentTypeID=1</link><pubDate>Fri, 10 Jul 2020 16:29:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77eb7d22-8417-4a34-ae04-e32b10aed140</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Nandhu,&lt;/p&gt;
&lt;p&gt;Hope you are doing fine.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We are very low on capacity due to low staffing because of summer holidays in Norway. I will try to look into this as soon as I can, hopefully in the beginning of next week.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>