<?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>Using Android BLE library, getting into a connecting -&amp;gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48796/using-android-ble-library-getting-into-a-connecting---disconnecting-timeout-situation-nrf-app-seems-to-help</link><description>Hi, 
 
 We&amp;#39;re using the Android BLE library from Nordic. It really helped us handle a lot of the things we didn&amp;#39;t want to think about handling on the bluetooth stack. (Thank you) 
 
 We&amp;#39;ve been experiencing some weird issues where the sensors will get</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Jul 2019 21:19:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48796/using-android-ble-library-getting-into-a-connecting---disconnecting-timeout-situation-nrf-app-seems-to-help" /><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/196082?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 21:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ea4eed8-73ad-4b6e-bbf8-1587654805c7</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;I&amp;#39;m able to use nRF toolbox UART profile and it behaved just like how nRF connect. And I found the fix to my issue because toolbox is open-source &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;&lt;/p&gt;
&lt;p&gt;I was using the compact scanner library from Nordic as well. The difference for me was that I had :&lt;pre class="ui-code" data-mode="text"&gt;.setUseHardwareBatchingIfSupported(true)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So after I set it to false (as is what toolbox seems to do as well) it fixed my issue. I wonder why this would cause this timeout issue. Can you help me understand it? The device I was testing on is a Nexus 5X.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But all in all, I&amp;#39;m happy it solved my issue. Thank you guys!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/194956?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 18:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e85f033c-7040-4657-80b1-8f93d117710d</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;Thanks. I&amp;#39;ll&amp;nbsp;test&amp;nbsp;using&amp;nbsp;nRF toolbox UART profile as well. But that&amp;#39;s not necessarily a long-term solution. It&amp;#39;s a bit weird that a third party would help alleviate issues in the app I&amp;#39;m building &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;. My goal is to figure out what&amp;#39;s those third party app are doing. If UART profile worked, I&amp;#39;ll try to dissect the code to find out what the difference is.&lt;/p&gt;
&lt;p&gt;In terms of timeouts, the timeout is firing on 10 seconds (see logs above). The library has been working for me with multiple bluetooth connections since I started using it a few months ago.&lt;/p&gt;
&lt;p&gt;The only significant changes I&amp;#39;ve made recently when we started noticing the timeout issues is when we added the Compat Scanner library (&lt;a href="https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library"&gt;https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library&lt;/a&gt;) and some performance improvements between scanning and connection attempts.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the mean time, I&amp;#39;m going to try to revert the changes I made with compat library (effectively removing it) to see if that might have introduced the issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/194758?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 07:00:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2de1954-5133-4f96-a4cc-fa9c3335523d</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;nRF Connect doesn&amp;#39;t do any magic. I guess it just scanned for the devices, and for some reason it helps. To be sure you may check other scanner app, for example nRF Toolbox -&amp;gt; UART profile (which scans without a filter), scan for few seconds and check your app. I have no idea why that would be helpful.&lt;/p&gt;
&lt;p&gt;Coming back to the timeouts, I didn&amp;#39;t try the library with multiple devices connecting at the same time. I don&amp;#39;t think they could impact one another on library level, as managers are separate, but perhaps Android has an issue, where allows only single connection at a time? But if the timeout in a library gets called, that indicates an issue in BLE Library. Could you debug why the timeout is being fired before 10 seconds?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/194474?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 23:25:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43654472-3d05-4da7-9058-545158270855</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;Thanks. The timeout is 10 seconds. It is indeed coming from the timeout, as I&amp;#39;ve mentioned in my previous messages. What is very puzzling to me is that by launching the nRF connect app all of these issues will start to flow perfectly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Scenario : I have a few peripherals (all running the same firmware) advertising. Nordic&amp;#39;s compact scanner found it on my app. Then we try to connect to the peripherals. They all get stuck in a timeout loop (times out -&amp;gt; next time I find out it&amp;#39;s not connected - I try again in the app). I was using the nRF connect app to see if the peripherals were having advertising or other issues. I would launch the nRF connect app and they will all start connecting successfully. If someone could tell me what other things I maybe missing that nRF connect is doing i&amp;#39;d be very grateful. (Note that I didn&amp;#39;t try to manually connect using nRF app).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/194396?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 13:18:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba7c277c-b6a6-4a2a-83c2-2aa163dcd59d</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As you are getting &amp;quot;Cancelling connection...&amp;quot; in the log, that means it may be a library issue. It is printed in &amp;quot;internalDisconnect()&amp;quot; method which may be called in 3 cases:&lt;/p&gt;
&lt;p&gt;1. If your device does not support required services,&lt;/p&gt;
&lt;p&gt;2. If there was an error during connection,&lt;/p&gt;
&lt;p&gt;3. If a connection timeout occurred.&lt;/p&gt;
&lt;p&gt;I think, it 1. and 2. you would get something more in the log, which would indicate that you are setting a very short timeout for connection request, possibly in seconds instead of milliseconds.&lt;/p&gt;
&lt;p&gt;Could you put a breakpoint in &amp;quot;internalDisconnect()&amp;quot; method, where it does print this message, and check the stack trace to verify from where you end up there?&lt;/p&gt;
&lt;p&gt;Also, check if you are not setting too small timeout in &amp;quot;enqueue&amp;quot; method.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/194194?ContentTypeID=1</link><pubDate>Sun, 23 Jun 2019 18:33:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1ec54bd-aa53-4a7e-b9d7-6b4ce4cb6108</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;This issue still happens even when I override `shouldClearCacheWhenDisconnected()` to return true.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As I&amp;#39;ve mentioned before, it seems like I we just launch nRF connect (Android) app in the same android device - this timeout issue will go away. The important distinction is that we are not doing anything on the nRF app, we just launch it (no connect/disconnects).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any thoughts as to why? If nRF connect code was open source, I would look at what it does and test those out but seems like it&amp;#39;s not. &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;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/193948?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2019 17:18:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1640cf3b-8bbe-451a-8937-bfdcc1247adf</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;Thank you. I will test `shouldClearCacheWhenDisconnected()` and report back my findings.&lt;/p&gt;
&lt;p&gt;We are not using bonding or pairing. (We cannot recover from error state: see logs below)&lt;/p&gt;
&lt;p&gt;The one way we&amp;#39;ve found works by launching nRF connect app; from my observation we don&amp;#39;t even need to hit &amp;quot;connect&amp;quot; on the nRF app. If our app is trying to connect to the device stuck in the follow log and we launch the nRF connect app to scan for devices - it will successfully connect to it. Could it be something with the way we&amp;#39;re scanning? (We switched to compact scanner library from Nordic recently from our own scanner)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the help, looking forward to hearing your thoughts on what might be happening.&lt;/p&gt;
&lt;p&gt;For the logs : here&amp;#39;s what I have&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;2019-06-20 10:07:01.729 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:01.731 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:07:11.766 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:07:11.769 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:07:11.773 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:07:11.782 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:07:11.784 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:07:11.987 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:11.995 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:07:21.782 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:07:21.789 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:07:21.796 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:07:21.810 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:07:21.813 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:07:22.016 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:22.023 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:07:31.806 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:07:31.813 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:07:31.821 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:07:31.836 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:07:31.840 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:07:32.041 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:32.045 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:07:41.834 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:07:41.837 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:07:41.844 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:07:41.859 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:07:41.861 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:07:42.062 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:42.066 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:07:51.856 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:07:51.862 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:07:51.872 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:07:51.883 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:07:51.886 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:07:52.087 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:07:52.092 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
2019-06-20 10:08:01.882 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Cancelling connection...
2019-06-20 10:08:01.888 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.disconnect()
2019-06-20 10:08:01.894 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Disconnected
2019-06-20 10:08:01.906 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt.close()
2019-06-20 10:08:01.910 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : wait(200)
2019-06-20 10:08:02.112 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : Connecting...
2019-06-20 10:08:02.118 31999-31999/ai.cloud I/Stream: StreamBleManager : Message : gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/193945?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2019 16:51:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54ed3939-847a-4764-baba-bc98747ffbf0</guid><dc:creator>13tett</dc:creator><description>&lt;p&gt;Yes sir.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/193936?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2019 15:19:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2cbff4f-5b5f-4c4f-b4df-430d7920581c</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Logs would be great for establishing what happens.&lt;/p&gt;
&lt;p&gt;nRF Connect does not use the Android BLE Library. The main difference is probably that in nRF Connect for Android, the cache is cleared on disconnection. You can get that same behavior in the BLE Library by changing &lt;a href="https://github.com/NordicSemiconductor/Android-BLE-Library/blob/master/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java#L616"&gt;shouldClearCacheWhenDisconnected()&lt;/a&gt; to return true instead of false. The issue may have to do with caching, and if so then that might be a solution.&lt;/p&gt;
&lt;p&gt;How do you recover from the error state? Do you use bonding? Pairing?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Android BLE library, getting into a connecting -&gt; disconnecting (timeout) situation. nRF app seems to help.</title><link>https://devzone.nordicsemi.com/thread/193810?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2019 08:16:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e19ab7bf-eae8-48df-b1be-4dc20dbf5153</guid><dc:creator>awneil</dc:creator><description>[quote userid="80821" url="~/f/nordic-q-a/48796/using-android-ble-library-getting-into-a-connecting---disconnecting-timeout-situation-nrf-app-seems-to-help"]Android BLE library from Nordic[/quote]
&lt;p&gt;This one:&amp;nbsp;&lt;a href="https://github.com/NordicSemiconductor/Android-BLE-Library"&gt;https://github.com/NordicSemiconductor/Android-BLE-Library&lt;/a&gt;&amp;nbsp;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>