MAC地址拿不到

yueda
Posts: 23
Joined: Wed Jun 01, 2016 11:52 am

MAC地址拿不到

Postby yueda » Wed Jul 06, 2016 2:18 pm

大家好,最近在开发esp的时候发现程序里使用wifi_get_macaddr()函数拿到的MAC和ESP FLASH DOWMLOAD TOOL 下载程序时生成的MAC不一样,有没有人遇到同样的问题呢?相关代码

Code: Select all

char hwaddr[6];
char DeviceBuffer[125] = {0};
wifi_get_macaddr(STATION_IF, hwaddr);
os_sprintf(DeviceBuffer, "station_mac:" MACSTR "!\n" ,  MAC2STR(hwaddr));
at_port_print(DeviceBuffer);
wifi_get_macaddr(SOFTAP_IF, hwaddr);
os_sprintf(DeviceBuffer, "ap_mac:" MACSTR "!\n" ,  MAC2STR(hwaddr));
at_port_print(DeviceBuffer);
at_port_print("get MAC!\r\n");
Attachments
ret.jpg
MAC.jpg
Last edited by yueda on Wed Jul 06, 2016 2:22 pm, edited 2 times in total.

yueda
Posts: 23
Joined: Wed Jun 01, 2016 11:52 am

Re: MAC地址拿不到

Postby yueda » Fri Jul 08, 2016 12:47 pm

发现问题了,这两个函数要在at_init()之前。否则不可以

Her Majesty
Posts: 186
Joined: Mon Oct 27, 2014 11:09 am

Re: MAC地址拿不到

Postby Her Majesty » Mon Jul 11, 2016 10:50 am

你可以参考 AT bin 里的 readme 文件烧录。
blank.bin 烧到 0x7E000 和 0xFE000 两个地址做初始化。

yueda
Posts: 23
Joined: Wed Jun 01, 2016 11:52 am

Re: MAC地址拿不到

Postby yueda » Fri Jul 29, 2016 5:53 pm

解决了:把调用拿MAC的函数放在at_nit 之前就没问题了。

Who is online

Users browsing this forum: No registered users and 2 guests