IP2STR(&evt->event_info.got_ip.mask),
IP2STR(&evt->event_info.got_ip.gw));
printf("\n");
break;
caseEVENT_SOFTAPMODE_STACONNECTED:
printf("station:"MACSTR"join,AID=%d\n",
MAC2STR(evt->event_info.sta_connected.mac),
evt->event_info.sta_connected.aid);
break;
caseEVENT_SOFTAPMODE_STADISCONNECTED:
printf("station:"MACSTR"leave,AID=%d\n",
MAC2STR(evt->event_info.sta_disconnected.mac),
evt->event_info.sta_disconnected.aid);
break;
default:
break;
}
}
voiduser_init(void)
{
//TODO:adduser’sowncodehere....
Wi-Fi_set_event_handler_cb(Wi-Fi_handle_event_cb);
}
3. Compile the application program, generate firmware and download it into the ESP8266
module.
4. Power off the module, and change it to operation mode; then power on the module and
run the program.
Result:
For example, when ESP8266 functions as a Station, the process of how it is connected to
a router is shown below:
Wi-Fi_handle_event_cb:event1
connecttossidDemo_AP,channel1
Wi-Fi_handle_event_cb:event4
IP:192.168.1.126,mask:255.255.255.0,gw:192.168.1.1
Wi-Fi_handle_event_cb:event2
disconnectfromssidDemo_AP,reason8
3.2.6. Read and Set the MAC Address of ESP8266
1. ESP8266 can work in Station+SoftAP mode. The MAC addresses of the Station and
SoftAP interfaces are different. It is guaranteed that the MAC address of every chip is