6. Compile the application program, generate firmware and download it into the ESP8266
module.
7. Power off the module, and change it to operation mode; then power on the module and
run the program. Connect a PC or other Stations to the ESP8266 SoftAP.
!
Result:
ESP8266 works as SoftAP, and the following information will be printed when a Station is
connected to it:
station:c8:3a:35:cc:14:94join,AID=1
3.2.5. Events Triggered When Wi-Fi Connection State Changes
1. The event monitor Wi-Fi_set_event_handler_cb monitors ESP8266’s Wi-Fi connection
state, either when it is working as Station or SoftAP, and executes a user callback when
the connection state changes.
2. Sample code:
voidWi-Fi_handle_event_cb(System_Event_t*evt)
{
printf("event%x\n",evt->event_id);
switch(evt->event_id){
caseEVENT_STAMODE_CONNECTED:
printf("connecttossid%s,channel%d\n",
evt->event_info.connected.ssid,
evt->event_info.connected.channel);
break;
caseEVENT_STAMODE_DISCONNECTED:
printf("disconnectfromssid%s,reason%d\n",
evt->event_info.disconnected.ssid,
evt->event_info.disconnected.reason);
break;
caseEVENT_STAMODE_AUTHMODE_CHANGE:
printf("mode:%d->%d\n",
evt->event_info.auth_change.old_mode,
evt->event_info.auth_change.new_mode);
break;
caseEVENT_STAMODE_GOT_IP:
printf("ip:"IPSTR",mask:"IPSTR",gw:"IPSTR,
IP2STR(&evt->event_info.got_ip.ip),