<?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>Unexpected disconnect after BluetoothGatt.discoverServices() (Android)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7459/unexpected-disconnect-after-bluetoothgatt-discoverservices-android</link><description>Hello, 
 Setup: Android 4.4.2 (LG G2), nRF51822 peripherial. 
 I noticed that once in a while when trying to connect to my nRF51 based device it won&amp;#39;t connect and what is worse the device gets removed from the list of bonded devices on the android phone</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Jun 2015 09:01:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7459/unexpected-disconnect-after-bluetoothgatt-discoverservices-android" /><item><title>RE: Unexpected disconnect after BluetoothGatt.discoverServices() (Android)</title><link>https://devzone.nordicsemi.com/thread/26572?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2015 09:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64026a10-54dd-4839-8048-8b085493a4b0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@michael: What we did in Master Control Panel is just to be sure gatt is closed when we start a connection. We don&amp;#39;t do re-connection with MCP but try to have fresh gatt every time we do connection.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure why it made your app more stable, because there is nothing wrong to close the gatt when you have disconnection and subscribe a new one when you do connect.&lt;/p&gt;
&lt;p&gt;The refresh() function is an internal Android Bluetooth function. We use that to clear the cached ATT table stored on Android device. So that Android will do a service discovery every time we connect to the device.&lt;/p&gt;
&lt;p&gt;You can have a look &lt;a href="http://stackoverflow.com/questions/22596951/how-to-programmatically-force-bluetooth-low-energy-service-discovery-on-android"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected disconnect after BluetoothGatt.discoverServices() (Android)</title><link>https://devzone.nordicsemi.com/thread/26571?ContentTypeID=1</link><pubDate>Wed, 10 Jun 2015 08:04:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5636c739-6a59-4915-b3d5-5d393784dac9</guid><dc:creator>michael</dc:creator><description>&lt;p&gt;@Hung Bui: While inspecting the logcat I noticed that upon disconnect you are calling gatt.refresh(). This is not a public method, could you elaborate how (reflection?) and why are doing this?&lt;/p&gt;
&lt;p&gt;06-10 09:19:19.365    2519-6053/? D/BtGatt.GattService? onDisconnected() - clientIf=5, connId=5, address=EE:08:DB:5E:BE:9B
06-10 09:19:19.365  29761-29772/? D/BluetoothGatt? onClientConnectionState() - status=0 clientIf=5 device=EE:08:DB:5E:BE:9B
06-10 09:19:19.405  29761-29772/? D/BluetoothGatt? refresh() - device: EE:08:DB:5E:BE:9B
06-10 09:19:19.405    2519-6053/? D/BtGatt.GattService? refreshDevice() - address=EE:08:DB:5E:BE:9B&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected disconnect after BluetoothGatt.discoverServices() (Android)</title><link>https://devzone.nordicsemi.com/thread/26570?ContentTypeID=1</link><pubDate>Wed, 10 Jun 2015 08:01:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d356ce4-e6c7-45bc-a1bc-e82c167d6727</guid><dc:creator>michael</dc:creator><description>&lt;p&gt;@Hung Bui: Thank you for looking into this! In fact, I think you are right, the problem seems to be on the Android side. In the mean time we did the same tests using iOS without seeing these problems. I noticed that your Master Control Panel is not showing this problem, also. I then tried to figure out what you are doing different on the Master Control Panel by looking at the Android logcat and the major difference is that you seem to call gatt.close() right before a connect, while I was calling close() right after I received the onConnectionSateChanged (disconnect) event. So I changed my code to the way you are doing this and everything is working much more stable now! I don&amp;#39;t know why, but it made major difference.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected disconnect after BluetoothGatt.discoverServices() (Android)</title><link>https://devzone.nordicsemi.com/thread/26569?ContentTypeID=1</link><pubDate>Tue, 09 Jun 2015 09:11:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f53610fa-aec5-44f5-a556-e68f226f468b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@michael : I&amp;#39;m suspecting the issue is from Android side.
We used to have some similar issue but it was with earlier Android versions, on Android v4.3 and 4.4.0&lt;/p&gt;
&lt;p&gt;What happens if you don&amp;#39;t bond to the device  ?&lt;/p&gt;
&lt;p&gt;Could you try to test with our nRFMaster Control Panel ?&lt;/p&gt;
&lt;p&gt;Have you tried with another phone ?&lt;/p&gt;
&lt;p&gt;Could you uploade a full snifer trace so I can have a look ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>