<?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>Proper S110 cleanup on link loss/disconnect?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3247/proper-s110-cleanup-on-link-loss-disconnect</link><description>Folks,
Here&amp;#39;s a specific question and a larger question, of which the first is a part. 
 
 
 What&amp;#39;s the proper way to insure S110 BLE stack cleanup on disconnect due to link loss, especially so I can quickly restart advertising to reestablish the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Aug 2014 18:12:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3247/proper-s110-cleanup-on-link-loss-disconnect" /><item><title>RE: Proper S110 cleanup on link loss/disconnect?</title><link>https://devzone.nordicsemi.com/thread/11892?ContentTypeID=1</link><pubDate>Fri, 01 Aug 2014 18:12:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e7a2f1-3381-4c6c-acb0-d81e6c4f8eea</guid><dc:creator>Mike Wirth</dc:creator><description>&lt;p&gt;Just to follow up and close this question:  Problem solved.  Pål was on the right track.  I wasn&amp;#39;t making a redundant call to start advertising, but after the new connection was established I was attempting to restart RSSI-changed events and the call was failing because it was already started (didn&amp;#39;t get shutdown when the prior connection went away and survived through the disconnect and reconnect).&lt;/p&gt;
&lt;p&gt;At this point, I would make a plea for a general &amp;quot;feature&amp;quot; in the S110 Soft Device -- it would be great to have a way to ascertain the current state of the BLE stack.  In particular, any configuration change that&amp;#39;s written to the soft device should be readable.&lt;/p&gt;
&lt;p&gt;In the current case, if I ask to start RSSI-changed events, at some other point in my code it would be great to be able to determine the state of this activity.  Without that, I had to write test code to determine that the call to start it while already running failed, but redundant calls to stop it didn&amp;#39;t.  Therefore, a &lt;em&gt;defensive programming&lt;/em&gt; style is to always turn the activity off before starting it up.  Seems kind of silly.&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper S110 cleanup on link loss/disconnect?</title><link>https://devzone.nordicsemi.com/thread/11891?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2014 05:44:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a4eb1c7-08b6-42db-a418-a95d7bff613c</guid><dc:creator>P&amp;#229;l H&amp;#229;land</dc:creator><description>&lt;p&gt;When the S110 disconnects and signals that to the application, then it is no longer in a connection. Thus what you are asking about will never  happen. At that point it is up to the app developer to either put it to sleep or start advertising again. As the S110 is just a peripheral device, the only thing it can do (as the iPhone don&amp;#39;t support directed advertising) is to just do normal advertising again. For how to handle the reconnection on iOS, I have no clue about.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper S110 cleanup on link loss/disconnect?</title><link>https://devzone.nordicsemi.com/thread/11890?ContentTypeID=1</link><pubDate>Mon, 28 Jul 2014 19:57:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65c4efa9-5c04-4a60-b73e-b576407ac29b</guid><dc:creator>Mike Wirth</dc:creator><description>&lt;p&gt;Pål, Thanks for the feedback.  At the app level, I have an FSM (Finite State Machine, implemented by a switch statement in C), so I shouldn&amp;#39;t be calling advertising start multiple times.  But there might be something happening at lower levels.  I&amp;#39;ll check.
BTW, what&amp;#39;s the S110 behavior if it loses connection and signals that to the app, causing the connection handle to go invalid, but goes back in range before the central tears down the connection.  Will the S110 reconnect by itself?  (Is this a possible situation?  Too many error states and recovery paths to consider :-)
Mike (who&amp;#39;s going off to read the &amp;quot;best practices&amp;quot; section in the iOS Core Bluetooth documentation on link maintenance)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper S110 cleanup on link loss/disconnect?</title><link>https://devzone.nordicsemi.com/thread/11889?ContentTypeID=1</link><pubDate>Mon, 28 Jul 2014 09:11:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4e92130-0ef9-45a3-9985-9befadc6709c</guid><dc:creator>P&amp;#229;l H&amp;#229;land</dc:creator><description>&lt;p&gt;Hi Mike, Just a small comment. Do you have a different flag to disallow calling the sd_ble_gap_adv_start twice right after each other? It looks like you have only one flag to determine if you should start advertising again, and this flag will not be updated until you have a connection. In the connection event.&lt;/p&gt;
&lt;p&gt;It would probably be an idea to have a BLE_CONN_HANDLE_INVALID and BLE_CONN_HANDLE_ADV_STARTED or something, and only trigger advertising on the BLE_CONN_HANDLE_INVALID, and then update it to BLE_CONN_HANDLE_ADV_STARTED?&lt;/p&gt;
&lt;p&gt;BR Pål&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>