<?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>About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6953/about-gatt-server-context-in-hid-mouse-keyboard-example</link><description>Hi, 
 Sorry if these are silly questions but I&amp;#39;ve tried some searchings and still cannot figure out the answers for the questions below 
 
 
 What is GATT Server Context? What is the data inside it specifically? 
 
 
 What is the purpose of saving</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 May 2015 09:27:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6953/about-gatt-server-context-in-hid-mouse-keyboard-example" /><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24513?ContentTypeID=1</link><pubDate>Wed, 27 May 2015 09:27:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c376760-bdae-471b-a58c-7357de6159e1</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;As I mentioned in the original post, you are required to get/set the system attributes for bonded devices only. Deleting/forgetting the bond AND the system attributes is allowed, but confuses the peer and might need manual removal from the peer. Deleting only one of the two is a spec violation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24512?ContentTypeID=1</link><pubDate>Tue, 26 May 2015 23:24:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1938758-adca-4fc7-80f7-b9007b8c2285</guid><dc:creator>chd</dc:creator><description>&lt;p&gt;Hi Ulrich, could you please give me some information about the need of storing and applying &lt;strong&gt;gatts_context&lt;/strong&gt; to the system using &lt;strong&gt;sd_ble_gatts_sys_attr_set&lt;/strong&gt; function?&lt;/p&gt;
&lt;p&gt;As my observation, when I reconnect to a previously bonded device, there seems to be no problem if I pass a NULL pointer to &lt;strong&gt;sd_ble_gatts_sys_attr_set&lt;/strong&gt; function:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Everything still work fine even when my device switches the connection back and forth between its bonded peers (e.g. bond with peer 1 -&amp;gt; disconnect -&amp;gt; bond peer 2 -&amp;gt; disconnect -&amp;gt; reconnect with peer 1, ...) as long as I call the &lt;strong&gt;sd_ble_gatts_sys_attr_set&lt;/strong&gt; upon &lt;strong&gt;BLE_GAP_EVT_CONN_SEC_UPDATE&lt;/strong&gt; event (NULL pointer as parameter)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24510?ContentTypeID=1</link><pubDate>Tue, 12 May 2015 14:07:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e04b40-f138-4777-8bc7-4a03625c9d15</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;After reading the spec, it does not explicitly mention deleting the bond when a rejection to re-encryption occurs. It only specifies to &amp;quot;abort the procedure&amp;quot;. I think in cases where the bond is lost, you will have to manually delete the bond from the iPhone to make it re-encrypt.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24511?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 17:06:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16b5ac48-1426-4498-9f97-cdf213c0b08f</guid><dc:creator>chd</dc:creator><description>&lt;p&gt;Is it the function call sd_ble_gap_sec_info_reply(m_conn_handle, NULL, NULL) that you&amp;#39;re mentioning? If it is, the peer (an iPhone in my case) will still keep the connection, but it&amp;#39;s unencrypted. As my application uses HID services that require encryption, doing so will make it got stuck with this iPhone (whenever I disconnect from my device&amp;#39;s side, iPhone will automatically request a reconnecting if it see my device&amp;#39;s advertising and get stuck in this unencrypted link again!)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24509?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 01:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8768282-e8e4-40f5-a204-f0fbb3c115d3</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;To my understanding, it should send a negative reply if you provide only null-pointers to the security fields of sec_info_reply().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24508?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 00:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d06d38e-8d63-4579-b4b5-287c3cc895e8</guid><dc:creator>chd</dc:creator><description>&lt;p&gt;Thank you for the swift response.
I understand that sd_ble_gatts_sys_attr_set function is used to apply the gatt server context. But how about the bond context or encryption keys? When does it get applied? I mean, I only have the instance of it from persistent memory, but I dont see any function to apply it to the stack.&lt;/p&gt;
&lt;p&gt;One more question, I already asked a &lt;a href="https://devzone.nordicsemi.com/question/37204/how-to-tell-the-host-to-clear-and-do-all-the-bonding-setup-again/"&gt;question&lt;/a&gt; about how to setup the paring/bonding again if one of the two devices lose the encryption info. This seems to be impossible as per a Nordic employee answered me but as you said that we can do this by sending a &amp;quot;Pin or key missing&amp;quot;, I&amp;#39;m really confused now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About GATT Server Context in HID mouse/keyboard example</title><link>https://devzone.nordicsemi.com/thread/24507?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 22:42:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:357c65a3-2a60-488b-a195-27fc6bd7b069</guid><dc:creator>Ulrich Myhre</dc:creator><description>&lt;p&gt;For bonded devices, you are required to remember the exchanged keys and the peer&amp;#39;s &amp;quot;preferences&amp;quot; (i.e. GATT CCCD states like &amp;quot;notification enabled&amp;quot;) shall be remembered between connections. This means that if a previously bonded device connects to you, you should be able to restore all the CCCD states as they were when you last communicated (this is done with sd_ble_gatts_sys_attr_set) and encrypt with the LTK received from earlier. I am not very familiar with the HID example, but I assume the two contexts refer to these two things. The GATT Server Context will contain every handle + value for each CCCD and the Bond Context I presume contain the encryption keys.&lt;/p&gt;
&lt;p&gt;Not remembering the encryption keys will lead to a new pairing happening each time, and might confuse the peer if you do not send a &amp;quot;Pin or key missing&amp;quot; response to the security key request (which should delete the bond on the peer side). Not remembering the CCCD states between connections with a bonded device is a spec violation, and will lead to interoperability problems down the road.&lt;/p&gt;
&lt;p&gt;Forgetting both the encryption keys and the CCCD context is allowed if you respond with &amp;quot;Pin or Key Missing&amp;quot;, but this leads to a really slow ramp-up time. The bonding procedure exchanges a minimum of 6 packets + 1-2 for each key specified. It is also not possible to use IRK-based white-listing or Privacy 1.1/1.2 if you do not remember the Identity Resolving Key of your peer.&lt;/p&gt;
&lt;p&gt;So these contexts are needed for HID, and while losing both is fine from a &amp;quot;What&amp;#39;s allowed&amp;quot; perspective, it will really hurt power usage, latency and interoperability. This could legitimately happen if the device is restored to factory settings or lose power before saving the contexts. Losing only one of them is not allowed however.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>