<?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>Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15817/bluetooth-automatic-reconnection-nrf51</link><description>Hi,
The situation: nRF51 has established a connection with the iOS/Android (custom made)App. The nRF51 goes out of the Bluetooth range. Eventually, the Bluetooth connection is disconnected. The nRF51 comes into the Bluetooth range. The App reconnects</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Sep 2016 00:51:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15817/bluetooth-automatic-reconnection-nrf51" /><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60395?ContentTypeID=1</link><pubDate>Thu, 01 Sep 2016 00:51:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bd8754c-ab4b-4c5e-a07c-7773df56a4c1</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;The problem was in the iOS set up during automatic reconnection.
This is because at reconnection the app takes a little of time to start receiving notification. It needs to perform the following sequential operations: connection-&amp;gt;discover services-&amp;gt;discover characteristics-&amp;gt;subscribe notification. During this time, it has missed the initial reception from nRF51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60394?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2016 04:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0eabbd5a-51dc-40ce-a22f-6c04f981e8bd</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Hi Jorgen, sorry for the late reply. I have attached the code herewith. Basically I send in the main(), I send a particular value (called pause state) to an endpoint upon new connection and another state called active upon the alternative new connection. I get success for sb_ble_gatts_hvs upon automatic reconnection, but the XCode (iOS)logs does not show any notifications received from the nRF51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60393?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:53:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8736ced-e388-4b38-b337-da0005bf6e31</guid><dc:creator>J&amp;#248;rgen Kvalvaag</dc:creator><description>&lt;p&gt;Hi, is it possible for you to post the code in question to this board? (You should modify your original question, the formatting in comments will make it hard to read)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60392?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:43:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea072ca3-bebc-428c-8349-6dc91d752892</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Hi Jorgen, I have tested this and you are correct, BLE_EVT_TX_COMPLETE did not happen for 300 times - it happened only for 65 times.I had 300 calls to sd_ble_gatts_hvx and on the app, only 5 packets were received by the iOS XCode logger. How to proceed from here? thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60391?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:06:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3022fa79-d4ac-42c8-b68c-c18a29a307af</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Hi Jorgen, Thanks for the reply. I haven&amp;#39;t tested that yet. I will test it now and let you know. Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60390?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 07:04:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6e368b0-0138-4a85-80c9-506bb4e54da9</guid><dc:creator>J&amp;#248;rgen Kvalvaag</dc:creator><description>&lt;p&gt;To clarify, do you have 300 BLE_EVT_TX_COMPLETE events (and 300 calls to sd_ble_gatts_hvx) on the nrf51 app, and only 5 packets received on your Ios/Android app?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60389?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 06:49:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1700d17-b631-48e3-88b6-b9aee92c8c23</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Hi Jorgen, Sorry, I didn&amp;#39;t explain it properly. Even when I send sd_ble_gatts_hvx() upon reconnection, I do get the BLE_EVT_TX_COMPLETE, but in the XCode logs of the (custom made)App, there is no indication that it has received a data from the nRF51. But when I keep sending the same data 300 times, then, the XCode logs of the app says that it has received 5 of the data (didn&amp;#39;t receive all the 300). I think it is something to do with the way the app handles reconnection with Bluetooth. Because, when I close the app and reopen it again(which is a compete disconnection and a new connection - not reconnection), the XCode logs says that it has received data from the nRF51 (nRF51 sent the data only once upon new bluetooth connection). From nRF51 point of view, reconnection or new connection is the same - which is BLE_EVT_CONNECTED, so if the app can receive data from nRF51 upon a new conection, it has to receive data upon reconnection, as well, isn&amp;#39;t it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60388?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2016 06:35:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df222127-2070-4e80-9d89-79feb54f6498</guid><dc:creator>J&amp;#248;rgen Kvalvaag</dc:creator><description>&lt;p&gt;If you are running &lt;code&gt;sd_ble_gatts_hvx()&lt;/code&gt; 295 times before getting a &lt;code&gt;BLE_EVT_TX_COMPLETE&lt;/code&gt; event, i suspect it must be returning an error code. Check the documentation &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v2.0.0/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html#ga313fe43c2e93267da668572e885945db"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60386?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2016 23:10:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac4da6ad-3c1d-4b18-95a7-7204c5d1069a</guid><dc:creator>nordicdev</dc:creator><description>&lt;p&gt;Hi Jorgen, Thanks for your reply. Yes I am using bonding- meaning, only if the app and the nRF51 are bonded (&amp;#39;pair&amp;#39;ed in iOS), the app can write data to the nRF51. Yes, I am using notifications and in the app, the notifications are checked to update the value of the characteristics. The App enables notifications upon reconnect, but by the time the app enables notifications, the initial data has already been sent to the app by the nRF51 (and nRF51 has got a BLE_EVT_TX_COMPLETE event in return). But, I am not checking the return code from  sd_ble_gatts_hvx(). I am not checking the return code from  sd_ble_gatts_hvx because I thought the Bluetooth stack itself would take care of sending multiple retries if the app has not acked the nRF51 regarding the initial(or any) data sent to the app. Please correct me if I am wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth automatic reconnection nRF51</title><link>https://devzone.nordicsemi.com/thread/60387?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2016 07:57:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92a67c82-3c2c-4cf8-862a-b03e6f168173</guid><dc:creator>J&amp;#248;rgen Kvalvaag</dc:creator><description>&lt;p&gt;Hi, how are you sending &amp;quot;initial data to be populated in the characteristics&amp;quot;? Are you using notifications? If so, did you check the return code from sd_ble_gatts_hvx()? Also, are you using bonding? If not, will the App enable notifications from the nRF51 on reconnect?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>