<?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>Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89502/client-automatically-reconnects-to-server-after-ota-dfu</link><description>I&amp;#39;m trying to implement OTA DFU in our custom App with our nRF52832 acting as the device to be upgraded. Everything seems to work OK in that: 
 1. New image uploads to the device 
 2. App resets the device to transfer new image into correct area 
 3.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jul 2022 06:12:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89502/client-automatically-reconnects-to-server-after-ota-dfu" /><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375922?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2022 06:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dd65118-537d-4091-8066-da01709375e9</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>[quote userid="3284" url="~/f/nordic-q-a/89502/client-automatically-reconnects-to-server-after-ota-dfu/375919"]The reset command from Mcumgr should do the same. It should reboot the device after gracefully disconnecting. Perhaps check why it doesn&amp;#39;t work as intended?[/quote]
&lt;p&gt;We can see that reset command being issued my the Mcumgr with both the devices, and this then restarts our device and it then beings advertising.&amp;nbsp; But for some reason on the 12/12Pro, the phone would then reconnect and the only way for us to get our device to disconnect was to force it to stop advertising (we enable/disable this via a GPIO)&lt;/p&gt;
&lt;p&gt;Much as I&amp;#39;d like to understand why, the commerical realities of getting product to market dictate that &amp;quot;if you&amp;#39;ve got something that works, move on to the next issue&amp;quot;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375919?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2022 06:01:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a4bbee1-5e86-4e53-8fae-177bf5fb141f</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;The reset command from Mcumgr should do the same. It should reboot the device after gracefully disconnecting. Perhaps check why it doesn&amp;#39;t work as intended?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375914?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2022 05:12:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fdce937-5f7a-4f3d-af19-175717b763f3</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;OK, so what we were able to ascertain is that it seemed to be device specific.&amp;nbsp; We are testing with two different devices (based on what our dev team have as their own handsets basically)&lt;/p&gt;
&lt;p&gt;1. iPhone 7, running iOS 15.5 - this would successfully disconnect from the device at the completion of the DFU&lt;/p&gt;
&lt;p&gt;2. iPhone 12/12Pro running iOS 15.5 - this would NOT disconnect from the device once the DFU had completed, even after issuing multiple software reset commands.&lt;/p&gt;
&lt;p&gt;So, we&amp;#39;ve resorted to a brute force method, and have a service/characteristic that we write to at the end of the DFU, that forces the device to disconnect the connection itself.&amp;nbsp; Seems to work on both the devices listed above.&lt;/p&gt;
&lt;p&gt;Not really sure why different devices behave differently, but we&amp;#39;ve got a solution that works&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375501?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2022 09:34:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97aafd22-d236-4c96-b3f5-70c175c04aab</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Mike,&amp;nbsp;&lt;br /&gt;I think the combination of Directed advertising + bonded = auto reconnection.&amp;nbsp;&lt;br /&gt;So if you disable directed advertising right after the new image is running it should be able to avoid reconnecting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Actively request a disconnection when an unwanted connection happens is a good failsafe solution in my opinion.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Another option is to switch between different addresses. When you don&amp;#39;t want to be connected or bonded you use a different advertising address. And when you want to be connected and bonded you return to the original address.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375207?ContentTypeID=1</link><pubDate>Sat, 02 Jul 2022 22:47:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5213b19-3920-46fe-81f0-1c0eb6130234</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Aleksander,&lt;/p&gt;
&lt;p&gt;Thanks for that explanation - makes sense&lt;/p&gt;
&lt;p&gt;We&amp;#39;re using NCS V1.9.1 to do our development.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll follow up your other post with some logs from the nRF Connect App.&amp;nbsp; That App actually works, in that I don&amp;#39;t get the automatic reconnect at the completion of the DFU (but it does hold the connection even if I press the &amp;#39;disconnect&amp;#39; button in that App).&amp;nbsp; Its our custom App that is the issue, so maybe I need to get the App developers to dig a bit deeper into what their App is doing at the conclusion of the DFU&lt;/p&gt;
&lt;p&gt;I am using CTS so that I can update the time in my on-board RTC anytime there is a connection to the device via our App.&amp;nbsp; We time stamp events as they occur, and so want to ensure that the RTC is as close to the correct time as possible.&amp;nbsp; It also helps us set up the RTC during production.&amp;nbsp; As I understand it, pairing/bonding is a requirement of iOS to use the CTS.&amp;nbsp; I&amp;#39;d prefer not to have to pair/bond if I didn&amp;#39;t need to.&lt;/p&gt;
&lt;p&gt;Our device spends most of its time in System OFF mode.&amp;nbsp; An event on a GPIO triggers it out of this mode, it grabs some details, stores some info into NVS, then goes back into System OFF.&amp;nbsp; That&amp;#39;s probably 99.9% of its time.&lt;/p&gt;
&lt;p&gt;If someone wants to grab the information the device has stored, they trigger it out of System OFF via a different GPIO input, and whilst this GPIO input remains active, the device is advertising with data in the scan response packet indicating details on the events.&amp;nbsp; Our App picks this info up and displays it.&amp;nbsp; It also grabs the information stored in NVS and sends this to a database so we can collect all the information from the various devices.&amp;nbsp; If there is a firmware update available, then this can also be completed via our App whilst the device is advertising.&amp;nbsp; Its this part of the device&amp;#39;s operation we&amp;#39;re having issues with.&amp;nbsp; Our App developers needed the device to restart advertising after the DFU, so our App can reconnect and confirm that the DFU was successful.&amp;nbsp; After the App has confirmed this, it resets the device a second time.&amp;nbsp; The device will then restart advertising as the appropriate GPIO is still being held active.&amp;nbsp; Its at this point that our iOS device reconnects, when we don&amp;#39;t want it to&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375176?ContentTypeID=1</link><pubDate>Sat, 02 Jul 2022 06:30:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7a982a8-6900-490d-90ea-5a42b142a828</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>[quote userid="109035" url="~/f/nordic-q-a/89502/client-automatically-reconnects-to-server-after-ota-dfu/374997"]I do notice that if I connect to the device using any other iOS BLE app (nRF Connect, LightBlue, etc) then when I hit the &amp;quot;disconnect&amp;quot; button on those apps, the Central doesn&amp;#39;t actually disconnect from Peripheral.&amp;nbsp; I actually had to create a characteristic that I have to write to in order to force the disconnection from those Apps.&amp;nbsp; This might be something to do with iOS - I&amp;#39;m not sure.[/quote]
&lt;p&gt;This is expected behavior. A device on both Android and iOS can be connected by multiple apps or multiple clients in each app. The physical Le connection is terminated only when the last virtual connection is discontented. A virtual connection may also be held by the system, if is supports the service, e.g. HID, or, in case of iOS, perhaps CTS service. A command to trigger disconnection from the device side is indeed the only solution for this use case.&lt;/p&gt;
&lt;p&gt;However, I understand that it is the automatic reconnection, not lack of disconnection, that&amp;#39;s the root cause. Try disabling direct advertising, or the CTS service, if you don&amp;#39;t need it.&lt;/p&gt;
&lt;p&gt;If connection is only for dfu, why do you have pairing/bonding in the first place?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375175?ContentTypeID=1</link><pubDate>Sat, 02 Jul 2022 06:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edfab0eb-e36f-4ecf-a815-3cc294aed620</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe that you&amp;#39;re using nRF5 SDK, not NCS, therefore OTA over Secure or Legacy DFU. Could you write which SDK version?&lt;/p&gt;
&lt;p&gt;Either way, in both legacy and secure dfu, the update is performed by the dfu bootloader. The last command sent after upload is complete triggers device restart, initiated from the device side. Mobile dfu libraries report succees only after the device disconnects. The device then switches back to application mode.&lt;/p&gt;
&lt;p&gt;As I understand, your device has Current Time Service (CTS). iOS it a requirement for the project? It&amp;#39;s not required by iOS, it exposes it&amp;#39;s own CTS service, but there&amp;#39;s no need to use it.&lt;/p&gt;
&lt;p&gt;Are you using pairing or bonding? I believe, after the restart it&amp;#39;s starting direct advertising which may triggers automatic reconnection from the phone. iOS can support CTS service natively, so may hold the connection writing any app running.&lt;/p&gt;
[quote userid="109035" url="~/f/nordic-q-a/89502/client-automatically-reconnects-to-server-after-ota-dfu"]But because it remains connected after the OTA DFU, things get all locked up.[/quote]
&lt;p&gt;Is it connected to the bootloader, or your custom firmware?&lt;/p&gt;
&lt;p&gt;Also, the mobile dfu libs are generating logs. It would be very helpful to see them. I believe that the dfu operation ends with a restart and it is the advertising initiated by firmware that triggers the phone to reconnect, but logs could prove me being wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/375007?ContentTypeID=1</link><pubDate>Fri, 01 Jul 2022 07:14:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d338b8e-1e44-439f-9c76-ea180a1598ed</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks Mike.&amp;nbsp;&lt;br /&gt;I think this is something we can fix in the iOS DFU library. I assume you have the same problem when you test with nRF DFU app or nRF Toolbox app , correct ?&amp;nbsp;&lt;br /&gt;I will report your observation to the app team and will let you know when we have any update.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/374997?ContentTypeID=1</link><pubDate>Fri, 01 Jul 2022 06:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecebce21-aa95-4f88-af85-a4f8e76bd3f1</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;So, in &amp;quot;normal&amp;quot; operation, the device is advertising, but the App doesn&amp;#39;t try and connect.&amp;nbsp; It just grabs the scan response data and updates its info that way.&amp;nbsp; The only time it will connect is to do a DFU.&lt;/p&gt;
&lt;p&gt;I do notice that if I connect to the device using any other iOS BLE app (nRF Connect, LightBlue, etc) then when I hit the &amp;quot;disconnect&amp;quot; button on those apps, the Central doesn&amp;#39;t actually disconnect from Peripheral.&amp;nbsp; I actually had to create a characteristic that I have to write to in order to force the disconnection from those Apps.&amp;nbsp; This might be something to do with iOS - I&amp;#39;m not sure.&lt;/p&gt;
&lt;p&gt;But after the DFU and with my custom App forcing the software reset, I would have thought the Peripheral would disconnect.&amp;nbsp; If I do a reset on the DK, it certainly forces the disconnect.&amp;nbsp; But having my App force the reset, it doesn&amp;#39;t seem to.&lt;/p&gt;
&lt;p&gt;I grab the vallue of RESETREAS when it first boots up, and not surprisingly, when the App resets the device, I see RESETREAS = 0x04, which corresponds to the Software Reset (SREQ).&amp;nbsp; My code then sets up Bluetooth and starts advertising.&amp;nbsp; The Client then connects, even though I don&amp;#39;t want it to.&lt;/p&gt;
&lt;p&gt;If I do a RESETPIN reset via the button on my DK at this point, then the device will go through the Bluetooth start up and start advertising, but will not reconnect to the Central.&lt;/p&gt;
&lt;p&gt;The brute force method at this point might well be that my App needs to write to my &amp;quot;disconnect&amp;quot; characteristic to force a disconnect.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Client automatically reconnects to server after OTA DFU</title><link>https://devzone.nordicsemi.com/thread/374851?ContentTypeID=1</link><pubDate>Thu, 30 Jun 2022 09:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d60dd440-c2e8-4d22-9235-087e64350b57</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Mike,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will check with the app team to see if there is any solution.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But could you let me know, if you turn on the device (in normal operation) close to the phone, would they automatically connect ?&amp;nbsp;&lt;br /&gt;As far as I know if a paired device is in range, the phone may just re-connect to it automatically.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>