This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

private resolvable address and IRK generation

i need to generate an irk from nrf52 so that no device can identify that nrf52 data...only the device with same irk can identify and connect to it

for that what should i do?

Thank you

Parents
  • Hi,

    If you include the peer_manager in your application, for instance like the ble hid keyboard and mouse examples in the SDK v15.3 is doing, then you can find that the peer manager will handle all bond information, and by default use whitelisting after bonding to ensure that only previously bonded peer devices may reconnect when advertising. It is only by bonding that an IRK is generated and whitelisting will work.

    Best regards,
    Kenneth

  • this is my code what are the changes should i do so that"only the device with same irk can identify and connect to it"

  • After bonding is complete, then the irk can be fetched by calling pm_whitelist_get(). For instance look at the hid keyboard examples:

            case BLE_ADV_EVT_WHITELIST_REQUEST:
            {
                ble_gap_addr_t whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                ble_gap_irk_t  whitelist_irks[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                uint32_t       addr_cnt = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
                uint32_t       irk_cnt  = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
    
                err_code = pm_whitelist_get(whitelist_addrs, &addr_cnt,
                                            whitelist_irks,  &irk_cnt);
                APP_ERROR_CHECK(err_code);
                NRF_LOG_DEBUG("pm_whitelist_get returns %d addr in whitelist and %d irk whitelist",
                              addr_cnt, irk_cnt);
    
                // Apply the whitelist.
                err_code = ble_advertising_whitelist_reply(&m_advertising,
                                                           whitelist_addrs,
                                                           addr_cnt,
                                                           whitelist_irks,
                                                           irk_cnt);
                APP_ERROR_CHECK(err_code);
            } break; //BLE_ADV_EVT_WHITELIST_REQUEST

    Best regards,
    Kenneth

Reply
  • After bonding is complete, then the irk can be fetched by calling pm_whitelist_get(). For instance look at the hid keyboard examples:

            case BLE_ADV_EVT_WHITELIST_REQUEST:
            {
                ble_gap_addr_t whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                ble_gap_irk_t  whitelist_irks[BLE_GAP_WHITELIST_ADDR_MAX_COUNT];
                uint32_t       addr_cnt = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
                uint32_t       irk_cnt  = BLE_GAP_WHITELIST_ADDR_MAX_COUNT;
    
                err_code = pm_whitelist_get(whitelist_addrs, &addr_cnt,
                                            whitelist_irks,  &irk_cnt);
                APP_ERROR_CHECK(err_code);
                NRF_LOG_DEBUG("pm_whitelist_get returns %d addr in whitelist and %d irk whitelist",
                              addr_cnt, irk_cnt);
    
                // Apply the whitelist.
                err_code = ble_advertising_whitelist_reply(&m_advertising,
                                                           whitelist_addrs,
                                                           addr_cnt,
                                                           whitelist_irks,
                                                           irk_cnt);
                APP_ERROR_CHECK(err_code);
            } break; //BLE_ADV_EVT_WHITELIST_REQUEST

    Best regards,
    Kenneth

Children
Related