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

Central - use public address

Hi. I'm new to Nordic BLE devices. Using the nrf51-DK. I have a peripheral device (non-Nordic) which I want to connect to from a Nordic central (S130) using the public address. It seems that by default the address used by the central is the random one. Is this possible? How can I do this? Thanks.

Parents
  • Hi,

    There should be no difference in the way you connect to a peripheral with a public or a random address.

    The softdevice function sd_ble_gap_connect() takes a pointer to the address struct, ble_gap_addr_t, as agrument. This should be filled with the address and the address type. By setting the type to BLE_GAP_ADDR_TYPE_PUBLIC, you can connect to a device that has a public address.

    If your central is scanning for advertising packets from the device before connecting, you can pass the address struct included in the advertising report, peer_addr, directly to the connect function.

    Best regards,

    Jørgen

  • You set it in the ble_gap_addr_t structure, along with the address. As mentioned above, you do not have to do this, as the softdevice handles this for you. If you want to set the address from FICR yourself, you can use the following code:

    static ble_gap_addr_t m_central_addr;
    
    m_central_addr.addr_type     = BLE_GAP_ADDR_TYPE_RANDOM_STATIC;
    m_central_addr.addr[0] = (uint8_t)NRF_FICR->DEVICEADDR[0];
    m_central_addr.addr[1] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 8);
    m_central_addr.addr[2] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 16);
    m_central_addr.addr[3] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 24);
    m_central_addr.addr[4] = (uint8_t)NRF_FICR->DEVICEADDR[1];
    m_central_addr.addr[5] = (uint8_t)((NRF_FICR->DEVICEADDR[1] >> 8) | 0xC0); // 2MSB must be set 11
    
    sd_ble_gap_addr_set(&m_central_addr);
    
Reply
  • You set it in the ble_gap_addr_t structure, along with the address. As mentioned above, you do not have to do this, as the softdevice handles this for you. If you want to set the address from FICR yourself, you can use the following code:

    static ble_gap_addr_t m_central_addr;
    
    m_central_addr.addr_type     = BLE_GAP_ADDR_TYPE_RANDOM_STATIC;
    m_central_addr.addr[0] = (uint8_t)NRF_FICR->DEVICEADDR[0];
    m_central_addr.addr[1] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 8);
    m_central_addr.addr[2] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 16);
    m_central_addr.addr[3] = (uint8_t)(NRF_FICR->DEVICEADDR[0] >> 24);
    m_central_addr.addr[4] = (uint8_t)NRF_FICR->DEVICEADDR[1];
    m_central_addr.addr[5] = (uint8_t)((NRF_FICR->DEVICEADDR[1] >> 8) | 0xC0); // 2MSB must be set 11
    
    sd_ble_gap_addr_set(&m_central_addr);
    
Children
No Data
Related