EasyManua.ls Logo

Espressif Systems ESP8266EX - Read and Set the MAC Address of ESP8266

Espressif Systems ESP8266EX
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
!
3. Sample Codes
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧IP2STR(&evt->event_info.got_ip.mask),
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧IP2STR(&evt->event_info.got_ip.gw));
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧printf("\n");
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧break;
󰲧󰲧󰲧󰲧case󰲧EVENT_SOFTAPMODE_STACONNECTED:
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧printf("station:󰲧"󰲧MACSTR󰲧"join,󰲧AID󰲧=󰲧%d\n",󰲧
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧MAC2STR(evt->event_info.sta_connected.mac),󰲧
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧evt->event_info.sta_connected.aid);
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧break;
󰲧󰲧󰲧󰲧case󰲧EVENT_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;
󰲧󰲧󰲧󰲧}
}
void󰲧user_init(void)
{
󰲧󰲧󰲧󰲧//󰲧TODO:󰲧add󰲧user’s󰲧own󰲧code󰲧here....
󰲧󰲧󰲧󰲧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󰲧:󰲧event󰲧1
connect󰲧to󰲧ssid󰲧Demo_AP,󰲧channel󰲧1
Wi-Fi_handle_event_cb󰲧:󰲧event󰲧4
IP:192.168.1.126,mask:255.255.255.0,gw:192.168.1.1
Wi-Fi_handle_event_cb󰲧:󰲧event󰲧2
disconnect󰲧from󰲧ssid󰲧Demo_AP,󰲧reason󰲧8
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
Espressif
! /!10 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals