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
  • I understand that in BLE Steam the 2 MSB bits of the address depends of the type of address as you attached in the comment before. But in this case we're reading a register, that could be use as on-air address or I could make my own address, so I think that there are other reason for this case.

    Also, as I can saw in the Product Specification Docs, there is a register in which appears the type of address:

    As we can appreciated if the register is 0xFFFFFFFF its a Random Address, and if the register is 0xFFFFFFFE, it's a public Address. I attach the code:

    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);
      if(NRF_FICR->DEVICEADDRTYPE == 0xFFFFFFFF) transmit_string_CR("Random",6);
      else transmit_string_CR("Public",6);
      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();
      CR();
      nrf_delay_ms(1000);
    }

    And I see by serial port:

    I have test that and the results are that there's a random address, so I don't understand why and don't correspond with the "public address" of the label.

    So what address I have to use in the PREFIX and BASE register of the Radio?

  • The address on the label is actually "Static Random", not "Public". You cannot change the DEVICEADDRTYPE register as it is also read-only. Nordic appear to hardcode the psuedo-random 48-bit address and then set the upper 2 bits within the SoftDevice stack to indicate "Static Random". These 3 registers can not be changed.

    If you want your own BLE "Public" address I believe you can set it using sd_ble_gap_addr_set() which you can find in the Infocenter. However it looks to me like your decoding is correct and matches the label provided you always set the upper 2 bits.

  • Many thanks , I'm going to try the code with another dongle and also with DK.

    I think thats my code reads the Public Address, and the label has the Static Random Address may be I could change it to Non Resolvable and Resolvable, masking with 0x02 and 0x03 the 2 bits.

    I tell you if the dongle or the DK has the same behavior. 

    Best,

    Jorge.

Related