Result:
ESP8266chipID:0x97f740
3.2.3. Connect to AP When ESP8266 Functions as Station
1. Set the working mode of ESP8266 to Station mode, or Station+SoftAP mode.
Wi-Fi_set_opmode(STATION_MODE);
2. Set the SSID and password of the AP.
#defineDEMO_AP_SSID"DEMO_AP"
#defineDEMO_AP_PASSWORD"12345678"
Wi-Fi_station_set_config is used to set the AP information when ESP8266 functions
as Station. Please note that the initialized value of bssid_set in station_config should
be 0. It is only when the MAC address of AP need be specified that the initialized value is
set to be 1.
Wi-Fi_station_connect sets the connection of AP.
structstation_config*config=(structstation_config*)zalloc(sizeof(struct
station_config));
sprintf(config->ssid,DEMO_AP_SSID);
sprintf(config->password,DEMO_AP_PASSWORD);
Wi-Fi_station_set_config(config);
free(config);
Wi-Fi_station_connect();
3. Compile the application program, generate firmware and program it into ESP8266
module.
4. Power off the module, and change it to operation mode; then power on the module and
run the program.
Result:
connectedwithDEMO_AP,channel11
dhcpclientstart...
ip:192.168.1.103,mask:255.255.255.0,gw:192.168.1.1
3.2.4. ESP8266 Functions as SoftAP
1. Set the working mode of ESP8266 as the Station mode, or Station+SoftAP mode.
Wi-Fi_set_opmode(SOFTAP_MODE);
2. Configure ESP8266 as SoftAP.
#defineDEMO_AP_SSID"DEMO_AP"
#defineDEMO_AP_PASSWORD"12345678"
structsoftap_config*config=(structsoftap_config*)zalloc(sizeof(struct
softap_config));//initialization