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

MAC address mismatch

I try to retrieve the current device's MAC address and print it through RTT so that it can be recognized automatically in the manufacturer's test. The weird thing is... the MAC address never matches the real MAC address. Here's what I do in my code:

char * macaddr( void )
{
    static char _str[BLE_GAP_ADDR_LEN * 3] = "";
    char * p = _str;
    ble_gap_addr_t mac;

    if ( !_str[0] )
    {
        pm_id_addr_get( &mac );
        for ( int i = BLE_GAP_ADDR_LEN; i; )
        {
            if ( i-- != BLE_GAP_ADDR_LEN ) *p++ = ':';
            p += sprintf( p, "%02X", mac.addr[i] );
        }
    }
    return _str;
}

I have a device with address F5:B8:BC:C3:99:C5. But the above code reports F5:B8:BC:C3:99:C4. It's always the LSB that is wrong. Same thing with all the other samples I have.

Software: SDK15, hardware nRF52832

  • Hi Joost, 

     

    I don't see the issue here. But note that the last bit of a BLE address has to follow the rule. Have a look here

    In your code do you set your address or it's the default address you have  ? If you set the address, do you see the correct address being advertised ? 

  • Thanks for looking into this issue. I use the default address for now. It looks like some kind of weird critical race - if I put just a little bit of code between advertisement start and this function everything works fine. I'm chasing ghosts, or so it looks like (the LSB is the first byte in this memory area and a simple NOP solves the issue). 

    Never mind, I will crank up the debugger once it shows up again. It's a minor issue anyway.

Related