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

MAC Address for BLE Communication

Hi,

I'm trying send me the mac address of the device by UART by the following method:

void sendMacAddress(void){
  uint8_t packet[6];
  packet[0] = NRF_FICR->DEVICEADDR[0];
  packet[1] = NRF_FICR->DEVICEADDR[0]>>8;
  packet[2] = NRF_FICR->DEVICEADDR[0]>>16;
  packet[3] = NRF_FICR->DEVICEADDR[0]>>24;
  packet[4] = NRF_FICR->DEVICEADDR[1];
  packet[5] = NRF_FICR->DEVICEADDR[1]>>8;
  transmit_string_CR("Start",5);
  for(int i=5; i>=0; --i){
    char msg[2]={0};
    itoa(packet[i],msg,16);
    transmit_string_NCR(msg,2);
    if(i!=0)transmit_string_NCR(":",1);
  }
  CR();
  nrf_delay_ms(1000);
}

By serial I receive: 

Start
b9:24:82:d5:4f:81

The problem its that the device which I receive is not the same that appears in the stick device, I attach photo:

Could anyone tell me that I'm do it correctly?

Best,

Jorge.

Parents Reply Children
  • Yes, of course. This is the trace from both techniques with the first part using the code I posted earlier:

    BLE 0001:58EAA39F67F4 (1FC5B4679FA3EA58)

    The second (in parenthesis) is the 64-bit device address from which the 48-bit BLE address is formed.

    // print format (%08X%08X)
    NRF_FICR->DEVICEADDR[1], NRF_FICR->DEVICEADDR[0]
    
    /**@brief Bluetooth Low Energy address. */
    typedef struct
    {
      uint8_t addr_id_peer : 1;       /**< Only valid for peer addresses.
                                           Reference to peer in device identities list (as set with @ref sd_ble_gap_device_identities_set) when peer is using privacy. */
      uint8_t addr_type    : 7;       /**< See @ref BLE_GAP_ADDR_TYPES. */
      uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */
    } ble_gap_addr_t;
    

    This shows the byte-reversal, and also note the top bits; I forget where these details are described so can't give a better description I'm afraid ..

Related