<?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>DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4883/dfu-on-nrf51822-ios----have-to-toggle-bluetooth-on-off</link><description>I&amp;#39;m wondering (hoping) if there is something that I&amp;#39;m not doing correctly ... 
 We have a BLE application on the nRF51822 which has been working nicely.
It is a custom BLE Service/Characteristic which supports a command/response
protocol that we&amp;#39;ve</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 31 Dec 2014 06:49:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4883/dfu-on-nrf51822-ios----have-to-toggle-bluetooth-on-off" /><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17244?ContentTypeID=1</link><pubDate>Wed, 31 Dec 2014 06:49:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3940b1e1-675d-47c0-935a-097a6f66f498</guid><dc:creator>Tim Clark</dc:creator><description>&lt;p&gt;Still struggling with this one.  I did find that the Nordic DFU Bootloader example doesn&amp;#39;t have the Service Changed Characteristic enabled.  So I enabled that.  (It was always enabled in my Application F/W).  But it still behaves (more or less) the same -- as if there is still some form of Caching happening on the iOS side?  I even changed the DFU bootloader and my Application F/W to have the advertise with the identical device name -- just in case.  No change.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17249?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 01:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4484d526-f89e-4c35-8a43-128e212212b8</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;The OP should really read Apple&amp;#39;s own guidelines, per my previous suggestion. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17248?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 01:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:455397bd-7066-4a98-85f1-7167838d7368</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Ah, yes, I agree. I missed your point about choosing one or the other.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17247?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 01:05:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70cb1124-926f-4625-bc93-606b6ea5825a</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;Altering the GATT table without Service Changed Characteristic &lt;em&gt;is&lt;/em&gt; a violation of the Spec. If you read Audun&amp;#39;s post carefully, he&amp;#39;s suggesting &lt;em&gt;either&lt;/em&gt; the Service Changed characteristic (the right way to do this) or &amp;quot;fooling&amp;quot; the device by using the same Services in both application and DFU &amp;quot;mode&amp;quot;.&lt;/p&gt;
&lt;p&gt;If you use the former, you don&amp;#39;t need the latter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17246?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 00:53:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c66aff92-e882-49b6-8706-cd02b5a36a5c</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Altering the GATT database isn&amp;#39;t in violation of the Bluetooth spec. The Service Changed characteristic exists explicitly to handle this situation: &amp;quot;If the list of GATT based services and the service definitions cannot change for the lifetime of the device then this characteristic shall not exist, otherwise this characteristic shall exist.&amp;quot;&lt;/p&gt;
&lt;p&gt;However, if this doesn&amp;#39;t work with iOS, I suggest keeping the same GATT database both for normal operation and when the bootloader is active. That is, adding a dummy DFU Service in normal mode, and dummy other-Services in the bootloader.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17245?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 00:37:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43572968-3f75-49cf-811e-9f9885b0cd90</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;By design, you cannot &amp;#39;flush&amp;#39; the CoreBluetooth GATT cache. Even setting the CBCentral object to nil, or instantiating another CBCentral won&amp;#39;t help in these circumstances.&lt;/p&gt;
&lt;p&gt;I wouldn&amp;#39;t recommend the second part of your suggestion as technically you&amp;#39;re violating both Spec (removing Services is just as much a no-no as adding them without Service Discovery enabled) and Apple&amp;#39;s guidelines for dealing with this situation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17243?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 00:21:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1020df3-6649-45a3-8f79-abbcb97382b5</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hi Tim,&lt;/p&gt;
&lt;p&gt;I agree with Nate and jt,
this does indeed look like a caching issue.&lt;/p&gt;
&lt;p&gt;One problem with the bootloader as it is now is that the bootloader has a completely different GATT database than your normal application. When a Central device re-connects to your nRF51, it expects that the GATT database is the same, so it can avoid doing a Service Discovery procedure (which takes time). Bluetooth does have functionality for dealing with this situation: one of the native characteristics on a BLE device is the &amp;quot;Service Changed Characteristic&amp;quot;. The idea is that the GATT Server can use this to indicate to the GATT Client that the GATT database has changed (see &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.1.0/s110/html/a01060.html#ga2c8c90d73fa27ba6691ad82b4a960adc)"&gt;developer.nordicsemi.com/.../a01060.html&lt;/a&gt;. There&amp;#39;s not guarantee that the peer device will take action when this happens, but it&amp;#39;s worth a try looking into. Note that with S110 v7.0.0 and later, you must specifically tell the stack to include this characteristic when enabling the stack (see &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.1.0/s110/html/a01045.html#ga0f632bec36100e4d2d74672ccbb4218b)."&gt;developer.nordicsemi.com/.../a01045.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also add the DFU Service to your normal GATT database before your other services. I mean, just add the Service to your database, but not include any of the actual bootloader functionality in there. This way the peer device will the the following services during normal operation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DFU Service&lt;/li&gt;
&lt;li&gt;Battery Service (for example)&lt;/li&gt;
&lt;li&gt;Device Information Service (for example)&lt;/li&gt;
&lt;li&gt;Your other Services&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When the bootloader is active, the peer device will see the following services:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DFU Service&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thus you won&amp;#39;t have to force flushing the cache in order to find the DFU Service in bootloader mode (as the DFU Service will now be at the exact same place in the GATT database), and hopefully you will see the full set of Services again when you resume normal operation.&lt;/p&gt;
&lt;p&gt;It might be easier to &amp;quot;just&amp;quot; flush the cache when triggering the bootloader, but I&amp;#39;m not exactly sure how/if that can be done without disabling and re-enabling Bluetooth (I&amp;#39;m not an iOS developer).&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
&lt;p&gt;Audun&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17242?ContentTypeID=1</link><pubDate>Sat, 20 Dec 2014 00:14:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fabd5d8-4e37-4d53-b87b-818e6ddfeef6</guid><dc:creator>Marc Nicholas</dc:creator><description>&lt;p&gt;Yes, there is something you&amp;#39;re not doing correctly. You need to:&lt;/p&gt;
&lt;p&gt;(1) Read the Bluetooth Spec.
(2) Read Apple&amp;#39;s Bluetooth Accessory Design Guidelines (maybe start here as it&amp;#39;s only a few pages long and has the answer plainly written in it).&lt;/p&gt;
&lt;p&gt;Both the reason why you are seeing this behaviour and the way to &amp;#39;fix it&amp;#39; is included within these documents.&lt;/p&gt;
&lt;p&gt;Contrary to the [incorrect] comments above, Apple&amp;#39;s iOS behaviour is not erroneous and is 100% per the Bluetooth Spec. Nor was this suddenly introduced in iOS8. Apple are pretty serious about BLE and don&amp;#39;t tend to cut corners, despite CoreBluetooth not being the most friendly API around ;)&lt;/p&gt;
&lt;p&gt;-m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17241?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2014 22:33:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8017a635-519d-485b-aec5-c34269426735</guid><dc:creator>Nathan</dc:creator><description>&lt;p&gt;Tim,&lt;/p&gt;
&lt;p&gt;This is probably the same bug I encountered awhile back while trying to get a DFU bootloader to work with iOS apps. My firmware used to work back on iOS 7, but broke when the phone was upgraded to iOS 8. What I eventually discovered is that in iOS 8, for some reason the Bluetooth stack will now save the advertising data of any Bluetooth smart device it connects to somewhere in memory at the moment of connection. The old advertising data will then be recalled and used the next time the peripheral advertises to the phone instead of the current advertising data. Therefore, except for first time connection the phone app will always be &amp;quot;one connection behind&amp;quot; in terms of what it reports is contained in the advertising data. Because I used the advertising data to tell the app when to use the bootloader as well, it got confused and couldn&amp;#39;t connect up properly.&lt;/p&gt;
&lt;p&gt;For now I&amp;#39;d avoid using the advertising data as a means to determine if your device wants to run normally or enter bootloader mode. If it&amp;#39;s possible to do and your phone app is flexible enough, I&amp;#39;d recommend altering your bootloader advertising data to exactly match the firmware main data, and have your phone app always search for the common data. On connection, perform a service discovery and use the services the peripheral reports are available to determine what mode the device is in, and handle it appropriately from there. Alternatively, create a custom common service between the bootloader and main firmware app whose sole purpose in life is to send a one byte value to the phone to tell it whether the device is in bootloader or main code.&lt;/p&gt;
&lt;p&gt;Nate&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17240?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2014 01:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74fe3a6b-abb7-4792-87ad-5c38229e01de</guid><dc:creator>Tim Clark</dc:creator><description>&lt;p&gt;Thanks for the suggestions!&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t checked the source code for nRF Toolbox (just downloaded from the App store) -- but it seems like our App must? be closing-out OK if nRF Toolbox is successfully discovering the DFU Service/Characteristic -- but then after nRF Toolbox is done -- I&amp;#39;m not able to see my device post-DFU.&lt;/p&gt;
&lt;p&gt;Guess would be great to hear is if anybody has had issues using the nRF Toolbox DFU -- then their device not showing up afterwards?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU on nRF51822 + iOS -- Have to toggle Bluetooth ON/OFF</title><link>https://devzone.nordicsemi.com/thread/17239?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2014 01:20:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f326173e-292b-404d-ac49-8d1611b60157</guid><dc:creator>jt</dc:creator><description>&lt;p&gt;I had a similar issue where my iOS app wasn&amp;#39;t properly handling a reconnect from the peripheral, so I had to also either toggle bluetooth on/off or reset the app. Did you confirm that your CBPeripheral object is set to nil upon a disconnect, if your CBPeripheral has a singleton/shared instance delegate, it&amp;#39;s being managed properly, and that you re-enable scanning? Those 3 things contributed to me seeing that behavior, but all the root cause was on the iOS side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>