<?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>Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39184/refreshing-cached-services-on-bonded-peer-after-dfu</link><description>Hi, 
 
 We&amp;#39;re using bonding between our peripheral HID device and 3rd party central devices. Our device runs on a 52832 board with SDK 14.0.0 and SD 5.0.0. 
 
 We&amp;#39;ve run into a problem with GATT service caching on Android devices. The problem occurs after</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Oct 2018 09:59:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39184/refreshing-cached-services-on-bonded-peer-after-dfu" /><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/154035?ContentTypeID=1</link><pubDate>Tue, 23 Oct 2018 09:59:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d2c80a3-1143-49b5-a80a-4b09ba635995</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I have sent an email to our Android developer asking if he has heard back from his Google contact. As for the&amp;nbsp;central&amp;nbsp;issue, from the Wireshark logs I see that the Central is trying to re-encrypt the link, but there is no reply from the peripheral side. Can you verify that you get the BLE_GAP_EVT_SEC_INFO_REQUEST on the peripheral side&lt;br /&gt;as shown in the&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___b_l_e___g_a_p___p_e_r_i_p_h___e_n_c___m_s_c.html"&gt;Peripheral Encryption Establishment using stored keys&lt;/a&gt;&amp;nbsp;MSC? Should be handled in&amp;nbsp;smd_ble_evt_handler() in security_dispatcher.c.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/153723?ContentTypeID=1</link><pubDate>Sun, 21 Oct 2018 16:28:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:679ff6d4-a707-4b18-a05b-c2c2bc68cdb7</guid><dc:creator>ohtap</dc:creator><description>&lt;p&gt;Hi Bjorn,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Our Android developer has implemented an automatic mechanism on the Android side that unpairs and re-pairs after a DFU.&lt;/p&gt;
&lt;p&gt;It seems to work with some Android devices, but with others it&amp;#39;s inconsistent. When the mechanism fails and the services aren&amp;#39;t refreshed, manual unpairing and pairing seems to do the trick.&lt;/p&gt;
&lt;p&gt;The strange thing is, after trying to connect to other devices (even non Android) we get strange spam from the Central&amp;#39;s side (attached 2 wireshark logs) and the devices themselves sometimes give an error of &amp;quot;Incorrect pin or passkey&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there a reason for the Central to spam requests?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also,&amp;nbsp;did you by chance get an answer from Google regarding the SC timing?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/PairingConfirmSpam.pcapng"&gt;devzone.nordicsemi.com/.../PairingConfirmSpam.pcapng&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/LL_5F00_ENC_5F00_REQ-spam.pcapng"&gt;devzone.nordicsemi.com/.../LL_5F00_ENC_5F00_REQ-spam.pcapng&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/152540?ContentTypeID=1</link><pubDate>Thu, 11 Oct 2018 15:07:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bb7b0cd-2088-48bf-824f-0f45ec3f23e2</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I do not see any acknowledgement of the indication nor any service discovery being performed in the trace. I just see the encryption request from the slave and then the encrypted packets after that, maybe the reply to the indication is in there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However I discussed the issue with our Android developer and if I understood him correctly&amp;nbsp;the issue is not in your application, but in the Android Settings App that handles the HID reports.&lt;/p&gt;
&lt;p&gt;According to him the Android Settings app will&amp;nbsp;see the&amp;nbsp;&amp;nbsp;new services next time&amp;nbsp;the device connects, which is why why things work after switching Bluetooth off/on.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Here is what he suggested:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;They could also try to do the same from the peripherals side. After SC indication is sent and Android completes service discovery, their HID device could gracefully disconnect and start advertising directly, so Android should&amp;nbsp; reconnect quickly or they can restart Bluetooth from the app, but that&amp;#39;s ugly (as User may be listening to a music, or something)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Settings app asks for services too quickly. It gets them before SC inidcation is received, and has no clue that they have changed. Their app is using correct services, as they waited 1.6 sec before calling gatt.discoverServices().&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;He also said that he has contacted Google about this, but he has yet to get a reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bj&amp;oslash;rn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/152449?ContentTypeID=1</link><pubDate>Thu, 11 Oct 2018 08:38:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb40d8e8-76d7-4328-94d2-bb8cb13e731f</guid><dc:creator>ohtap</dc:creator><description>&lt;p&gt;The log itself is unfiltered and filled with empty packets, so I&amp;#39;m attaching the some of the packets that came after the indication. There are still a few &amp;quot;Encrypted packet decrypted incorrectly (bad MIC)&amp;quot; events, so I&amp;#39;m not sure if something was missed.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the meanwhile we&amp;#39;re exploring the option of unpairing and pairing again automatically, but it&amp;#39;s probably not the best solution.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Service_5F00_changed_5F00_indication1.pcapng"&gt;devzone.nordicsemi.com/.../Service_5F00_changed_5F00_indication1.pcapng&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/152249?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 14:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e835e6b6-62ad-4d3d-8a0e-f240ef72e6fd</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I agree that the handles look fine. Do you see the Master acknowledging the indication to the Slave? If you could attach the sniffer trace here then that would be great.&amp;nbsp; I&amp;#39;ll run this by our Android developer and hear what he has to say.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/152228?ContentTypeID=1</link><pubDate>Tue, 09 Oct 2018 13:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6ac945a-9fb4-4a22-afd3-65bcafa97e5b</guid><dc:creator>ohtap</dc:creator><description>&lt;p&gt;Hi, thanks for the answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried to reply, but the message wasn&amp;#39;t posted, so I&amp;#39;ll try again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We tested the issue on multiple Android devices with versions 7.0, 8.0, 9.0 and had the same issue.&lt;/p&gt;
&lt;p&gt;The sniffer had some issues, but eventually I noticed this packet while updating using the nRF Connect on LG G6:&lt;/p&gt;
&lt;p&gt;Frame 9634: 37 bytes on wire (296 bits), 37 bytes captured (296 bits) on interface 0&lt;br /&gt;Nordic BLE Sniffer&lt;br /&gt; Board: 9&lt;br /&gt; Header, Packet counter: 13367&lt;br /&gt; Length of packet: 10&lt;br /&gt; Flags: 0x01&lt;br /&gt; Channel: 10&lt;br /&gt; RSSI (dBm): -66&lt;br /&gt; Event counter: 1&lt;br /&gt; Delta time (&amp;micro;s end to start): 151&lt;br /&gt; [Delta time (&amp;micro;s start to start): 383]&lt;br /&gt;Bluetooth Low Energy Link Layer&lt;br /&gt; Access Address: 0xaf9abdac&lt;br /&gt; [Master Address: 61:b2:bc:04:36:02 (61:b2:bc:04:36:02)]&lt;br /&gt; [Slave Address: ed:50:3a:4f:39:81 (ed:50:3a:4f:39:81)]&lt;br /&gt; Data Header: 0x0b06&lt;br /&gt; [L2CAP Index: 472]&lt;br /&gt; CRC: 0x6737c7&lt;br /&gt;Bluetooth L2CAP Protocol&lt;br /&gt; Length: 7&lt;br /&gt; CID: Attribute Protocol (0x0004)&lt;br /&gt;Bluetooth Attribute Protocol&lt;br /&gt; Opcode: Handle Value Indication (0x1d)&lt;br /&gt; 0... .... = Authentication Signature: False&lt;br /&gt; .0.. .... = Command: False&lt;br /&gt; ..01 1101 = Method: Handle Value Indication (0x1d)&lt;br /&gt; Handle: 0x000c (Generic Attribute Profile: Service Changed)&lt;br /&gt; [Service UUID: Generic Attribute Profile (0x1801)]&lt;br /&gt; [UUID: Service Changed (0x2a05)]&lt;br /&gt; Starting Handle: 0x000e&lt;br /&gt; Ending Handle: 0xffff&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The handles seem fine, but I&amp;#39;m not sure about the rest of it (Authentication? command?).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Our Android developer&amp;nbsp;tried using the 1600ms delay, but the problem wasn&amp;#39;t solved. He&amp;#39;s indeed using the latest version from the DFU library.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Turning Bluetooth off and on solves the issue without even unpairing, so perhaps the indication is ignored until the connection is re-established?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Refreshing cached services on bonded peer after DFU</title><link>https://devzone.nordicsemi.com/thread/151864?ContentTypeID=1</link><pubDate>Fri, 05 Oct 2018 14:42:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b9528cb-8682-4263-a672-4bb40deaef48</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Oded,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which Android version are you using? Our Anderoid developer informed me that Android version 4.3-5.0 (prehaps 5.1 as well) and 8.0-9.0 do not enable Service Changed indications after bonding. It should be done automatically, but it&amp;#39;s not on those versions.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So, make sure that indications of the Service Changed characteristic is enabled and that sd_ble_gatts_service_changed() call made from the bootloader includes the correct start and end handle values.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume that you&amp;#39;re&amp;nbsp;using our &lt;a href="https://github.com/NordicSemiconductor/Android-DFU-Library"&gt;Android DFU Library&lt;/a&gt; in your Android app. Make sure that you&amp;#39;re using the latest version, v1.7.0 other wise you will run in to the issue described &lt;a href="https://github.com/NordicSemiconductor/Android-DFU-Library/issues/112"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Do you have a sniffer trace of the communication between the Android device and the nRF52832? It would be interesting to see if the Service Changed Indication is sent from the NRF52832 to the Android device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If the SC indication is enabled and properly handled by the Android device, then another possible cause could be the following:&lt;/p&gt;
&lt;p&gt;After re-connection to the new app and resuming encryption, the target sends the SC indication and the Android will do the service discovery. Here, care must be taken to make sure that indication is correctly received.&amp;nbsp; After getting onConnectionStateChanged on bonded device we reommend waiting 1.6 second before calling discoverServices(), to make sure the indication was received, and the new service discovery was complete, or at least started.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>