<?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, caching &amp;amp; iOS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29499/dfu-caching-ios</link><description>Hi, 
 I know that this is a known issue, but I&amp;#39;m seeing caching issues often with iOS.
I&amp;#39;m using S132 v5.0.0, SDK 14.0 against custom application with iOS DFU SDK and often I&amp;#39;m seeing that my device is unusable after DFU unless I toggle the bluetooth</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jan 2018 12:25:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29499/dfu-caching-ios" /><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117260?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 12:25:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95ded96b-b7ed-4cbe-8e52-2b7a0944a618</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;OK, I got this working. Apparently, the SDK is not working well with DFU &amp;amp; multiple peers. Effectively, currently only the first peer is stored for SC indication.&lt;/p&gt;
&lt;p&gt;The total changes I did:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;ble_dfu_bonded.c: changed &lt;code&gt;if (p_evt-&amp;gt;params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_GATT_LOCAL)&lt;/code&gt;
to
&lt;code&gt;if (p_evt-&amp;gt;params.peer_data_update_succeeded.data_id == PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING)&lt;/code&gt;
since the former was never triggered; only the latter.&lt;/li&gt;
&lt;li&gt;ble_dfu_bonded.c: added
&lt;code&gt;break;&lt;/code&gt;
before
&lt;code&gt;case PM_EVT_PEER_DATA_UPDATE_FAILED:&lt;/code&gt;
since it&amp;#39;ll enter the FAILED case upon any SUCCESS.&lt;/li&gt;
&lt;li&gt;in main.c, in
&lt;code&gt;case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:&lt;/code&gt;
stopped advertisement (setting &lt;code&gt;ble_adv_on_disconnect_disabled&lt;/code&gt; with &lt;code&gt;ble_advertising_modes_config_set(x)&lt;/code&gt;)
since the iOS/android app SDK will reconnect to the FW before entering bootloader and cause app SDK errors.&lt;/li&gt;
&lt;li&gt;gatt_cache_manager.c: removed fallthrough of &lt;code&gt;case NRF_ERROR_INVALID_STATE&lt;/code&gt; in &lt;code&gt;service_changed_send_in_evt(x)&lt;/code&gt; since this function is triggered after disconnection, after storing peers&amp;#39; data but before entering bootloader, which will drop the SC indication storage.&lt;/li&gt;
&lt;li&gt;increased &lt;code&gt;FDS_OP_QUEUE_SIZE&lt;/code&gt; since I saw a lot of &lt;code&gt;FDS_ERR_NO_SPACE_IN_QUEUES&lt;/code&gt; which may cause peers&amp;#39; data to be discarded before entering bootloader&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For now, it&amp;#39;s working well. Couldn&amp;#39;t find any bugs.
Can somebody review the changes and possible effects on application behavior?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117259?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 07:57:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c794a572-2883-48d1-b673-46ffa6b40a7d</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;but now there&amp;#39;s a race in another place. in ble_dfu_buttonless_bootloader_start_prepare(), there&amp;#39;s a connection termination, which didn&amp;#39;t actually happen (to some degree). upon receiving callbacks from FDS about successful writes from gscm_local_database_has_changed(), the gatt_cache_manager&amp;#39;s service_changed_pending_flags_check() is triggered, then seeing that it needs to send SC indication, but gscm_service_changed_ind_send(x) returns NRF_ERROR_INVALID_STATE since we already disconnected, which then removes the indication request (// CCCDs not enabled. Drop indication.).&lt;/p&gt;
&lt;p&gt;I set a break in this case NRF_ERROR_INVALID_STATE so it doesn&amp;#39;t removed the need for indication. Any comment on how would it affect the system? Any suggestion for a better solution?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117258?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 16:17:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29d48a98-08ca-4562-96f4-e21df3bc3ac9</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;It passes the fallthrough (by mistake?) in the above code with an event
p_evt-&amp;gt;evt_id = PM_EVT_PEER_DATA_UPDATE_SUCCEEDED and p_evt-&amp;gt;params.peer_data_update_succeeded.data_id = PM_PEER_DATA_ID_SERVICE_CHANGED_PENDING.&lt;/p&gt;
&lt;p&gt;It looks like a race to store all of the peers&amp;#39; SC indication status in the flash until the reset to the bootloader. More likely until the 1st peer data is stored.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117257?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 15:48:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3bc3344-8c90-4f60-a5f8-2d47344b4824</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;Apparently, the code is hitting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    case PM_EVT_PEER_DATA_UPDATE_FAILED:
    // Failure to update data. Service Changed cannot be sent but DFU mode is still possible
    err_code = ble_dfu_buttonless_bootloader_start_finalize();
    if (err_code != NRF_SUCCESS)
    {
        mp_dfu-&amp;gt;evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED);
    }

    break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I&amp;#39;m investigating what&amp;#39;s the reason for the failure&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117256?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 15:00:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68605526-0416-4b75-be60-dbc955687e7f</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;Could it be that the SC indication is sent only to the first peer that ever connected? I&amp;#39;m seeing that the second peer doesn&amp;#39;t receive the indication, but the first does&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117255?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 12:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bba545fc-8f89-48a4-97df-fb93dd0e996c</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;@run_ar, using SDK14 from scratch, gscm_local_database_has_changed is called.&lt;/p&gt;
&lt;p&gt;What are the effects of changing to bondless? Is it still buttonless DFU and no need for app/user intervention to perform DFU? and I&amp;#39;m guess that the link is not encrypted as well to the DFU is exposed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117254?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 12:19:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82ca481a-0dbe-4cff-91d3-663c9e00bb00</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;SC indication is working with iPad 2 Mini, iOS ver 10.3.3 and doesn&amp;#39;t work with iPhone 7, iOS 11.2.2.&lt;/p&gt;
&lt;p&gt;Any known issues with iOS 11?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117253?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 12:16:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5d0ac52-9b2f-453e-9904-ed465052ab0a</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Are you by any chance updating from an older SDK? Or are you starting from scratch with sdk 14?&lt;/p&gt;
&lt;p&gt;Assuming you are using buttonless, make sure the last this you do before starting the bootloader is set the service changed flag in the peer manager. See the ble_app_buttonless_dfu example:
gscm_local_database_has_changed(); is called from the function ble_dfu_buttonless_bootloader_start_prepare();&lt;/p&gt;
&lt;p&gt;Have you considered not to use bonding for the bootloader? That way it will show up as a different device, so you avoid this problem all togheter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117252?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 12:09:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6aea9138-4e7f-42fe-a94e-db16b2d50d82</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;Continuing debugging, looks like the FW doesn&amp;#39;t trigger SC indication at all. I&amp;#39;ve put breakpoints at gatts_cache_manager.c, line 359, right after sd_ble_gatts_service_changed call and a breakpoint at gatt_cache_manager.c, line 494, at BLE_GATTS_EVT_SC_CONFIRM case and none of them are hit.&lt;/p&gt;
&lt;p&gt;Looks like the FW is not triggering indication.
I&amp;#39;m wondering if iOS 11 has anything to do with that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117250?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 10:59:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d15f4b3-2d64-43f3-9ba5-39504a9d1c05</guid><dc:creator>gkovelman_tap</dc:creator><description>&lt;p&gt;attribute table didn&amp;#39;t change in the app, but entering DFU and returning to app changes the table, as expected, I assume.
No sniffer trace yet&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DFU, caching &amp; iOS</title><link>https://devzone.nordicsemi.com/thread/117251?ContentTypeID=1</link><pubDate>Wed, 17 Jan 2018 10:07:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2edbe972-d79c-4099-9519-893cee25b7d4</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Are you changing the attribute table? And if so I assume you are sending a service changed indication when reconnecting to the peer? Do you have a sniffertrace so you can see if iOS starts the service discovery procedure when you send the service changed indication?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>