<?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>ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection</link><description>Hi All, 
 I&amp;#39;m using nrf Connect SDK v1.7.0 with Vs Code 
 So here I can see in the debug prints that Bluetooth device is able to get connection successfull callback and Immediately I get disconnection callback with this error reason. 
 
 BT_HCI_ERR_CONN_FAIL_TO_ESTAB</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 Feb 2024 08:48:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection" /><item><title>RE: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/470395?ContentTypeID=1</link><pubDate>Fri, 23 Feb 2024 08:48:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:506a2e22-88ac-42e9-9666-dd5d5f12a9c9</guid><dc:creator>muli</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/viswa"&gt;viswa&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you solve this in the end?&lt;/p&gt;
&lt;p&gt;I am struggling with a similar issue. My central can&amp;#39;t re-connect to my peripheral with the same error. I have reported it here : &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/108565/bt_hci_err_conn_fail_to_estab-every-time-on-re-connection"&gt;BT_HCI_ERR_CONN_FAIL_TO_ESTAB every time on re-connection&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Would you have any ideas? Thanks.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/367089?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 08:30:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:916c7a21-2df5-4889-a886-e2418aaef138</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hmm, okay. What environment are you testing your application in? Are the devices located right next to each other? You can try increasing the TX power (&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/samples/bluetooth/hci_pwr_ctrl/README.html"&gt;example here&lt;/a&gt;) on your peripheral devices.&lt;/p&gt;
&lt;p&gt;Can you share some more details on what samples exactly the central/peripherals are based on?&lt;/p&gt;
&lt;p&gt;A&lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt; sniffer trace&lt;/a&gt; of the connection might give us a better idea of what the problem (on air) is.&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: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366956?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 13:12:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa37be82-450b-4941-903f-ad962bd2b754</guid><dc:creator>viswa</dc:creator><description>&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
[quote userid="75734" url="~/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection/366948#366948"]What sample project is your central application based on?[/quote]I&amp;#39;ve picked an example from Nordic webinar from YouTube, PFA&lt;/div&gt;
&lt;div&gt;[quote userid="75734" url="~/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection/366948#366948"]an you show us how you clear the BT conn variables upon a disconnect?&amp;nbsp;[/quote]
&lt;p&gt;Below function is called inside disconnect callback.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ClearBleConn(void)
{
&amp;#160; if(default_conn)
&amp;#160; &amp;#160; &amp;#160; { /* Connection instance for central role */
&amp;#160; &amp;#160; &amp;#160; &amp;#160; bt_conn_unref(default_conn);
&amp;#160; &amp;#160; &amp;#160; &amp;#160; default_conn = NULL;
&amp;#160; &amp;#160; &amp;#160; }
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="75734" url="~/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection/366948#366948"]I assume the CONFIG_BT_MAX_CONN is set to some value by default in your application either way? [/quote]
&lt;p&gt;It was two by default and I made it 5 now, still the problem persists.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Viswa N M&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366948?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 12:57:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b12458b-990c-4e56-99fe-e531fc182a00</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I assume the CONFIG_BT_MAX_CONN is set to some value by default in your application either way? Can you show us how you clear the BT conn variables upon a disconnect?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It should not be necessary to stop advertising in order to connect, as a scanning central device will establish a connection with advertising devices.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What sample project is your central application based on? It might be that the connection establishment isn&amp;#39;t handled correcty, and it for some reason tries to connect to both advertising devices at the same time at some points.&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: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366830?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 05:48:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e6b7941-53ef-486b-80bc-357ad8a0f400</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Sorry for late reply.&lt;/p&gt;
[quote userid="75734" url="~/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection/366586#366586"]What is your &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.99-dev1/kconfig/CONFIG_BT_MAX_CONN.html#cmdoption-arg-CONFIG_BT_MAX_CONN"&gt;CONFIG_BT_MAX_CONN &lt;/a&gt;set to in the central application for example?[/quote]
&lt;p&gt;I have not used that setting in our application and I clear bt_conn variables used for connection after every disconnection.&lt;/p&gt;
[quote userid="75734" url="~/f/nordic-q-a/87577/ble-disconnects-immediately-after-connection/366586#366586"]Do these fail to establish errors occur even when trying to connect to the first peripheral as well, or only when trying to connect to peripheral number X?[/quote]
&lt;p&gt;Our application acts a central, with two peripheral sensors all placed together currently and in field they are placed meters apart.&lt;/p&gt;
&lt;p&gt;As I said these are very near to the central device and disconnection occurs randomly not particularly with one peripheral device.&lt;/p&gt;
&lt;p&gt;Do I need to stop peripheral advertising before I go for a central connection?&lt;/p&gt;
&lt;p&gt;I use internal software timer to count milliseconds in our code does it has a toll on performance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366586?ContentTypeID=1</link><pubDate>Fri, 06 May 2022 05:55:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f9959e1-87d4-4f16-bcb8-b500480d23ed</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What kinds of devices are the central device and the peripherals in this use case? Do these fail to establish errors occur even when trying to connect to the first peripheral as well, or only when trying to connect to peripheral number X? It could be that the maximum number of connected devices has been reached by the central device. What is your &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.99-dev1/kconfig/CONFIG_BT_MAX_CONN.html#cmdoption-arg-CONFIG_BT_MAX_CONN"&gt;CONFIG_BT_MAX_CONN &lt;/a&gt;set to in the central application for example?&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: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366461?ContentTypeID=1</link><pubDate>Thu, 05 May 2022 12:25:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c09de68e-a759-414a-acf5-5bde92641597</guid><dc:creator>viswa</dc:creator><description>&lt;p&gt;We&amp;#39;re trying to connect these mutliple peripheral devices one at a time, which comes out of sleep every 3 minutes and advertises. On receiving matching bluetooth Address I&amp;#39;m going for connect request. using following Api.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  param2.interval_max = 30;
  param2.interval_min = 7;
  param2.latency = 0;
  param2.timeout = 400;

 
  err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN,
      &amp;amp;param2,  conn);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not whitelisting or anything as such deliberately&lt;/p&gt;
&lt;p&gt;Please ask me if you need any specific details.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards&lt;/p&gt;
&lt;p&gt;Viswa&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble disconnects Immediately after connection.</title><link>https://devzone.nordicsemi.com/thread/366436?ContentTypeID=1</link><pubDate>Thu, 05 May 2022 11:34:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d48b9546-cd6a-4299-8c1c-45fc0bed5ca0</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BT_HCI_ERR_CONN_FAIL_TO_ESTABLISH will happen from time to time. This means that the peripheral didn&amp;#39;t respond to the connect request correctly (only one request is sent per connect attempt). It&amp;#39;s normal for this error to happen from time to time, but it can for example happen if there is lots of noise or interference from nearby sources. It could also be due to a whitelisting issue, that&amp;nbsp;either side of the connection simply doesn&amp;#39;t allow connections to the device&amp;nbsp;it&amp;#39;s trying to connect with. Hard to say without a bit more information on what you&amp;#39;re doing.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>