<?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>Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99893/creating-a-heart-rate-service-peripheral-example-application-that-requires-mode-1-level-3-security</link><description>I am using SDK v15.3 and would like to modify the peripheral heart rate service example to require the Central to establish mode 1, level 3 security. I am undecided on whether it will be numeric comparison, passkey or OOB, but would like to evaluate each</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Jun 2023 17:24:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99893/creating-a-heart-rate-service-peripheral-example-application-that-requires-mode-1-level-3-security" /><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428829?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 17:24:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef7bed2b-e41c-40c7-8875-3bae3c572e3b</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;You can disregard the last question...I have figured out the issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can consider this question closed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428819?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2023 16:32:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed00ec70-8c14-4bc8-a829-8b42b7c5f005</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I have everything working now...thanks for the assistance.&lt;/p&gt;
&lt;p&gt;I am running into an issue whenever an initial bonding operation occurs unrelated to the central connection with the heart rate service peripheral. My implementation also supports a single peripheral connection which is interacts with the central connection in the following way:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Peripheral advertising is enabled by default&lt;/p&gt;
&lt;p&gt;a. Initiating advertising first sets the Tx power (sd_ble_gap_tx_power_set), updates the advertising message (sd_ble_gap_adv_set_configure) and finally starts the advertising (ble_advertising_start)&lt;/p&gt;
&lt;p&gt;2. Upon starting to scan for heart rate service peripherals, the peripheral advertising is stopped (sd_ble_gap_adv_stop)&lt;/p&gt;
&lt;p&gt;3. After connecting, bonding and enabling the heart rate service notification, the peripheral advertising is enabled again.&lt;/p&gt;
&lt;p&gt;The above sequence worked perfectly prior to adding the bonding functionality. It works when connecting to an already bonded heart rate peripheral. However, it now fails reliably after step 3 above as follows:&lt;/p&gt;
&lt;p&gt;...when calling sd_ble_gap_adv_set_configure() it returns&amp;nbsp;NRF_ERROR_INVALID_STATE (see code snippet below). It doesn&amp;#39;t matter whether the third parameter is NULL or not. I have confirmed that advertising is definitely being stopped and that I am calling the below function once prior to re-starting adverstising.&lt;/p&gt;
&lt;p&gt;ble_gap_adv_data_t adv_data;&lt;br /&gt; memcpy(&amp;amp;adv_data, p_profile-&amp;gt;padvertising-&amp;gt;p_adv_data, sizeof(ble_gap_adv_data_t));&lt;br /&gt; if (p_profile-&amp;gt;padvertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_IDLE)&lt;br /&gt; {&lt;br /&gt; result = sd_ble_gap_adv_set_configure(&amp;amp;p_profile-&amp;gt;padvertising-&amp;gt;adv_handle, &amp;amp;adv_data, &amp;amp;p_profile-&amp;gt;padvertising-&amp;gt;adv_params);&lt;br /&gt; if (result != NRF_SUCCESS)&lt;br /&gt; asm(&amp;quot;nop&amp;quot;);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; result = sd_ble_gap_adv_set_configure(&amp;amp;p_profile-&amp;gt;padvertising-&amp;gt;adv_handle, &amp;amp;adv_data, NULL);&lt;br /&gt; if (result != NRF_SUCCESS)&lt;br /&gt; asm(&amp;quot;nop&amp;quot;);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;I am willing to create a separate support question if that is desired.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428336?ContentTypeID=1</link><pubDate>Wed, 31 May 2023 08:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65b6da4a-c6ad-4796-abfa-f257eeb0ae84</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;No, it is not like that. If the central initiate&amp;nbsp;pairing/bonding of the link, and the peripheral already have a bond with this central, you will get the&amp;nbsp;PM_EVT_CONN_SEC_CONFIG_REQ event on the peripheral side. If you allow re-pairing by calling&amp;nbsp;pm_conn_sec_config_reply() as shown in the mentioned post, a new pairing procedure will start. If not, the peripheral will send&amp;nbsp;LL_REJECT_IND. If the device that initiated bonding (central in this case) is an nRF, you will get a PM_EVT_CONN_SEC_FAILED event at this point (when it&amp;nbsp;has received the&amp;nbsp;LL_REJECT_IND).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428240?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 15:04:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0106e267-48db-4c26-9ad1-6a4c68098945</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;As described in the &amp;quot;post&amp;quot; you cite...will the&amp;nbsp;&lt;span&gt;LL_REJECT_IND sent by the peripheral trigger the&amp;nbsp;&lt;/span&gt;&lt;span&gt;PM_EVT_CONN_SEC_CONFIG_REQ, or more specifically, how is the central informed the the LL_REJECT_IND has been sent (this is received by the soft device, but I don&amp;#39;t see how it bubbles up)?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428237?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:58:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5a7f063-f3c0-4ab7-9dbc-10379ca759fd</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry, forgot the context over the weekend. The default behavior of the nRF5 SDK as well&amp;nbsp; is to reject re-pairing attempts for the reasons I explained in my previous points. You can allow re-pairing on that device too though, by doing as described in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/52034/sdk-15-3-pairing-issue/212756"&gt;this post&lt;/a&gt;.&lt;/p&gt;
[quote user="mlyonupdesigns"]What can I do from the central side if I have lost the bonding information but the peripheral has not? I&amp;#39;m just trying to understand what the spec says should occur in these instances.[/quote]
&lt;p&gt;The spec does not describe how this should be handled, it is up to the product designer. Generally, it is not a good idea to allow re-pairing. But&amp;nbsp;for many small embedded devices it is needed. In the case you describe here, where the bonding information is lost on the central, the only way to recover is if the peripheral either has some mechanism to delete bonding data (for instance with a button press or similar), or if you allow re-pairing. It is commonly done, but as it is a potential security issue, it is prohibited by default in both the nRF5 SDK and nRF Connect SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428206?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 14:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07a362af-65e2-42b8-b1aa-207a86c3b38a</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;The BT_SMP_ALLOW_UNAUTH_OVERWRITE doesn&amp;#39;t pertain to SDK 15.3 I don&amp;#39;t believe (at least I don&amp;#39;t see any reference to that type of functionality).&lt;/p&gt;
&lt;p&gt;Specifically, I purposely deleted the bonding information from the peripheral to see the behavior so I&amp;#39;m trying to understand what the correct procedure is for forcing a re-bonding if either the central or peripheral loses the non-volatile storage holding the bonding information. Obviously, in our app on the central side I can delete the peer information (e.g., pm_peers_delete) which should force a re-bonding. What can I do from the central side if I have lost the bonding information but the peripheral has not? I&amp;#39;m just trying to understand what the spec says should occur in these instances.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/428194?ContentTypeID=1</link><pubDate>Tue, 30 May 2023 13:47:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6edb99d9-7b93-4ca1-90b8-3d1d28c05496</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The default behavior is to reject pairing attempts from peers where there already exists a bond. This is for security reasons, as if you allow that, it means that an attacker can spoof the address of the peer you are bonded with, and replace that bond. It is however possible to allow re-pairing by &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE"&gt;BT_SMP_ALLOW_UNAUTH_OVERWRITE&lt;/a&gt;&amp;nbsp;if you want to. Sometimes this may be required from a usability perspective, but it is important to be aware of the security implications&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427907?ContentTypeID=1</link><pubDate>Sat, 27 May 2023 08:22:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5464eed-32da-4d43-93ae-bb60e2deb310</guid><dc:creator>Emil Lenngren</dc:creator><description>&lt;p&gt;Why not require mode 1 level 4 instead? The difference to level 3 is that level 4 requires LE Secure Connections, which is much more secure than Legacy Pairing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427872?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 15:28:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be5dd994-6c60-4af7-875a-0f35eaf941c1</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I did have a follow up question related to central and peripheral bonding data becoming of &amp;quot;lost&amp;quot;. If the central has it&amp;#39;s bonding information, but the peripheral no longer does.&lt;/p&gt;
&lt;p&gt;From my BT capture I see that the central sends a LL_ENC_REQ and the peripheral responds with LL_ENC_RSP (which must have something in it that doesn&amp;#39;t match. The&amp;nbsp;peripheral then responds with LL_REJECT_IND. I don&amp;#39;t see this handled in the SDK and wonder what is the correct action?&lt;/p&gt;
&lt;p&gt;Similarly, if the central no longer has the bonding information, but the peripheral does what is the expected behavior?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427863?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 15:02:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c12a6a4c-23a6-4da2-8de9-ee5065fe4904</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;Once I fixed the behavior of the ble_app_hrs example so it doesn&amp;#39;t start the application timers (application_timers_start) at start-up, but rather waits for&amp;nbsp;BLE_GAP_EVT_AUTH_STATUS event on the initial bonding or&amp;nbsp;NRF_BLE_GATT_EVT_ATT_MTU_UPDATED event on reconnection, then all worked as expected.&lt;/p&gt;
&lt;p&gt;Also stopping the application timers on a disconnect was necessary so that repeated connect/disconnect operations would work.&lt;/p&gt;
&lt;p&gt;So I think I&amp;#39;m all set. Thanks for your attention.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427803?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 12:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02e91ca9-22c1-4782-911b-b3dc77555745</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Can you share code also?&amp;nbsp;Regarding the more data bit in the last screenshot from the previous post I am not able to see much from the screenshot. Can you upload the actual trace file? Generally though, if there are empty packets with MD set, that seems odd.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427789?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 12:24:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da2a8b90-495f-4e2b-bf72-b8f24ec2c5e9</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;Here are two example logs (and call stack screen shots) from the peripheral.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_hrs_5F00_1.log"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_hrs_5F00_1.log&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_hrs_5F00_2.log"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_hrs_5F00_2.log&lt;/a&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685103848802v1.png" /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/FatalError_5F00_2.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The error being returned from heart_rate_meas_timeout_handler() is&amp;nbsp;NRF_ERROR_FORBIDDEN.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427772?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 11:35:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddcf6769-00b5-4396-a971-2d4847510391</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;The third screen shot (which I added after the original reply) shows the initial bonding capture. The first screen shot is nRF connect and the second screen shot is my application.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you comment on the &amp;quot;More Data&amp;quot; flag being set in the second screen shot?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427756?ContentTypeID=1</link><pubDate>Fri, 26 May 2023 10:59:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d18c3380-f10b-43fd-a305-49ad1100500b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see from&amp;nbsp;the second screenshot that the central is re transmitting&amp;nbsp;the LL_ENC_REQ packet, so it seems that something happened to the peripheral when you are using your central and not nRF Connect. Do you have logs from the peripheral that can tell us what happened there?&lt;/p&gt;
&lt;p&gt;Other than that, the&amp;nbsp;peripheral sent the LL_LENGTH_REQ right before the&amp;nbsp;central sent LL_ENC_REQ, but that should be OK.&amp;nbsp;There are few limitations on the order of procedures other than that only one procedure can be initiated from each side at a single time,&amp;nbsp;and as I see LL_ENC_REQ here right away, so a bond already exist. A feature exchange is normally needed for using any feature that is not mandatory, but up to this point the only non-mandatory feature is encrypting the link, but if a bond already existed that should be no problem. Do you have a sniffer trace from the first connection when the bond was established? (Or if this is the first connection, then there is something fundamentally wrong with the handling of the security as the central at least acts as if it has an existing bond).&lt;/p&gt;
&lt;p&gt;I am not able to say much more based on&amp;nbsp;these&amp;nbsp; screenshots. Can you share logs from both the peripheral and central side, and your central implementation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427561?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 14:07:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2cbd0e4-07a5-4bc5-8852-183c66c61d53</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;OK....thanks.&lt;/p&gt;
&lt;p&gt;This is the BT capture when I used nRF Connect (Android) to first bond to ble_app_hrs app (with mode 1, level 2 security required for the measurement data) and then reconnect after bonding.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685023459489v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;and this is my application (instead of nRF Connect) trying to reconnect to the ble_app_hrs app...obviously I have something wrong in&amp;nbsp; my app, but not sure what. Any ideas?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685023647252v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;I note that there is no &amp;quot;feature exchange&amp;quot; from my app...is this necessary?&lt;/p&gt;
&lt;p&gt;Also, the &amp;quot;More Data&amp;quot; flag is set in the example from my app (see Empty PDUs) which looks incorrect and may be keeping the peripheral from behaving properly. After 6 seconds the peripherals disconnects and begins advertising again.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1685043598406v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Above is the initial bonding capture&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427554?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 13:54:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0f1cde7-05b7-4cb4-bd5b-642949440996</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="mlyonupdesigns"]I assume there is nothing that precludes repeated discovery if you choose not to implement the &amp;quot;remote_db&amp;quot; functionality.[/quote]
&lt;p&gt;No, that is right. If you don&amp;#39;t store the remote database, you have to do discovery every time.&lt;/p&gt;
[quote user="mlyonupdesigns"]If repeated discovery is used, is the link encrypted first before discovery or is discovery in the clear and when encryption is enabled doesn&amp;#39;t matter?[/quote]
&lt;p&gt;It should not matter if you do service discovery before or after the link is encrypted.&lt;/p&gt;
[quote user="mlyonupdesigns"]Also, is there a peripheral example that supports mode 1, level 2 security (no MITM) out-of-the-box...preferably heart rate?[/quote]
&lt;p&gt;Not out of the box, but you only need to change the security level for the parameter(s) you don&amp;#39;t want to be accessible without mode 1 level 2 or higher, as I suggested in my initial post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427521?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 12:18:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:438ccdcd-c07b-48ff-be8c-070add0dde43</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I assume there is nothing that precludes repeated discovery if you choose not to implement the &amp;quot;remote_db&amp;quot; functionality. If repeated discovery is used, is the link encrypted first before discovery or is discovery in the clear and when encryption is enabled doesn&amp;#39;t matter?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also, is there a peripheral example that supports mode 1, level 2 security (no MITM) out-of-the-box...preferably heart rate?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427515?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 12:00:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5676dfbb-adb7-480e-8e20-a47fca66419e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Regarding database caching, that is supported in the SDK, and makes it so that repeated discovery is not needed. There are two examples in the SDK that demonstrate it: &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_ancs.html"&gt;Apple Notification Center Service (ANCS) Client Application&lt;/a&gt;&amp;nbsp;and &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_gatts_c.html"&gt;GATT Service Client Example Application&lt;/a&gt;. Search for &amp;quot;remote_db&amp;quot; in the main.c to see most of the relevant code. (These happen to be peripheral and not centrals, but they key point here is that they are GATT clients).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427510?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 11:50:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c1e7beb-ac58-4ebd-bc0a-dd04e3f3778f</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I will investigate further and come back to you.&lt;/p&gt;
&lt;p&gt;I was also curious whether the bonding operation also stores the discovered services/characteristics for the peer? If so, does this mean repeated discovery is not necessary? Can you reference which sdk element manages storing and retrieving the discovery results?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427483?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 10:53:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74b98c01-a080-4f06-afb6-a791e32d9d3f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. I am not able to find any other reasons for getting&amp;nbsp;NRF_ERROR_INVALID_STATE in this case (other than there not being any&amp;nbsp;pending request or the connection handle not being for an active connection). Can you double check that this is the error you get, and that it is from&amp;nbsp;sd_ble_gatts_exchange_mtu_reply? And which event to you get before calling it? (I am not sure, as the sniffer trace screenshot also shows a LL_LENGTH_REQ, which is not the same as a GATT length update, and for that you reply with&amp;nbsp;sd_ble_gap_data_length_update() - perhaps that is mixed up somehow in your code)?&lt;/p&gt;
&lt;p&gt;There is no obvious link between this and encrypting the link though, and even though I see in the sniffer trace that the link is about to be encrypted, this could happen in parallel (the main limitation is that there can only be one LL procedure initiated by each side at a single time, but at least form the screenshot that does not seem to be a problem). Does it help if you delay encrypting the link, just as a test? If not, perhaps you can share your code, and/or elaborate on which changes you did when this issues was introduced?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427240?ContentTypeID=1</link><pubDate>Wed, 24 May 2023 12:44:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b627d7a8-103d-4638-b3ba-9893a9ea4194</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I am using my central app for this development (not a Nordic example). This app has been used reliably for connecting to unsecure heart rate services for years. I am now attempting to introduce security for certain devices that now require it.&lt;/p&gt;
&lt;p&gt;I have confirmed that there is no conflict from multiple attempts to reply to the MTU request. You can see an image of the call stack on the nRF52832 below where the nrf_ble_gatt_on_ble_evt handler is processing the request.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1684931957539v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have also included a snippet of a BT capture showing the behavior. No replay ever appears on the link.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1684932284787v2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427184?ContentTypeID=1</link><pubDate>Wed, 24 May 2023 10:49:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24515b30-ffc4-4f7c-84f1-5fdb08903777</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_hrc.html"&gt;BLE Heart Rate Collector Example&lt;/a&gt;&amp;nbsp;supports bonding out of the box (but without MITM), so you can refer to that. You can refer to the message sequence charts in the SoftDevice specifications to see the detailed sequence diagrams for bonding on the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s332.api.v6.1.1/group___b_l_e___g_a_p___p_e_r_i_p_h___s_e_c___m_s_c.html"&gt;peripheral&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s332.api.v6.1.1/group___b_l_e___g_a_p___c_e_n_t_r_a_l___s_e_c___m_s_c.html"&gt;central&lt;/a&gt; side.&lt;/p&gt;
&lt;p&gt;Regarding the error you get on the central I do not know which example you have based this on&amp;nbsp;(as the hart rate collector already supports bonding) and what changes you have done, but generally you will get&amp;nbsp;NRF_ERROR_INVALID_STATE returned from&amp;nbsp;sd_ble_gatts_exchange_mtu_reply() if either the connection handle is invalid, or if there is no pending ATT_MTU request. Have you added code for handling this request in your application? If so, it could be that there is a conflict if, as this is normally hanled by the GATT module if that is used (components/ble/nrf_ble_gatt/nrf_ble_gatt.c). If you also handle the request in in your application, that would mean two calls to&amp;nbsp;sd_ble_gatts_exchange_mtu_reply() for a single request, which is not valid.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/427040?ContentTypeID=1</link><pubDate>Tue, 23 May 2023 19:32:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c15dd2df-a944-440d-bdac-168e6fe466c9</guid><dc:creator>mlyonupdesigns</dc:creator><description>&lt;p&gt;I found the hrm_ccd_wr_sec setting and changed it to&amp;nbsp;SEC_JUST_WORKS as a start. This resulted in an &amp;quot;Insuffcient Authentication&amp;quot; error when the Central attempted to enable the characteristic notification.&lt;/p&gt;
&lt;p&gt;I then enabled the peer manager functionality in the Central to manage the bonding process. That all worked as expected. I am now struggling with the reconnection after both Central and Peripheral have stored the bonding information. I can see that the Central successfully reaches the&amp;nbsp;sd_ble_gap_encrypt() function; however, the peripheral is sending an ATTMTU request prior to the Central enabling encryption and the Central attempts to reply but receives an&amp;nbsp;NRF_ERROR_INVALID_STATE error in response to&amp;nbsp;sd_ble_gatts_exchange_mtu_reply().&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t&amp;nbsp; changed any of the Central logic which was in place prior to supporting security, so typically the&amp;nbsp;nrf_ble_gatt_on_ble_evt() would handle the ATT requests/responses and my application event handler would just start service discovery on the CONNECT event. I suspect this has to change somehow.&lt;/p&gt;
&lt;p&gt;Can you point me to a sequence diagram that demonstrates a reconnection between bonded Central and Peripheral (and an example)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/426590?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 13:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79875836-bfc8-4a70-baea-c89ef7deaed5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In Bluetooth, the security level is set per characteristic. Referring to the Heart Rate example in nRF5 SDK 15.3, you can see that the security level of the heart rate characteristics is set in&amp;nbsp;services_init():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    // Here the sec level for the Heart Rate Service can be changed/increased.
    hrs_init.hrm_cccd_wr_sec = SEC_OPEN;
    hrs_init.bsl_rd_sec      = SEC_OPEN;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you want to use level 3,&amp;nbsp;change this to &lt;code&gt;SEC_MITM&lt;/code&gt;&amp;nbsp;intend&amp;nbsp;of &lt;code&gt;SEC_OPEN&lt;/code&gt;. With this, security level 3 is required in order to access the specific characteristics.&amp;nbsp;Note that the mode essentially means that MITM or OOB is used, so you do not need to do other changes in this part regardless of if you are using numeric comparison, passkey or OOB.&lt;/p&gt;
&lt;p&gt;The second part is to expand the example to use the MITM protection method you want to use/test. For that, you can refer to other examples and copy-past in relevant parts. For instance, ble_app_gls use passkey (with the nRF being the display), printing the passkey over UART. Which MITM method that works is depending on the I/O capabilities of your product. If it has both a keyboard and a display, you can use numeric comparison (only with LE secure connections and provided the peer also supports it). If it has a keyboard or a display, it can use passkey, provided the peer has the opposite (or both). For OOB you would typically need something application specific.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating a Heart Rate Service Peripheral Example Application That Requires Mode 1 Level 3 Security</title><link>https://devzone.nordicsemi.com/thread/426316?ContentTypeID=1</link><pubDate>Fri, 19 May 2023 12:22:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33c7ff98-c873-4925-bd22-8a03ccc646ed</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;I am sorry, but we are short staffed this week due to Public Holidays in Norway. We will be back on Monday 22nd and hope to be able to answer all incoming requests within a couple of days, depending on the backlog. I am sorry for the inconvenience.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>