Reading XDK Mac address in C
Risposta
29/05/15 2.02
Hi,

is it possible to read the mac address of the xdk board from within the C application?

Thanks,
Christoph
0 (0 Voti)
Reading XDK Mac address in C
Risposta
28/05/15 3.49 come risposta a Christoph Grotz.
Hello Christoph,

we're happy to help, unfortunately tek sensor doesn't really ring a bell for us.

Could you may clarify which sensor you mean by 'tek sensor'?

- Florian
0 (0 Voti)
Reading XDK Mac address in C
Risposta
28/05/15 7.42 come risposta a Manuel Cerny.
Sorry, I mean the XDK of course. I got a little carried away :-)
 
0 (0 Voti)
Reading XDK Mac address in C
Risposta
05/06/15 1.36 come risposta a Christoph Grotz.
Hello cgrotz,

apologise for the late answer.

Meanwhile I was able to find a solution for your question:

If you look into the XDK Documentation that was shipped with your XDK Workbench ( Help -> Help Contents ) you'll find a code example for exactly your problem.

SL_MAC_ADDRESS_GET: 
 
 Get the device MAC address. 
 The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address 
 is retrieved from HW. 
 

 _u8 macAddressVal[SL_MAC_ADDR_LEN]; 
 _u8 macAddressLen = SL_MAC_ADDR_LEN; 
 sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal);

Make sure to #include "simplelink.h".

Regards,
Florian

0 (0 Voti)
Reading XDK Mac address in C
Risposta
11/06/15 12.44 come risposta a Manuel Cerny.
I tried to insert this code snippet into one of the sample applications and a hard crash after the following assertion:

asserted at Filename C:/Software/XDK-Workbench/SDK/lib/FreeRTOS/source/queue.c , line no  1177 

I guess this function needs an initialized WLAN adapter.

0 (0 Voti)
Reading XDK Mac address in C
Risposta
12/06/15 3.53 come risposta a Christian Renz.
Hi Christian Renz,

I just tested the code in the SensorMonitor Demo after the Wifi Adapter was connected to my network and it worked fine. When I tested it without any initialisation I got the same error as you did.
So I guess you are right and this method needs an initialized Wifi adapter.

So thanks for this great note! 

I just forwarded what you mentioned to our second level support so we can make this more clear in the documentation and might provide another way to read the MAC address.

- Florian
0 (0 Voti)
Reading XDK Mac address in C
Risposta
17/06/15 9.49 come risposta a Manuel Cerny.
It would be very helpful if not only the mac address but also the dynamic assigned IP address can be read (and printed).

I know that there is also a code snippet for that and I tried that in the sensor monitor demo but it always gives me 0.0.0.0 back.

I ask for that because it is not always possible to have a look on the router / dhcp server and check assigned IPs. Even the second suggested option to do a network scan can be recongized as a attack in company environment (and is not working in productive environment).

For the Sensor Monitor demo I find it very intersting to do the connection the other way around: The IP of Monitor App will be configured in the XDK using config.txt file. The XDK will automatically establish connection to the App when available (in a endless loop with timeout). In this way you don't need to find out the IP address of the XDK and it's more pratical that XDKs register themself once they are connected.
0 (0 Voti)
Reading XDK Mac address in C
Risposta
24/06/15 15.30 come risposta a Stefan Witschel.
Hi Stefan,

thanks for pointing this out. 

I replicated what you've described and unfortunately it seems like the XDK always give 0.0.0.0 back. 

I forwarded this to our SDK developers to make sure we did it the right way and if so it is being fixed.

Sorry that I couldn't solve it just now.

- Florian
0 (0 Voti)
Reading XDK Mac address in C
Risposta
01/07/15 15.00 come risposta a Florian Harr.
Hello Stefan,

while the NetCfg modul seems to give the wrong IP, here's another solution that worked for me.


        NCI_getIpSettings(&myIpSettings);
        *IpaddressHex = Basics_htonl(myIpSettings.ipV4);
        (void)Ip_convertAddrToString(IpaddressHex,(char *)&ipAddress);
        printf("Connected to WPA network successfully \r\n ");
        printf(" Ip address of the device %s \r\n ",ipAddress);

Best regards,
Florian

0 (0 Voti)
Reading XDK Mac address in C
Risposta
10/07/15 14.44 come risposta a Florian Harr.
Hi everyone,

is there also a way to get the MAC address of the Bluetooth module that is written down on the back of the XDK?

BR,
Florian
0 (0 Voti)
Reading XDK Mac address in C
Risposta
16/08/15 15.06 come risposta a Florian Dittrich.
Hi Florian,

if you look into the "CSU_chipStartUp_cc.c" file of the SDK you'll find around Line 60 and 68 the macros "UPA_BTLE_MAC_ADDRESS" and "UPA_BTLE_MAC_ADDRESS_FLAG" as well as their corresponds for length.
These should get you the MAC address from the Bluetooth module.
    if (UPA_SUCCESS == UPA_getUserPageDataOfAField(UPA_BTLE_MAC_ADDRESS_FLAG, &isBleAddressValid))
    {
        if (isBleAddressValid == UINT8_C(0))
        {
            address = NULL;
        }
        else
        {
            if (UPA_SUCCESS != UPA_getUserPageDataOfAField(UPA_BTLE_MAC_ADDRESS, (uint8_t*) address))
            {
                address = NULL;
            }
        }
Also if you look into the file "UPA_userPagesAccess_ih.h" you'll find another hint:
        uint8_t btleMacAddress[UPA_BTLE_MAC_ADDRESS_LENGTH];     /**< Bluetooth MAC address*/

- Florian
0 (0 Voti)
Reading XDK Mac address in C
Risposta
13/07/15 5.31 come risposta a Florian Harr.
Hi Florian,

thanks for this, I'll look into this.

BR,
Florian
0 (0 Voti)