<?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>Pairing &amp;amp; Bonding happens even when the client&amp;#39;s iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42978/pairing-bonding-happens-even-when-the-client-s-iocap-is-no_io_caps</link><description>I have a ble server with display developed for passkey security. It works fine when the Master (i.e. client) is set to have Keyboard input capability, which is good. 
 The problem is that when the client is set to have no_io_caps, the pairing and bonding</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Feb 2019 13:53:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42978/pairing-bonding-happens-even-when-the-client-s-iocap-is-no_io_caps" /><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/169087?ContentTypeID=1</link><pubDate>Fri, 01 Feb 2019 13:53:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:192f1cdb-dc19-42a9-aa43-5cd917959bc7</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;Here&amp;#39;s the trace file.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/iphone_5F00_BLE_5F00_SC_5F00_Connect.pcapng"&gt;devzone.nordicsemi.com/.../iphone_5F00_BLE_5F00_SC_5F00_Connect.pcapng&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/169034?ContentTypeID=1</link><pubDate>Fri, 01 Feb 2019 11:27:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ee00c3c-44d0-4027-aa90-25763c0bd9d3</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;IT IS WORKING!!!&amp;nbsp; The following is what I did:&lt;br /&gt;&lt;br /&gt;I already had PM_LESC_ENABLED set before.&amp;nbsp; The extra few lines in idle_state_handle() fixes it.&amp;nbsp; I am so glad that I do not have to deal with the key request myself. &lt;br /&gt;&lt;br /&gt;The extra code for BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST &amp;amp; BLE_GAP_EVT_CONN_PARAM_UPDATE is unnecessary, as I believe the peer manager should already handle these.&lt;br /&gt;&lt;br /&gt;For the initial pairing/bonding, it took over 10 seconds.&amp;nbsp; Is that normal?&amp;nbsp;&amp;nbsp; Once bonded, connecting is fast.&lt;br /&gt;&lt;br /&gt;Again, thanks for your amazing knowledge and patience.&amp;nbsp; Nordic&amp;rsquo;s customer support is always exceptional.&lt;br /&gt;&lt;br /&gt;I have attached the iPhone trace for your reference.&amp;nbsp;&amp;nbsp; I am not sure if it is really connecting using LE secure connection.&amp;nbsp; It&amp;rsquo;s not something I care about anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/169023?ContentTypeID=1</link><pubDate>Fri, 01 Feb 2019 10:21:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1074796-3708-4508-8249-1b90152e3687</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Joseph,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Q1:there is a &lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/group__nrf__ble__lesc"&gt;LESC module&lt;/a&gt; in the nRF5x SDK v15.2.0 that handles the LESC events for you and is integrated in the PM manager. I recommend taking a look at at the&amp;nbsp;&lt;a href="https://www.nordicsemi.com/DocLib/Content/SDK_Doc/nRF5_SDK/v15-2-0/ble_sdk_app_multirole_lesc"&gt;Experimental: LE Secure Connections Multirole Example&lt;/a&gt;&amp;nbsp;in the SDK.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Add&amp;nbsp;nRF5_SDK_15.2.0_9412b96\components\ble\peer_manager\nrf_ble_lesc.c to your project and include&amp;nbsp;#include &amp;quot;nrf_ble_lesc.h&amp;quot; in main.c&lt;/p&gt;
&lt;p&gt;You also need to set PM_LESC_ENABLED to 1 in sdk_config.h. If this isnt present in you sdk_config file, then simply add the following snippet to the&amp;nbsp;Peer Manager section&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;q&amp;gt; PM_LESC_ENABLED  - Enable/disable LESC support in Peer Manager.
 

// &amp;lt;i&amp;gt; If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space.

#ifndef PM_LESC_ENABLED
#define PM_LESC_ENABLED 1
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You also need to add&amp;nbsp;nrf_ble_lesc_request_handler to the idle_state_handler() function in main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void idle_state_handle(void)
{
    ret_code_t err_code;
    
    err_code = nrf_ble_lesc_request_handler();
    APP_ERROR_CHECK(err_code);
    
    if (NRF_LOG_PROCESS() == false)
    {
        nrf_pwr_mgmt_run();
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Q2: Could you attach the trace of the communication between your iPhone and the NRF52832? I would like to see if the pairing request sent from the iPhone sets the Secure Connection Flag. As stated previously b&lt;span&gt;oth sides must state that they support LESC, otherwise the paring will be performed with the common denominator in terms of supported features.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168938?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 17:40:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82595aae-3214-4ea3-8b3a-56eed9a8db55</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;Thanks for the additional info.&amp;nbsp; Added what you suggested, but it didn&amp;#39;t help.&lt;/p&gt;
&lt;p&gt;After further investigation, I now believe the problem is caused by ESP32 (i.e. BLE client)&amp;#39;s request for &amp;quot;DH Key Check&amp;quot;, which translates to BLE_GAP_EVT_LESC_DHKEY_REQUEST in nRF.&amp;nbsp; The process dies because nRF side didn&amp;#39;t respond to this DH Key request.&lt;/p&gt;
&lt;p&gt;A few questions:&lt;/p&gt;
&lt;p&gt;1. Am I supposed to handle the request explicitly myself?&lt;/p&gt;
&lt;p&gt;2. For comparison, I traced connection to the NRF using nRF connect from my iPhone.&amp;nbsp; It worked fine.&amp;nbsp; But strangely, I did not see any DHKEY Request during the handshake.&amp;nbsp; Why is it different?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Based on the client about BLE_GAP_EVT_LESC_DHKEY_REQUEST, I found some code from one of the NFC examples that generates a reply to the DH Key request that look something like this:&lt;/p&gt;
&lt;pre&gt;        case BLE_GAP_EVT_LESC_DHKEY_REQUEST:
        {
            // Buffer peer Public Key because ECC module arguments must be word aligned.
            memcpy(&amp;amp;m_lesc_peer_pk.pk[0],
                   &amp;amp;p_ble_evt-&amp;gt;evt.gap_evt.params.lesc_dhkey_request.p_pk_peer-&amp;gt;pk[0],
                   BLE_GAP_LESC_P256_PK_LEN);

            // Compute D-H key.
            err_code = ecc_p256_shared_secret_compute(&amp;amp;m_lesc_sk.pk[0],
                                                      &amp;amp;m_lesc_peer_pk.pk[0],
                                                      &amp;amp;m_lesc_dhkey.key[0]);
            APP_ERROR_CHECK(err_code);

            // Reply with obtained result.
            err_code = sd_ble_gap_lesc_dhkey_reply(m_conn_handle, &amp;amp;m_lesc_dhkey);
            APP_ERROR_CHECK(err_code);
        } break;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, I have yet to be able to try it yet, as it requires me to build the external micro-ecc library, which seems really complicated. It&amp;#39;s getting late, I will probably try it more tomorrow.&amp;nbsp; But, before I sink more time into this, I want to make sure I am on the right track.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Joseph&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168651?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 10:06:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14aad4b6-5641-4b01-bafc-ee49695906de</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;I took a look at the trace and in terms of LESC support its all good, both sides states that they support LESC in the pairing request/response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which SDK version are you using ?&lt;/p&gt;
&lt;p&gt;At least in SDK v15.2.0 you will need to respond to the&amp;nbsp;BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST event by adding the following snippet to&amp;nbsp;ble_evt_handler&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
{
    NRF_LOG_DEBUG(&amp;quot;Received BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST&amp;quot;);

    err_code = sd_ble_gap_conn_param_update(m_conn_handle,
        &amp;amp;p_gap-&amp;gt;params.conn_param_update_request.conn_params);

    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;Failure to update connection parameter request: 0x%x&amp;quot;, err_code);
    }

    APP_ERROR_CHECK(err_code);
} break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can also add handling of the&amp;nbsp;BLE_GAP_EVT_CONN_PARAM_UPDATE event, which is generated when the update is finished.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; case BLE_GAP_EVT_CONN_PARAM_UPDATE:
{
    NRF_LOG_DEBUG(&amp;quot;Received BLE_GAP_EVT_CONN_PARAM_UPDATE&amp;quot;);

    ble_gap_conn_params_t const * p_conn =
        &amp;amp;p_gap-&amp;gt;params.conn_param_update.conn_params;

    NRF_LOG_DEBUG(&amp;quot;max_conn_interval: %d&amp;quot;, p_conn-&amp;gt;max_conn_interval);
    NRF_LOG_DEBUG(&amp;quot;min_conn_interval: %d&amp;quot;, p_conn-&amp;gt;min_conn_interval);
    NRF_LOG_DEBUG(&amp;quot;slave_latency: %d&amp;quot;,     p_conn-&amp;gt;slave_latency);
    NRF_LOG_DEBUG(&amp;quot;conn_sup_timeout: %d&amp;quot;,  p_conn-&amp;gt;conn_sup_timeout);
} break;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168632?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 09:10:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:274d4545-e1bf-42c5-8665-4f2cd2c97881</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;Regarding LESC connection, thanks for the useful suggestion of using nRF Sniffer to capture the connection.&amp;nbsp; It looks like towards the end, after Key Exchange, the MASTER (i.e. ESP32 as client) sends a LL_CONNECTION_UPDATE_REQ.&amp;nbsp; But, the nrf device (Server) doesn&amp;#39;t respond with anything. Until 28 seconds later, the nrf sends a LL_TERMINATE_IND.&lt;/p&gt;
&lt;p&gt;Is the nRF device supposed to respond to a LL_CONNECTION_UPDATE_REQ command, or not?&amp;nbsp; Can you tell what the problem may be?&lt;/p&gt;
&lt;p&gt;I have attached the capture from nRF Sniffer.&amp;nbsp; You may use this as filter to see the essential packets:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; btle.length!=0 &amp;amp;&amp;amp; !btle.advertising_header&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/LeSecureConnectFail.pcapng"&gt;devzone.nordicsemi.com/.../LeSecureConnectFail.pcapng&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168493?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 14:25:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b461c22-502b-4e6e-afbd-537af5b93982</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Both sides must state that they support LESC, otherwise the paring will be performed with the common denominator in terms of supported features. So we need to verify if the ESP32 sets LESC as a suppported feature during the connection preocedure.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you use the &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer/Download#infotabs"&gt;nRF Sniffer v2&lt;/a&gt;&amp;nbsp;to capture a on-air-trace of the communication between the ESP32 and the nRF52?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168419?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 10:24:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67b84f8e-1a5f-4953-830f-f5a2396118c8</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;I am using an ESP32 as BLE client.&amp;nbsp; Trying to get level 4 security (LE security) to work.&amp;nbsp; Even though I set:&lt;/p&gt;
&lt;pre&gt;#define SEC_PARAM_LESC                  1 &lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;p&gt;It seems like my ESP32 is still authenticated without LE SC.&amp;nbsp; Using peer manager, are there some extra code I have to add to enable LE Secure Connection on NRF side?&lt;/p&gt;
&lt;p&gt;Thanks again,&lt;/p&gt;
&lt;p&gt;Joseph&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168401?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 09:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3db43dfb-9858-4008-b341-926fc76dfd67</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Joseph,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the&amp;nbsp;&lt;span&gt;0x3002 error code is&amp;nbsp;BLE_ERROR_INVALID_CONN_HANDLE,&amp;nbsp; which is listed in the function brief of sd_ble_gap_disconnect() in ble_gap.h&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Disconnect (GAP Link Termination).
 *
 * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
 *          with a @ref BLE_GAP_EVT_DISCONNECTED event.
 *
 * @events
 * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.}
 * @endevents
 *
 * @mscs
 * @mmsc{@ref BLE_GAP_CONN_MSC}
 * @endmscs
 *
 * @param[in] conn_handle Connection handle.
 * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
 *
 * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
 * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
 */
SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You solve the issue by wrapping the code in the&amp;nbsp;&lt;span&gt;PM_EVT_CONN_SEC_FAILED&amp;nbsp;case&amp;nbsp;in a if statment that checks if the conn_handle is valid, i.e.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if(m_conn_handle !=BLE_CONN_HANDLE_INVALID)
{
    err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    if (err_code != NRF_ERROR_INVALID_STATE)
    {
        APP_ERROR_CHECK(err_code);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It is possible to block connection requests at the Link Layer, i.e. that the SoftDevice rejects connection request, but this requires that a white-list is used, see&amp;nbsp;&lt;a href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S132/v6-1-0/group_ble_gap_functions#gacdd2dd570000368dd5c29d799c198779"&gt;sd_ble_gap_whitelist_set&lt;/a&gt;&lt;span&gt;&amp;nbsp;in the SD API doc.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As for the security level, as stated in the comments Security Level 4 requires support for LESC (LE Secure Connections)on both sides of the link, i.e. both sides must be Bluetooth v4.2 or higher. So if you set the security level requirement to 4 for the characteristics, then a smartphone with a BLE v4.1 stack or below will not be able to access the characteristics. Level 4 is of course more secure, but the con is that not all smartphones support it. With level 3 you should not have any issues with the Bluetooth version.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168357?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 04:39:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c8294ae-fbe2-4c9e-a305-d4e25af85c7d</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;And, about security permission of the characteristics, would you not recommend level 4 instead of level 3?&amp;nbsp; What is the difference?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168356?ContentTypeID=1</link><pubDate>Tue, 29 Jan 2019 04:23:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f5d4f14-4222-4344-8c6e-2e089584ab7b</guid><dc:creator>joeyh</dc:creator><description>&lt;p&gt;Great.&amp;nbsp; This is exactly the answer I am looking for.&lt;/p&gt;
&lt;p&gt;But, there is still a problem.&amp;nbsp; Even though I replied to the client with &lt;span&gt;BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP&lt;/span&gt;, the client may still choose to ignore the rejection, and continue retrieving services and characteristics, etc.&amp;nbsp; Wouldn&amp;#39;t it be better if I close the connection immediately at the point of replying to secure parameters?&lt;/p&gt;
&lt;p&gt;I tried adding these lines immediately after the reply:&lt;/p&gt;
&lt;pre&gt;            err_code = sd_ble_gap_disconnect(p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);&lt;/pre&gt;
&lt;pre&gt;            APP_ERROR_CHECK(err_code);&lt;/pre&gt;
&lt;p&gt;This closes the connection fine, but after that, the pm event handler gets a PM_EVT_CONN_SEC_FAILED event.&amp;nbsp; And, the firmware dies in the &amp;quot;if&amp;quot; statement below:&lt;/p&gt;
&lt;pre&gt;            err_code = sd_ble_gap_disconnect(m_conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            if (err_code != NRF_ERROR_INVALID_STATE)
            {
                APP_ERROR_CHECK(err_code);
            }&lt;/pre&gt;
&lt;p&gt;It return an error code of 0x3002.&amp;nbsp; I guess you are not supposed to call sd_ble_gap_disconnect() when we don&amp;#39;t have a connection.&amp;nbsp; I could probably ignore this error.&amp;nbsp; But, it would be good to know the proper way to handle this.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Joseph&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pairing &amp; Bonding happens even when the client's iocap is no_io_caps</title><link>https://devzone.nordicsemi.com/thread/168172?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 09:34:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:064b87c5-0ca8-4a0c-9446-2f061e67e814</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi J&lt;span&gt;oseph,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes, if one of the peers do not have IO capabilities, then Just Works pairing will be used, see table 2.8 in the&amp;nbsp;BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H, page 2313.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When the Central ( Link Master) initiates the Pairing process by sending a Pairing request, you will receive a BLE_GAP_EVT_SEC_PARAMS_REQUEST event on the Peripheral side. With this event you will get an&amp;nbsp; ble_gap_sec_params_t event struct that contains the IO caps of the central .&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So you could examine the&amp;nbsp;io_caps field upon receiving the event in the the BLE event handler in main.c and see it its set to BLE_GAP_IO_CAPS_NONE. If the IO caps are set to&amp;nbsp;BLE_GAP_IO_CAPS_NONE, then you can reject pairing by calling&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;sd_ble_gap_sec_params_reply with sec_status set to&amp;nbsp;BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would also like to add that you can set the a security level requirement for each characteristic to security level 3 so that even though a device is able to pair and bond using Just works (Security Level 2), the central will not be able to write /read the characeristics unless it re-pairs with the appropriate security level. See&amp;nbsp;BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part C, page 2019 , table 5.8.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In the nRF5x SDK, this is done by setting the ble_gap_conn_sec_mode_t read_perm/&amp;nbsp;write_perm fields in the&amp;nbsp;ble_gatts_attr_md_t struct that is passed to&amp;nbsp;sd_ble_gatts_characteristic_add() to the desired security level&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief GAP connection security modes.
 *
 * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
 * Security Mode 1 Level 1: No security is needed (aka open link).\n
 * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
 * Security Mode 1 Level 3: MITM protected encrypted link required.\n
 * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n
 * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
 * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
 */
typedef struct
{
  uint8_t sm : 4;                     /**&amp;lt; Security Mode (1 or 2), 0 for no permissions at all. */
  uint8_t lv : 4;                     /**&amp;lt; Level (1, 2, 3 or 4), 0 for no permissions at all. */

} ble_gap_conn_sec_mode_t;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Bjørn&lt;/p&gt;
&lt;p&gt;&lt;span&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>