I am trying to figure out why the XDK's MAC Address is random and isn't set to the value located on the label on the back of the XDK.

In my research I have discovered a couple of errors with the SDK code that I have udpated in my SDK (the software folder included with the workbench).  I also found the code will look at the User Page and if it doesn't see a valid MAC Address there it will assign a random address to the XDK.  The User Page is blank by default so in order to use the MAC Address on the label you have to write to the user page first with the correct MAC Adress.

My main question is where are the MAC addresses for the WLAN and Bluetooth stored on the XDK?  I don't mind having to write the User Page for every XDK I program but I don't want to have to manually write a different MAC Address for each XDK and therefor have to flash a different program to every XDK.
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
2/23/16 8:40 PM as a reply to Christopher Koch.
Just an FYI to user who are curious, I changed the following code in the SDK:

In BoardInitialization.c:

static void* bleGetPublicAddress(void* address)
{
    uint8_t isBleAddressValid = UINT8_C(0);

    if (USERPAGE_SUCCESS == UserPage_readAFieldFromUserPage(USERPAGE_CONTENT_INFO_INDEX, USERPAGE_CONTENT_INFO_LENGTH, &isBleAddressValid))
    {
        if (isBleAddressValid == UINT8_C(0))
        {
            address = NULL;
        }
        else
        {
            if (USERPAGE_SUCCESS != UserPage_readAFieldFromUserPage(USERPAGE_BTLE_MAC_INDEX, USERPAGE_BTLE_MAC_ADDRESS_LENGTH, (uint8_t*) address))
            {
                address = NULL;
            }
        }
    }

    return (address);
}

In BLE_radioInterface_cc.c:

static BleStatus BLE_checkAddressValidity(BD_ADDR *address)
{
    BleStatus resultCode = BLESTATUS_SUCCESS;

    /* test parameters are hard-coded on purpose to BCDS OUI ID of FC-D6-BD */
    if ((0xFC != address->addr[0]) || (0xD6 != address->addr[1]) || (0xBD != address->addr[2]))
    {
        resultCode = BLESTATUS_FAILED;
    }

    return (resultCode);
}

The following code will allow a user to add the MAC Address on the label to their code;
In the example SendAccelerometerDataOverBle, and the file SendAccelerometerDataOverBle.c:

#include "BCDS_UserPage.h"
#include "UserPageConfig.h"
...
void appInitSystem(OS_timerHandle_tp xTimer)
{
    (void) (xTimer);

    uint8_t Unique_BleMac[USERPAGE_BTLE_MAC_ADDRESS_LENGTH] = {0xFC, 0xD6, 0xBD, 0x10, 0x03, 0xC7};
    uint8_t Flag[USERPAGE_CONTENT_INFO_LENGTH] = {0x01};
    UserPage_writeAFieldToUserPage(USERPAGE_CONTENT_INFO_INDEX, USERPAGE_CONTENT_INFO_LENGTH, Flag);
    UserPage_writeAFieldToUserPage(USERPAGE_BTLE_MAC_INDEX, USERPAGE_BTLE_MAC_ADDRESS_LENGTH, Unique_BleMac);

    init();
}
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
2/24/16 10:47 AM as a reply to Christopher Koch.
Is the Wifi MAC address set on a fresh XDK?
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
2/24/16 5:45 PM as a reply to Kornelius Nägele.
Yes, the Wifi MAC address is set and matches the label on the XDK.  This is static and not random.  I am not sure where this MAC address is stored, or where the BLE MAC address is stored.  I need to do a bit more research, but I suspect the MAC for the WiFi is stored on the CC3100 chip and the MAC for the BLE is provided by BCDS via the label but needs to be programmed into the XDK's User Page by the user.
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
2/27/16 11:15 PM as a reply to Christopher Koch.
Hi Chris, it might be related to privacy concerns addressed in the BLE-specs. http://blog.bluetooth.com/bluetooth-technology-protecting-your-privacy/
tl,dr: While advertising the device can take on any MAC, while the real MAC is only exposed after a connection is estabished.

 
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
2/29/16 8:21 PM as a reply to Kornelius Nägele.
That is a good article, but I don't think it pertains to the current XDK implementation.  I could be wrong, but when I dug through the code, the XDK tries to set a static MAC from the User Page and when it can't it will then set up a random one.  Once this is done the same random one will remain the MAC address until a power down occurs.

Besides, even if the XDK implemented this security, it would still have to store the original MAC address somewhere, and that address is exactly what I am looking for.  I have looked through most of the header files in the SDK with no luck.  I am begining to think this isn't being stored in the firmware at all.
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/3/16 6:07 PM as a reply to Christopher Koch.
I am still waiting on a reply for this question.  Does anyone know where the XDK stores the Bluetooth MAC Address or is this something that must be input manaully by the user for each XDK?

Chris
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/5/16 9:13 AM as a reply to Christopher Koch.
Hi Chrisrkoch,

By default XDK have the Random Mac Address Generates support , If you want to Disable random Mac Address , you need to disable the flag ( #define BLE_RANDOM_ADDRESSING_SUPPORT    0) in "BLECustomConfig.h" file exists under Common/config/ .
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/5/16 9:25 AM as a reply to Dhanunjaya Palnati.
Hi Chrisrkoch,
Be aware of this statement also while trying to "Random addressing must be enabled for XDK projects that use Bluetooth Smart as"
        "a fall-back solution in case the device cannot load a proper public MAC address ".
 
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/9/16 11:55 AM as a reply to Dhanunjaya Palnati.
Hi Chris,

sorry for the late reply. The MAC addresses are stored in the user page on the MCU. While the WLAN address is also hard coded into the WLAN module, the BLE address is assigned in production.
A problem can occur if the user page is deleted, which is not possible while flashing over USB, but can be done when using the JTAG interface. In that case, you'd have to re-programm the user page. If no valid BLE address is found, the standard allows to assign a random address - I guess this is what you have observed.

BR,
Mathias
 
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/9/16 4:05 PM as a reply to Mathias Bruendel.
Thank you Mathias and dhanunjaya.

Both replies are much appreciated.  Mathias, it is very possible I had at some point deleted the user page with the XDK I am working on since I have been using this XDK for various projects and have programmed the device via USB and the debugger.

I will use a fresh XDK to see if the user page is stored properly and then I can move forward with the project that way.

Thank you again,
Chris
 
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/12/16 8:36 PM as a reply to Christopher Koch.
Thanks Community! I learned a lot about BLE and the XDK through this thread!
0 (0 Votes)
BLE MAC address is random and doesn't follow the XDK Label
Answer
3/23/16 8:32 PM as a reply to Kornelius Nägele.
All,

    I have recently run some tests and have confirmed the code changes at the begining of this thread to the BoardInitialization.c file and the BLE_radioInterface_cc.c file will allow a fresh XDK to read and use the BLE MAC Address from the User Page, which will match the Bluetooth MAC address on the XDK Label.  You do not need to include the code added to the appInitSystem function that writes the User Page.

    If you have already programmed the XDK using the USB and want to access the pre-programmed Bluetooth MAC address you will need to flash the User Page once with the follwoing code (after you do this once you can remove this code from your program):

#include "UserPageConfig.h"
#include "BCDS_UserPage.h"

void appInitSystem(OS_timerHandle_tp xTimer) {
    ( void) (xTimer);
    uint8_t Value = 0x01;
    UserPage_writeAFieldToUserPage(USERPAGE_CONTENT_INFO_INDEX,
                                                             USERPAGE_CONTENT_INFO_LENGTH, &Value);
   /* Rest of you Code here */
}


    I have also confimred that using the debugger will erase the User Page and if you plan on using the User Page along with the debugger you should add the appropriate code to re-write the XDK's user page.  This will need to be done everytime you use the debugger.  Something like the code below will at least reprogram the Bluetooth MAC Address in the User Page (you should flash the User Page before you start the Bluetooth):

#include "UserPageConfig.h"
#include "BCDS_UserPage.h"

void appInitSystem(OS_timerHandle_tp xTimer) {
    ( void) (xTimer);
    uint8_t Unique_BleMac[USERPAGE_BTLE_MAC_ADDRESS_LENGTH] = {0xFC, 0xD6, 0xBD, 0x10, 0x03, 0xC7};
    uint8_t Flag[USERPAGE_CONTENT_INFO_LENGTH] = {0x01};
    UserPage_writeAFieldToUserPage(USERPAGE_CONTENT_INFO_INDEX,
                                                         USERPAGE_CONTENT_INFO_LENGTH, Flag);
    UserPage_writeAFieldToUserPage(USERPAGE_BTLE_MAC_INDEX,
                                                         USERPAGE_BTLE_MAC_ADDRESS_LENGTH, Unique_BleMac);
    /* Rest of User Code Here */
}

NOTE:  Future Release of the XDK workbench might not require these changes.  As of Workbench Version 1.5.1 these changes are still necessary.  Also these changes are to the files in the SDK folder and will only need to be done once and not for each project.
0 (0 Votes)