<?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>Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38228/error-22-0x16-gatt_conn-terminate-local-host-issue</link><description>Platform NRF52832 SoftDevice S132 V6.1 SDK 15.0 FreeRTOS implemented 
 Hi, In our application, once the mobile app is connected to the peripheral, it makes continuous writes to a characteristic every 1 second and then forwards the message to a different</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 20 Oct 2019 20:36:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38228/error-22-0x16-gatt_conn-terminate-local-host-issue" /><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/215805?ContentTypeID=1</link><pubDate>Sun, 20 Oct 2019 20:36:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d1918de-e34d-4e25-ab3d-611c81347432</guid><dc:creator>dennyi</dc:creator><description>&lt;p&gt;Hello, I experienced a similar issue, my bluetooth connection kept getting disconnected with error 22 after a somewhat random time intervals (mostly 30-90 seconds).&lt;/p&gt;
&lt;p&gt;First time this happened I tried forgetting the device in android settings, removing the bonding information.. That didnt help, then I played around with the connection parameters and thought that solved the issue.&lt;/p&gt;
&lt;p&gt;The problem reappeared some days later, even through I didnt change any of the settings. This time nothing seemed to help, until I erased bluetooth cache in the bluetooth system app in the App info settings (oneplus 6T,&amp;nbsp; Android 9, OxygenOS 9.0.17), which solved the issue completely and the connection is now stable again.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure whether the problem OP has is the same, but since I was looking for solution to this multiple times and didnt find anything, thought I&amp;#39;d share so ppl who have the same issue can try this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/148471?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 15:40:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4329beb-b3f5-417d-bd5d-94c90afb35f1</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;That is interesting news. Please let me know how it goes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/148430?ContentTypeID=1</link><pubDate>Wed, 12 Sep 2018 13:28:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80fac863-2c6c-40a7-88ab-9d41d0cec627</guid><dc:creator>Siddhesh</dc:creator><description>&lt;p&gt;Quick update on the issue&lt;br /&gt;I changed the connection intervals to Min: 100ms Max 300ms Supervisory timeout: 5000ms&lt;br /&gt;On Oneplus 3, the connection was stable for around 8 hours overnight. It was still active when I woke up and manually closing the app caused a clean disconnect (Reason 0x13).&lt;br /&gt;I will run some more tests with Samsung phones and upload sniffer logs if there are any issues.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/148243?ContentTypeID=1</link><pubDate>Tue, 11 Sep 2018 14:48:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c38189c-185e-4463-bfeb-c483d02f100f</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;It seems like two weird things happen around frame 3355:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In frame 3356 the slave responds to an empty PDU, but the master doesn&amp;#39;t acknowledge. This is indicated by the wrong Sequence Number in frame 3357. There seems to be a fair amount of packet loss in your trace so this could be coincidental.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The slave stops responding&amp;nbsp;to the master&amp;#39;s PDUs after frame 3356. There are many reasons this could happen. Maybe the code asserted, a BLE event isn&amp;#39;t handled properly, the device is out of range, etc.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-552f57a64c5f4fc59be38dda572e6ad3/pastedimage1536675501680v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;After 5 seconds the supervision timout is out and the Sniffer starts listening on the advertising channels again. At the end your link seems to use ~1 s connection intervals. With a supervision timout of 5 seconds this allows for 4 dropped packets before the link times out. It should be enough i most cases, but it could be interesting to see what happens if you increase the supervision timout or reduce the connection parameters a little.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;strong&gt;Should I put a breakpoint on every SD API call&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;No. Most SD functions, as well as most of the functions in the libraries and drivers in the SDK, return an error code. You should check &lt;em&gt;all&lt;/em&gt; error codes and handle them properly. In the SDK the codes are usually checked with&amp;nbsp;the macro APP_ERROR_CHECK(err_code). For example:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = sd_ble_gap_disconnect(...);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are you doing this? If you do that and debug like shown in my previous link, you will end up in an error handler if something&amp;nbsp;unexpected happen.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;strong&gt;[...]OnePlus device where the phone stops sending data when the screen is off&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;This sounds related to the implementation of the App. Do you lose connections with the OnePlus as well?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you upload a couple of more sniffer logs? It could be interesting to compare.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/148019?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 12:35:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f64fcd3-cc23-4f33-87e4-57459fece44c</guid><dc:creator>Siddhesh</dc:creator><description>&lt;p&gt;1. Highlights of the sniffer log. The peripheral advertises and scans at the same time. The scan is for a different device not active while testing. Connection established at 15.809 Connection lost without a proper disconnect at 406.29&lt;/p&gt;
&lt;p&gt;2. I put a break point in the app_error handler. Should I put a breakpoint on every SD API call ?&lt;/p&gt;
&lt;p&gt;3. Currently we are testing using Samsung Galaxy S8 running Android Oreo. I found a slightly different background behavior with a OnePlus device where the phone stops sending data when the screen is off and then resumes sending on waking up.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7002.test2.pcapng"&gt;devzone.nordicsemi.com/.../7002.test2.pcapng&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT: I also came across this blog. Could this be an issue ?&lt;br /&gt;&lt;a href="https://blog.classycode.com/a-short-story-about-android-ble-connection-timeouts-and-gatt-internal-errors-fa89e3f6a456"&gt;blog.classycode.com/a-short-story-about-android-ble-connection-timeouts-and-gatt-internal-errors-fa89e3f6a456&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/147980?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 10:13:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec75c6eb-c7d2-49cc-a4e6-993e52485543</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Can you upload your sniffer logs?&lt;/p&gt;
&lt;p&gt;Are you checking the return codes of &lt;em&gt;all&lt;/em&gt; your Softdevice API calls?&lt;/p&gt;
&lt;p&gt;What kind of mobile phone do you use as a central and what OS does it run? Have you tried other devices?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/147857?ContentTypeID=1</link><pubDate>Fri, 07 Sep 2018 18:25:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94fd8ec5-46a0-4711-b5b1-57becf75479f</guid><dc:creator>Siddhesh</dc:creator><description>&lt;p&gt;After using both your suggestions, the sniffer concluded there was nothing wrong on the BLE end.&lt;br /&gt;After debugging the code was stuck without any error. After I paused the debugger, the control was stuck in&amp;nbsp;vPortSuppressTicksAndSleep function in port_cmsis_systick.c. Specifically the lines 254-255.&lt;/p&gt;
&lt;p&gt;I enabled the part for softdevice ignoring the internal ticket&amp;nbsp;NRFFOSDK-11174, and the board was connected for around 2 hours but got the same error 22&lt;/p&gt;
&lt;p&gt;I disabled tickless idle in FreeRTOSConfig.h and the board was connected for around 2 hours and 40 mins after which I saw GATT_CONN_TIMEOUT error 0x08 on the phone side, but no disconnect on the board side.&lt;/p&gt;
&lt;p&gt;Any thoughts on this ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST ISSUE</title><link>https://devzone.nordicsemi.com/thread/147603?ContentTypeID=1</link><pubDate>Thu, 06 Sep 2018 13:40:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fcceb95-a168-4f3e-bb6a-3568d836083f</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You say that &amp;quot;&lt;span&gt;we do not see any disconnect event and the board becomes unresponsive&amp;nbsp;&amp;quot; does this mean that the device continue to work perfectly normal, except for the BLE stuff? It sounds like your code has asserted and just ended up in an endless while loop in an assert handler somewhere. Have you &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;debugged&amp;nbsp;your code&lt;/a&gt;? Do you get any debug log information out of your nRF52 device?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;It could be useful with a sniffer trace so that we can check what packets are transmitted last. If you have an extra Nordic dev kit to spare you can use our&amp;nbsp;&lt;a title="nRF Tools" href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.tools/dita/tools/sniffer/sniffer_intro.html?resultof=%22%6e%72%66%22%20%22%73%6e%69%66%66%65%72%22%20"&gt;RF Bluetooth Sniffer&lt;/a&gt;&amp;nbsp;solution.&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>