<?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>HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29001/hid-over-gatt-on-android-disconnects-after-30-seconds</link><description>I am using nrf51822 with PCA 10001, SoftDevice S110 6.0 and SDK 5.2. I modified the HID example to send media keys, basically I just changed the report map and added a few functions for sending media keys. This all works great on iOS 7, I am able to connect</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 13 Jan 2018 13:28:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29001/hid-over-gatt-on-android-disconnects-after-30-seconds" /><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114684?ContentTypeID=1</link><pubDate>Sat, 13 Jan 2018 13:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b89e06-683a-4e89-8e40-0f7baba1df7a</guid><dc:creator>Sansei</dc:creator><description>&lt;p&gt;Did you solve it finally or not? I have the same problem with Nordic_Ble_Preipheral_HID_KeyBoard (or mouse) where the connection got lost in a few moment periodically.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114691?ContentTypeID=1</link><pubDate>Mon, 06 Oct 2014 03:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88d92e75-dfc8-4242-9d52-cc98ce888962</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;I&amp;#39;m having this problem too with the SoftDevice 7...&lt;/p&gt;
&lt;p&gt;#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER) /&lt;strong&gt;&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (15 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)  /&lt;/strong&gt;&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first (5 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                           /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */&lt;/p&gt;
&lt;p&gt;Ignore the comments, but I connect to the device on iOS 8, and after 35 seconds it just gets disconnected..&lt;/p&gt;
&lt;p&gt;Which is 20 + (3 * 5) seconds.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cp_init.p_conn_params                  = NULL;
cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
cp_init.disconnect_on_fail             = false;
cp_init.evt_handler                    = on_conn_params_evt;
cp_init.error_handler                  = conn_params_error_handler;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any ideas?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114690?ContentTypeID=1</link><pubDate>Mon, 25 Aug 2014 17:41:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dbb943e-0b7d-44e4-9b2a-4785f5f92681</guid><dc:creator>Andrew Kohlsmith</dc:creator><description>&lt;p&gt;I see what the problem is, at least in my scenario which I don&amp;#39;t know is the same.&lt;/p&gt;
&lt;p&gt;With my application, if I set the MAX_CONN_INTERVAL down to 25ms, I get the timeouts. If I leave it up at 40ms, I do not. It looks like the soft device is ignoring my &amp;quot;do not disconnect on failure to negotiate the connection parameters&amp;quot; setting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114689?ContentTypeID=1</link><pubDate>Mon, 25 Aug 2014 16:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8c67c2b-8746-4b33-a8be-e38896019784</guid><dc:creator>Andrew Kohlsmith</dc:creator><description>&lt;p&gt;I am getting the same thing on iOS (8.0b5 on iPhone 5S as well as 7.1.1 on iPad3). My application is based on the Nordic ble_lbs demo code which sets up the connection as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cp_init.p_conn_params                  = NULL;
cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
cp_init.disconnect_on_fail             = false;
cp_init.evt_handler                    = on_conn_params_evt;
cp_init.error_handler                  = conn_params_error_handler;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;FIRST_CONN_PARAMS_UPDATE_DELAY is 1s, NEXT_CONN_PARAMS_UPDATE_DELAY is 5s, and MAX_CONN_PARAMS_UPDATE_COUNT is 3. My disconnects occur almost exactly 15s (5s delay, 3 attempts) after connecting.&lt;/p&gt;
&lt;p&gt;Like the original poster, the soft device does NOT resume advertising.&lt;/p&gt;
&lt;p&gt;This doesn&amp;#39;t appear to be an Android thing, but perhaps a soft device thing. I&amp;#39;m running s110 v6.0.0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114688?ContentTypeID=1</link><pubDate>Tue, 24 Jun 2014 11:25:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa2f15ea-0d3b-4a40-993a-4805f7a21613</guid><dc:creator>eric ely</dc:creator><description>&lt;p&gt;Thanks for the response. Yes, I already had it set to false, and I don&amp;#39;t think it is directly related to the connection parameter update.&lt;/p&gt;
&lt;p&gt;I am keeping the interval between connection parameter updates extremely high. If I do that, and I have Wifi turned off in the Android phone, it will stay connected for a very long time. However, if I wait a few minutes press a button and send a HID key, there is about a 50% chance it will disconnect. Also, if I turn on Wifi in the Android handset, it will likely disconnect without any other action. So disconnects are happening outside of just connection parameter updates.&lt;/p&gt;
&lt;p&gt;I have tried the RFDuino, which is using nrf51822 and a custom service on GATT as far as I can tell, with this exact phone. It will stay connected forever even with Wifi on. So there must be a way to keep the connection up. Is there an Android specific example provided by Nordic?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114687?ContentTypeID=1</link><pubDate>Tue, 24 Jun 2014 10:22:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a8a5a11-c15c-4200-a97c-8fe9476b3895</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You could try to set the disconnect_on_fail menber of ble_conn_params_init_t to false, and see if that helps. Then the application should not disconnect even if it is not satisfied with the connection parameters from the master.&lt;/p&gt;
&lt;p&gt;BR,
Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114686?ContentTypeID=1</link><pubDate>Mon, 23 Jun 2014 22:32:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc50c156-ecb8-46e0-ad67-6faed6f7e461</guid><dc:creator>eric ely</dc:creator><description>&lt;p&gt;&lt;strong&gt;UPDATE TO THE UPDATE&lt;/strong&gt;: I found a way to sniff HCI packets from the Android side. By looking at the trace, as far as I can see, the Disconnect event is coming from the nrf51822. I see nothing in the logs, and then there is one packet:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HCI Packet Type: 0x04 (HCI Event)&lt;/li&gt;
&lt;li&gt;Event Code: (0x05) Disconnect Complete&lt;/li&gt;
&lt;li&gt;Parameter Total Length: 4&lt;/li&gt;
&lt;li&gt;Status: 0x00 Success&lt;/li&gt;
&lt;li&gt;Connection Handle: 0x0002&lt;/li&gt;
&lt;li&gt;Reason: 0x08 Connection Timeout&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the nrf51822 is initiating the disconnect it seems. How can I catch this from the nrf51822 side before it sends that packet? I have the normal event handlers set up for ble events with breakpoints, but it doesn&amp;#39;t get caught there. Where can I catch the reason the chip is sending that packet?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I set the &lt;em&gt;next_conn_params_update_delay&lt;/em&gt; parameter in the &lt;em&gt;ble_conn_params_init_t&lt;/em&gt; structure to a ridiculously high value. Once I do that, I can basically keep the Anrdoid phone connected nearly indefinitely. However, it doesn&amp;#39;t solve the problem entirely. If I wait a long period of time (10 minutes or so) and then I send a media key, it does go through (the action registers on the phone), but then sometimes it will disconnect right after and sometimes it will stay connected. So it seems that there is still some kind of issue when packets go back and forth, the connection parameter update may have just been exacerbating the problem because packets were going back and forth every 30 seconds when the slave requested new parameters. By turning that off, I am using less packets and hence less chance of a disconnect.&lt;/p&gt;
&lt;p&gt;I am trying to investigate. Anyone from Nordic have any thoughts in this issue?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Original:&lt;/strong&gt;
I played around with this a bit more. If I turn the Wifi off on the Android phone, it will stay connected a lot longer. I read in a few places that Android had an issue at one point that it would reject incoming connection parameter update requests if Wifi is on. However, it was supposed to be resolved in Android 4.4.&lt;/p&gt;
&lt;p&gt;So turning Wifi off does help, but it doesn&amp;#39;t entirely solve the problem because it will still disconnect after some time, but it&amp;#39;s more like 5 minutes. At this point, I am starting to think that this has something to do with the Android phone missing connection events or not handling connect parameter updates properly. I am playing around with the NEXT_CONN_PARAMS_UPDATE_DELAY parameter to see if it helps. Is there a way (or is it a good idea) to never update the connection parameters once connected?&lt;/p&gt;
&lt;p&gt;The thing is, I have used other BLE modules with this chip (like the RFDuino) and they maintain the connection indefinitely. So even if it is an issue with Android, there must be a way to work around it from the nrf51822.&lt;/p&gt;
&lt;p&gt;The other annoying part is, when the phone disconnects, the nrf51822 isn&amp;#39;t going back to advertise state. In some way, it is still connected to the Android phone. I have to unpair the two, turn off Bluetooth in Android and then re-scan and reconnect. So it takes a while just to debug/test.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114685?ContentTypeID=1</link><pubDate>Mon, 23 Jun 2014 21:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f57601ac-9781-4e02-9c73-463919196f85</guid><dc:creator>davman</dc:creator><description>&lt;p&gt;Got the same issue, but with BlueZ on Linux (so same)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HID over GATT on Android disconnects after 30 seconds</title><link>https://devzone.nordicsemi.com/thread/114683?ContentTypeID=1</link><pubDate>Mon, 23 Jun 2014 18:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f76a6387-ee97-44d2-9c73-574d24a43df0</guid><dc:creator>eric ely</dc:creator><description>&lt;p&gt;Anyone have insight here? I have tried setting the connection parameters to various things based on a different post, but that didn&amp;#39;t help. I am quite stuck here and cannot proceed. iOS still works fine. Android will always disconnect after some period of time, even though it works properly while connected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>