<?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>MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/76889/mac-address-incrementation-pairing-issue</link><description>Hi, 
 We are testing mass pairing on our windows machines, as we have seen problems with a high number of paired devices. 
 I am able to increment the mac address by using sd_ble_gap_addr_set, and saving it in a noinit ram section, and soft reseting the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Jul 2021 09:34:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/76889/mac-address-incrementation-pairing-issue" /><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/322000?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 09:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9de9e1e-7831-4424-8879-359259d7fbe4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the update. I&amp;#39;m glad to hear that it worked! The main purpose of the IRK is to enable address resolving of &amp;#39;private resolvable&amp;#39; type BLE addresses, but it can also be used as an unique device identifier like in this case.&lt;/p&gt;
&lt;p&gt;Note that the SDK examples all use a non-resolvable random static address by default, so the IRK isn&amp;#39;t needed for address resolving anyway.&lt;/p&gt;
&lt;p&gt;Now knowing that the IRK was the culprit, I think you could have also have solved this by not exchanging the IRK during the bonding procedure. This is achieved by clearing the following bit in pm_init():&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1627378468088v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/321991?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 09:13:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed685ebc-2e36-4100-9d45-f8cea4b3bfc7</guid><dc:creator>Roiger</dc:creator><description>&lt;p&gt;Works like a charm!!!! Thanks Vidar!! Well worth the wait :)&lt;/p&gt;
&lt;p&gt;Just out of interest - what exactly is the irk?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/321974?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 08:16:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e127f375-462d-488a-b182-11b5d6b20a98</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the delayed response. Have you had any progress on this issue in the meantime? The reason for the BLE_GAP_SEC_STATUS_&lt;strong&gt;UNSPECIFIED&lt;/strong&gt; error seems to be related to the fact that the peripheral keeps re-using the same IRK (identity resolving key - is exchanged during bonding procedure). Updating the IRK along with the BLE address does the trick.&lt;/p&gt;
&lt;p&gt;Modified main() in ble_app_hid_keyboard to generate new random BLE address and IRK on startup:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for application main entry.
 */
int main(void)
{
    bool erase_bonds;
    uint32_t err_code;

    // Initialize.
    log_init();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    // Delete bonds on startup
    erase_bonds = 1;
    power_management_init();
    ble_stack_init();
    scheduler_init();
    gap_params_init();

    uint8_t random_bytes[16];
    ble_gap_addr_t addr;
    uint8_t capacity;

    do
    {
        err_code = sd_rand_application_bytes_available_get(&amp;amp;capacity);
        APP_ERROR_CHECK(err_code);
    } while (capacity &amp;lt; 16);

    err_code = sd_rand_application_vector_get(random_bytes, sizeof(random_bytes));
    APP_ERROR_CHECK(err_code);

    err_code = sd_ble_gap_addr_get(&amp;amp;addr);
    APP_ERROR_CHECK(err_code);

    // Swap out 3 of the address bytes with the random bytes to make the address unique.
    addr.addr[2] = random_bytes[0];
    addr.addr[3] = random_bytes[1];
    addr.addr[4] = random_bytes[2];

    err_code = sd_ble_gap_addr_set(&amp;amp;addr);
    APP_ERROR_CHECK(err_code);

    gatt_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    buffer_init();
    peer_manager_init();

    pm_privacy_params_t privacy_params;
    ble_gap_irk_t irk;

    memset(&amp;amp;privacy_params, 0, sizeof(privacy_params));

    privacy_params.p_device_irk = &amp;amp;irk;

    err_code = pm_privacy_get(&amp;amp;privacy_params);
    APP_ERROR_CHECK(err_code);


    //Update the local IRK
    irk.irk[2] = random_bytes[0];
    irk.irk[3] = random_bytes[1];
    irk.irk[4] = random_bytes[2];

    err_code = pm_privacy_set(&amp;amp;privacy_params);
    APP_ERROR_CHECK(err_code);
    // Start execution.
    NRF_LOG_INFO(&amp;quot;HID Keyboard example started.&amp;quot;);
    timers_start();
    advertising_start(erase_bonds);

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/319186?ContentTypeID=1</link><pubDate>Thu, 08 Jul 2021 12:53:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55cdf20e-cb51-4cb6-8adf-f24976e65009</guid><dc:creator>Karlo</dc:creator><description>&lt;p&gt;Same problem here,&lt;/p&gt;
&lt;p&gt;&amp;lt;info&amp;gt; peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 136&lt;/p&gt;
&lt;p&gt;after trying to connect on incremented mac. This is happening on a windows device, android is working fine.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x10.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Requesting to update ATT MTU to 256 bytes on connection 0x0.
&amp;lt;info&amp;gt; app: Connected
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x23.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Peer on connection 0x0 requested a data length of 251 bytes.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Updating data length to 27 on connection 0x0.
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x24.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Data length updated to 27 on connection 0x0.
&amp;lt;debug&amp;gt; nrf_ble_gatt: max_rx_octets: 27
&amp;lt;debug&amp;gt; nrf_ble_gatt: max_tx_octets: 27
&amp;lt;debug&amp;gt; nrf_ble_gatt: max_rx_time: 2120
&amp;lt;debug&amp;gt; nrf_ble_gatt: max_tx_time: 328
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x55.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Peer on connection 0x0 requested an ATT MTU of 527 bytes.
&amp;lt;debug&amp;gt; nrf_ble_gatt: Updating ATT MTU to 256 bytes (desired: 256) on connection 0x0.
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x3A.
&amp;lt;debug&amp;gt; nrf_ble_gatt: ATT MTU updated to 256 bytes on connection 0x0 (response).
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x13.
&amp;lt;debug&amp;gt; peer_manager_handler: Event PM_EVT_CONN_SEC_START
&amp;lt;debug&amp;gt; peer_manager_handler: Connection security procedure started: role: Peripheral, conn_handle: 0, procedure: Bonding
&amp;lt;debug&amp;gt; peer_manager_handler: Event PM_EVT_CONN_SEC_PARAMS_REQ
&amp;lt;debug&amp;gt; peer_manager_handler: Security parameter request
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x1A.
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x19.
&amp;lt;debug&amp;gt; peer_manager_handler: Event PM_EVT_CONN_SEC_FAILED
&amp;lt;info&amp;gt; peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 136
&amp;lt;debug&amp;gt; peer_manager_handler: Error (decoded): BLE_GAP_SEC_STATUS 0x88
&amp;lt;debug&amp;gt; nrf_sdh_ble: BLE event: 0x11.
&amp;lt;info&amp;gt; app: Fast advertising.
&amp;lt;info&amp;gt; app: Disconnected
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/318250?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 13:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08658228-0204-4f6d-889c-596f3903a2c8</guid><dc:creator>Roiger</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;br /&gt;I also tried erasing bonds before the reset, to no avail.&lt;br /&gt;We want this test to be able to happen w/o being physically connected to a debugger, so the nrjfprog option is not possible for us.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;br /&gt;Roi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/318220?ContentTypeID=1</link><pubDate>Thu, 01 Jul 2021 12:46:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80c22b9c-eb50-404c-8228-9bb2d1290cc2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Roi,&lt;/p&gt;
&lt;p&gt;I think I would probably have created a random BLE address after every boot so I didn&amp;#39;t have to keep track of the increment in RAM. Apart from that, it sounds like a good way to test this issue.&lt;/p&gt;
&lt;p&gt;As for the pairing issue, did you try to reset the device after deleting the bonds? It may be an idea to use nrfjprog to erase the flash pages between each test to be absolutely sure the bonding information is erase:&lt;/p&gt;
&lt;p&gt;1. nrfjprog --erasepage &amp;lt;fds_page_start-fds_page_end&amp;gt;&lt;/p&gt;
&lt;p&gt;2. nrfjprog --reset&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/317766?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 14:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f3fb923-9b73-4c5d-b5f1-69c12cabc93b</guid><dc:creator>Roiger</dc:creator><description>&lt;p&gt;Hi Vidar!&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Yes, the problem we see is definitely on the windows side. We simply want to try and estimate the number of paired devices windows can deal with before &amp;quot;going crazy&amp;quot;.&lt;/li&gt;
&lt;li&gt;I erase bonds only on the nRF end, because part of the issue on the windows end is the amount of LTKs and cached GATT tables, so I want to keep them.&lt;/li&gt;
&lt;li&gt;You are correct - we want the windows PC to pair with the incremented mac as if it is a new device. Is there a more elegant solution that you can suggest?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Thanks for your quick reply!&lt;/p&gt;
&lt;p&gt;Roi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MAC Address Incrementation Pairing issue</title><link>https://devzone.nordicsemi.com/thread/317738?ContentTypeID=1</link><pubDate>Tue, 29 Jun 2021 13:29:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5f6597d-18a4-4c95-a9b5-2d8daf8ac565</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Error 136 corresponds to BLE_GAP_SEC_STATUS_&lt;strong&gt;UNSPECIFIED&lt;/strong&gt; assuming it reported via the PM security failed event, so it&amp;#39;s not the most helpful error code I&amp;#39;m afraid. I&amp;#39;m not sure how I should try to replicate this error here, can you maybe provide the steps for me?&lt;/p&gt;
[quote user=""]high number of paired devices[/quote]
&lt;p&gt;Just to confirm, is this an issue on the Windows PC or on the nRF side?&lt;/p&gt;
[quote user=""]I also erase bonds post reset, and have tried pre reset as well.[/quote]
&lt;p&gt;&amp;nbsp;On PC, nRF, or both?&lt;/p&gt;
[quote user=""]I see the advertisement on the incremented mac address[/quote]
&lt;p&gt;&amp;nbsp;What&amp;#39;s the purpose changing the address, is it to make the windows PC see the nRF as a new device.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>