Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Central Connection Establishment with Private Peer (Resolvable Random Private Address)

Hello,

I am trying to establish a connection with a peer with Resolvable Random Private address.

Based on Noridc GAP API documentation (https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.0.0/group___b_l_e___g_a_p___c_e_n_t_r_a_l___c_o_n_n___p_r_i_v___m_s_c.html), the  sd_ble_gap_device_identities_set() should be called prior to sd_ble_gap_connect().

In my case the sd_ble_gap_device_identities_set function returns 0x3202 (BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.). Please see below a code example.

m_peer_addr.addr[5] = 0x73;
m_peer_addr.addr[4] = 0x8D;
m_peer_addr.addr[3] = 0x8B;
m_peer_addr.addr[2] = 0xCC;
m_peer_addr.addr[1] = 0xF5;
m_peer_addr.addr[0] = 0x42;

m_peer_addr.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;//BLE_GAP_ADDR_TYPE_PUBLIC;
m_peer_addr.addr_id_peer = 1;

ble_gap_irk_t peer_gap_irk_value;
memcpy(&peer_gap_irk_value.irk[0],&irk_value[0],16);

ble_gap_id_key_t peer_gap_key_id = {
    .id_info = peer_gap_irk_value,
    .id_addr_info = m_peer_addr
};
          
ble_gap_id_key_t const * const p_gap_id_key = &peer_gap_key_id;
          
err_code = sd_ble_gap_device_identities_set(&p_gap_id_key,NULL,1); // ----> returns 0x3202 (BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.)

I wonder if I am missing something.

Thank you in advance.

Adrian.

Parents
  • It is a bit difficult to understand why this error is thrown without understanding the context of when you are trying to do this and the peer info. Normally the information is got from the persistent memory which is saved when bonding is done. Since you are manually building this struct for ble_gap_id_key_t, I cannot validate what is correct and wrong data. 

    Can you print this data when the device bonding is done so that we can match that data with what you are trying to set?

Reply
  • It is a bit difficult to understand why this error is thrown without understanding the context of when you are trying to do this and the peer info. Normally the information is got from the persistent memory which is saved when bonding is done. Since you are manually building this struct for ble_gap_id_key_t, I cannot validate what is correct and wrong data. 

    Can you print this data when the device bonding is done so that we can match that data with what you are trying to set?

Children
  • Hi Susheel,

    Thanks for your answer and I am sorry for my late response.

    I the above code snippet I tried to add in the trusted list the IRK of the peripheral without making any bonding (pairing procedure) prior. In the meantime, I understood that this is not the right way for making a connection. As you mention this information are stored in persistent memory when bonding is done. This could be handled automatically by the peer_manager library if it is used.

    I think we can close this case.

    Thank you very much.

    Adrian

Related