EasyManua.ls Logo

Espressif Systems ESP8266EX - Connect to AP When ESP8266 Functions as Station; ESP8266 Functions as Softap

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
Result:
ESP8266󰲧chip󰲧ID: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.
󰲧󰲧󰲧󰲧#define󰲧DEMO_AP_SSID󰲧󰲧󰲧󰲧󰲧󰲧"DEMO_AP"
󰲧󰲧󰲧󰲧#define󰲧DEMO_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.
struct󰲧station_config󰲧*󰲧config󰲧=󰲧(struct󰲧station_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:
connected󰲧with󰲧DEMO_AP,󰲧channel󰲧11
dhcp󰲧client󰲧start...
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.
󰲧󰲧󰲧󰲧#define󰲧DEMO_AP_SSID󰲧󰲧󰲧󰲧󰲧󰲧"DEMO_AP"
󰲧󰲧󰲧󰲧#define󰲧DEMO_AP_PASSWORD󰲧󰲧"12345678"
󰲧󰲧󰲧󰲧struct󰲧softap_config󰲧*config󰲧=󰲧(struct󰲧softap_config󰲧*)zalloc(sizeof(struct󰲧
softap_config));󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧initialization
Espressif
! /!7 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals