You can get the MAC address from the Sphere high-level application, at least with the latest OS/SDK as of this posting:
#include <ifaddrs.h>
#include <net/ethernet.h>
#include <sys/socket.h>
#include <netpacket/packet.h>
void getIP(void)
{
struct ifaddrs* addr_list;
struct ifaddrs* it;
int n;
const char EthInterface[] = "wlan0";
if (getifaddrs(&addr_list) < 0) {
Log_Debug("***** GETIFADDRs failed! ***\n");
}
else {
for (it = addr_list, n = 0; it != NULL; it = it->ifa_next, ++n) {
if (it->ifa_addr == NULL) {
continue;
}
if (strncmp(it->ifa_name, EthInterface, sizeof(EthInterface)) == 0) {
if (it->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in* addr = (struct sockaddr_in*)it->ifa_addr;
char* ip_address = inet_ntoa(addr->sin_addr);
Log_Debug("**** wlan0 IP found: %s ***\n", ip_address);
}
else if (it->ifa_addr->sa_family == AF_PACKET) {
struct sockaddr_ll* mac_addr = (struct sockaddr_ll*)it->ifa_addr;
unsigned char* mac = mac_addr->sll_addr;
char mac_string[20];
sprintf(mac_string, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0],
mac[1], mac[2], mac[3], mac[4], mac[5]);
Log_Debug("**** wlan0 MAC 1 found: %s ****\n", mac_string);
}
}
}
}
freeifaddrs(addr_list);
}