<?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 way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56080/proper-way-to-handle-a-bonded-reconnect</link><description>According to the spec, this is how a bonded reconnect should work: 
 On first pass, the central client does discovery and enables descriptors to characteristics of interest. At sometime during this sequence, pairing occurs. The central saves the pairing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Jan 2020 16:40:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56080/proper-way-to-handle-a-bonded-reconnect" /><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/231964?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 16:40:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c2c5de8-3df9-4a4b-a940-9b4ac10ed931</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I will work on that. The client is fairly complicated as it is a production application. It does not ever read the CCCDs, it always enables them every pass because there are some devices that do NOT properly remember the bonding information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/231920?ContentTypeID=1</link><pubDate>Thu, 30 Jan 2020 14:07:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1df35302-c5d5-43eb-b3e5-c566a27e5ba0</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;As a check, what happens if you try the read a cccd value from the gatt-client, after you have connected and tried to restore the attributes on the connection event (on the gatt server)? Since this is the api&amp;#39;s we are using in the peer manager to recover attributes they should work, but maybe there is something wrong with the serialization.&lt;/p&gt;
&lt;p&gt;Is there any chance you can share your application? or create stripped down version that recreates the issue?&lt;/p&gt;
&lt;p&gt;Also, could you capture sniffer traces that shows the initial connection where the bonds is created and also a new connection where the bond and attribute data is restored?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230667?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 14:33:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f084da4-9ebe-4b65-9559-00fd28d7b07c</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I do not know what will trigger the attrs missing event. It is never triggered.&lt;/p&gt;
&lt;p&gt;I have tried all combinations for the get and set. At the moment I am ORing all the available flags in the hope that I am getting both system and &amp;#39;application&amp;#39; CCCD settings. From parsing the data (which is not the easiest to read) it looks like everything is there (service changed AND my app&amp;#39;&amp;#39;s CCCDs).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This prevents me from sending a service changed event ... it never works. But having the central re-set the CCCDs every connection works. A bad solution and not following the spec.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230602?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 12:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79f0243b-d2cb-498b-a93d-14aa3828e04b</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Yes, you are right, you have to wait until the connection is established befor setting the system attribures. But you already confirmed the get looks good when you read it back after a write. So that is a bit strange. Are you using the flags or are you getting and restoring both system and user attributes? Note that it should be fine to set the attribute on connection,&amp;nbsp; I do not see a reason to wait for the system attribute missing event or error. However you should probably wait until the bond has been reestablished so you know you are setting the system attributes for a known device and not just someone who randomly connected.&lt;/p&gt;
&lt;p&gt;Note that calling sd_ble_gatts_hvx will not trigger an event. Instead it will return an error message with the error code&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BLE_ERROR_GATTS_SYS_ATTR_MISSING compared to the event&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BLE_GATTS_EVT_SYS_ATTR_MISSING which will be generated in case the peer tries to read a system attribute handle.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230585?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 11:57:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0d69985-8c78-4431-a1ea-4936269494aa</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;There is a lot to filter through here. I will need to change my central to get back to testing these situations. Because of the problem, I have added code in my central that writes CCCDs EVERY connection, bonded or not, which is not ideal. However, there are health devices in the field which also have this bug.&lt;/p&gt;
&lt;p&gt;The problem with doing the &amp;#39;set&amp;#39; and &amp;#39;get&amp;#39; calls pre-connection is that the calls themselves require a connection handle which you don&amp;#39;t get until a connection event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I know the first pass at doing this I had my set and get calls in the BLE_ERROR_GATTS_SYS_ATTR_MISSING event handler. But calling the sd_ble_gatts_hvx did not signal the event and the central did not receive the indications/notification.&amp;nbsp;So I gave up that approach a long time ago and went for the setting during the connection event.&amp;nbsp;Interestingly, when I read back what I set, it looks good.&lt;/p&gt;
&lt;p&gt;I am at an IHE connectathon at the moment so am a little tied when it comes to further testing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230570?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2020 11:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b03e56f2-e929-4424-8805-02cc5eb508a4</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Yes, you are correct. The peer should not have to re-set the CCCD&amp;#39;s or perform service discovery on a reconnect when it is bonded.&lt;/p&gt;
&lt;p&gt;However I am a bit confused, as you say you do not get the &lt;span&gt;BLE_ERROR_GATTS_SYS_ATTR_MISSING event? But is the peer actually trying to read something in this case?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also in case you call sd_ble_gatts_hvx, you can get an BLE_ERROR_GATTS_SYS_ATTR_MISSING error message. This is also a case where you need to set the system attribute.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, since this is serialization. Can you collect the content using system attribute get command, first before esthablishing a connection at all, then on disconnect. And then again after setting them after reestablishing the bond. Just want to check that it is actually updated during the connection and that the last get matches what you received on disconnect.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230400?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 14:58:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a8e0f84-3474-46d6-a757-706d990defe9</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Pairing&amp;nbsp;is not the problem.I have no problems&amp;nbsp;with pairing or encryption on a reconnect. The problem is saving the &amp;#39;enabled&amp;#39; state of the descriptors. On the first time connect, the peer pairs and then sets the CCCDs for indications or notifications (as needed). I save that information according to the documentation. On a reconnect I restore it according to the documentation. As I understand it, the peer should NOT have to re-set the CCCDs. But if the peer does not reset the CCCDs, no data will be sent and I get the above errors. So either my understanding of the pairing/bonding procedure is incorrect, or something is wrong with the documentation on how to restore the&amp;nbsp;CCCD data.&lt;/p&gt;
&lt;p&gt;I guess I should add that when following the sequence diagram that you mention I never get the&amp;nbsp;BLE_GATTS_EVT_SYS_ATTR_MISSING event. I submitted a ticket on that some time ago, but have received no resolution. So I am assuming that approach (as in the sequence diagram) does not work and I am trying to do what is done in the handling of that event in the connection event. I have long given up on the&amp;nbsp;&lt;span&gt;BLE_GATTS_EVT_SYS_ATTR_MISSING event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/54039/why-don-t-i-get-a-ble_gatts_evt_sys_attr_missing-event/223027#223027"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/54039/why-don-t-i-get-a-ble_gatts_evt_sys_attr_missing-event/223027#223027&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/230366?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2020 13:35:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73ac6150-45ac-4fbf-b490-ec09b67beda4</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately we do not have a bonding example for the pc-ble-driver. However serialization uses the same softdevice calls as the sdk does. In the SDK the Peer manager will create an event (PM_EVT_BONDED_PEER_CONNECTED) on connection that is forwarded to the gatts_cache_manager. This event will call a function local_db_apply_in_evt ( this will call gscm_local_db_cache_apply) that eventually results in sd_ble_gatts_sys_attr_set being called. Look at gatts_cache_manager.c:218&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/228300?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 09:29:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b3d12a3-5d85-4dfc-9494-b67c24eb318a</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;There is no such support for the ble-pc-driver. Everything is based upon sd_* calls and that is all I have at my disposal. Besides, according to the documentation, what I am doing should work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Proper way to handle a bonded reconnect</title><link>https://devzone.nordicsemi.com/thread/228289?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 08:56:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd64f101-6d41-473f-b478-00e4d05de2bc</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;First I just want to say that I am sorry for the late answer, we have been catching up on backlog from the Holidays.&lt;/p&gt;
&lt;p&gt;Second how come you are not using the peer manager (&lt;span&gt;&lt;a title="Architecture" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_pm_architecture.html?cp=7_1_3_2_7_0"&gt;Architecture&lt;/a&gt;&lt;/span&gt;)? this SDK module would handle these things for you. If you take a look at the gatts_cache_manager module in our SDK you can see how we handle these attributes. More specifically the gscm_local_db_cache_apply function.&lt;/p&gt;
&lt;p&gt;If you are making your own &amp;quot;Peer manager&amp;quot;: Did you see the Message sequence charts in our documentation?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a title="GATTS System Attributes Handling: Bonded Peer" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/group___b_l_e___g_a_t_t_s___s_y_s___a_t_t_r_s___b_o_n_d_e_d___p_e_e_r___m_s_c.html?cp=4_5_2_1_2_4_3_16"&gt;GATTS System Attributes Handling: Bonded Peer&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a title="GATTS System Attributes Handling: Unknown Peer" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.0.1/group___b_l_e___g_a_t_t_s___s_y_s___a_t_t_r_s___u_n_k___p_e_e_r___m_s_c.html?cp=4_5_2_1_2_4_3_17"&gt;GATTS System Attributes Handling: Unknown Peer&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>