Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

getting identity address in PM_EVT_CONN_SEC_SUCCEEDED

After a successful LESC bonding, the address given by p_ble_evt->evt.gap_evt.params.connected.peer_addr in a BLE_GAP_EVT_CONNECTED event is
a "identity address" as expected.

However, currently I need to disconnect and reconnect to get that identity address from my peer (which is in Central role).

I would like to get the identity address right after a successful bonding, which yields a PM_EVT_CONN_SEC_SUCCEEDED event.
I tried im_ble_addr_get(..) from within that event handler, but that wouldn't return the identity address but the same random address
I get before bonding in BLE_GAP_EVT_CONNECTED.

Is there a way to either resolve the identity address from random address (i guess it is a resolvable one) or getting the identity address
somehow right after bonding, ideally before or within the PM_EVT_CONN_SEC_SUCCEEDED event?

Thanks for your help

ps.: I'm using SDK 15.3 on nrf 52832 with Softdevice S132 6.1.1, my remote peer is a recent Android 8.0 device running as Central, initiating the bonding procedure.

Parents
  • Hi,

    You can use the function pm_peer_data_bonding_load() to get the peer identity address. It should work when you get the event PM_EVT_PEER_DATA_UPDATE_SUCCEEDED, and I will check if you can get it any earlier.

    In pm_evt_handler(), you can use it like this:

    Snippet:

    pm_peer_data_bonding_t peer_bonding_data;
    uint32_t return_code;
    
        switch (p_evt->evt_id)
        {
            case PM_EVT_PEER_DATA_UPDATE_SUCCEEDED:
                return_code = pm_peer_data_bonding_load(p_evt->peer_id,&peer_bonding_data);
                
                if(return_code == NRF_SUCCESS)
                {
    
                  NRF_LOG_INFO("PM_EVT_PEER_DATA_UPDATE_SUCCEEDED peer address %02x%02x%02x%02x%02x%02x",
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[0],
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[1],
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[2],
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[3],
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[4],
                  peer_bonding_data.peer_ble_id.id_addr_info.addr[5]
                  );
    
                }
                else
                {
                  NRF_LOG_INFO("pm_peer_data_bonding_load failed with error %d",return_code);
                }
            
    
    

  • Thanks Sigurd, you saved my day.
    I tried using pm_peer_data_bonding_load as well, but within my PM_EVT_CONN_SEC_SUCCEEDED handler.
    Of course, with no luck.
    Your suggested solution works well and there's no reason for me to require the peer identity address be available earlier.
    Thank you.
    However, I noticed that after bonding, when i disconnect my android-device and reconnect again, in the BLE_GAP_EVT_CONNECTED event handler I get the correct peer identity address but it is marked as type BLE_GAP_ADDR_TYPE_PUBLIC which seems misleading to me.
    Am I missing something conceptual here or is the Softdevice "abstracting" or "hiding" information or is this just a plain bug?

Reply
  • Thanks Sigurd, you saved my day.
    I tried using pm_peer_data_bonding_load as well, but within my PM_EVT_CONN_SEC_SUCCEEDED handler.
    Of course, with no luck.
    Your suggested solution works well and there's no reason for me to require the peer identity address be available earlier.
    Thank you.
    However, I noticed that after bonding, when i disconnect my android-device and reconnect again, in the BLE_GAP_EVT_CONNECTED event handler I get the correct peer identity address but it is marked as type BLE_GAP_ADDR_TYPE_PUBLIC which seems misleading to me.
    Am I missing something conceptual here or is the Softdevice "abstracting" or "hiding" information or is this just a plain bug?

Children
  • Testing here on an android version 7 phone(Samsung S6), and with S132 6.1.1,  I get different addresses in pm_peer_data_bonding_load() and in the BLE_GAP_EVT_CONNECTED event.

    In the event BLE_GAP_EVT_CONNECTED the address is a BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE.

    With pm_peer_data_bonding_load the other address is a BLE_GAP_ADDR_TYPE_PUBLIC   .

Related