如何读取CC3200的MAC地址?
我需要读取当前芯片中的MAC地址。
在CC3200的simplelink库提供的函数中参考如下代码读取本机的MAC地址:
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(unsigned char *)macAddressVal);
从GitHub上找到一个帖子,参考如下:
/// | |
/// @brief Get MAC address | |
/// @return MAC address | |
/// | |
MACAddress getMacAddress() | |
{ | |
uint8_t macAddressVal[SL_MAC_ADDR_LEN]; | |
uint8_t macAddressLen = SL_MAC_ADDR_LEN; | |
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,macAddressVal); | |
MACAddress MAC(macAddressVal); | |
return MAC; | |
} |
地址连接https://github.com/energia/Energia/issues/687
CC3200 WiFi: How to Get the MAC Address
Setting MAC address to the Device.
The new MAC address will override the default MAC address and it be saved in the FileSystem.
Requires restarting the device for updating this setting.
_u8 MAC_Address[6]; MAC_Address[0] = 0x8; MAC_Address[1] = 0x0; MAC_Address[2] = 0x28; MAC_Address[3] = 0x22; MAC_Address[4] = 0x69; MAC_Address[5] = 0x31;
sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress);
sl_Stop(0); sl_Start(NULL,NULL,NULL);
#define SL_MAC_ADDR_LEN (6)
#define SL_IPV4_VAL(add_3,add_2,add_1,add_0) ((((_u32)add_3 << 24) & 0xFF000000) | (((_u32)add_2 << 16) & 0xFF0000) | (((_u32)add_1 << 8) & 0xFF00) ((_u32)add_0 & 0xFF) )
#define SL_IPV4_BYTE(val,index) ( (val >> (index*8)) & 0xFF )