EasyManua.ls Logo

Espressif Systems ESP8266EX - 2.2. Schematics

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
󰲧󰲧󰲧󰲧Wi-Fi_softap_get_config(config);󰲧󰲧󰲧//󰲧Get󰲧soft-AP󰲧config󰲧first.
󰲧󰲧󰲧󰲧sprintf(config->ssid,󰲧DEMO_AP_SSID);
󰲧󰲧󰲧󰲧sprintf(config->password,󰲧DEMO_AP_PASSWORD);
󰲧󰲧󰲧󰲧config->authmode󰲧=󰲧AUTH_WPA_WPA2_PSK;
󰲧󰲧󰲧󰲧config->ssid_len󰲧=󰲧0;󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧or󰲧its󰲧actual󰲧SSID󰲧length
󰲧󰲧󰲧󰲧config->max_connection󰲧=󰲧4;󰲧
󰲧󰲧󰲧󰲧Wi-Fi_softap_set_config(config);󰲧󰲧󰲧//󰲧Set󰲧ESP8266󰲧soft-AP󰲧config󰲧
󰲧󰲧󰲧󰲧free(config);
3. Get the Station info when ESP8266 functions as SoftAP.
struct󰲧station_info󰲧*󰲧station󰲧=󰲧Wi-Fi_softap_get_station_info();
while(station){
󰲧󰲧󰲧󰲧printf(bssid󰲧:󰲧MACSTR,󰲧ip󰲧:󰲧IPSTR/n,󰲧
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧MAC2STR(station->bssid),󰲧IP2STR(&station->ip));
󰲧󰲧󰲧󰲧station󰲧=󰲧STAILQ_NEXT(station,󰲧next);
}
Wi-Fi_softap_free_station_info();󰲧󰲧󰲧󰲧//󰲧Free󰲧it󰲧by󰲧calling󰲧functions
4. When ESP8266 functions as SoftAP, its default IP address is 192.168.4.1. The IP
address is subject to modification by developers; however, the DHCP server must be
closed first before modifying the address. Below is an example of setting the IP address
as 192.168.5.1.
󰲧󰲧󰲧󰲧Wi-Fi_softap_dhcps_stop();󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧disable󰲧soft-AP󰲧DHCP󰲧server
󰲧󰲧󰲧󰲧struct󰲧ip_info󰲧info;
󰲧󰲧󰲧󰲧IP4_ADDR(&info.ip,󰲧192,󰲧168,󰲧5,󰲧1);󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧set󰲧IP
󰲧󰲧󰲧󰲧IP4_ADDR(&info.gw,󰲧192,󰲧168,󰲧5,󰲧1);󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧//󰲧set󰲧gateway
󰲧󰲧󰲧󰲧IP4_ADDR(&info.netmask,󰲧255,󰲧255,󰲧255,󰲧0);󰲧󰲧󰲧󰲧//󰲧set󰲧netmask
󰲧󰲧󰲧󰲧Wi-Fi_set_ip_info(SOFTAP_IF,󰲧&info);
5. The range of the IP address allocated by ESP8266 SoftAP can be set by developers.
For example, the IP address can range from 192.168.5.100 to 192.168.5.105. Please
enable the DHCP server when the configuration is completed.
󰲧󰲧󰲧󰲧struct󰲧dhcps_lease󰲧dhcp_lease;
󰲧󰲧󰲧󰲧IP4_ADDR(&dhcp_lease.start_ip,󰲧192,󰲧168,󰲧5,󰲧100);
󰲧󰲧󰲧󰲧IP4_ADDR(&dhcp_lease.end_ip,󰲧192,󰲧168,󰲧5,󰲧105);
󰲧󰲧󰲧󰲧Wi-Fi_softap_set_dhcps_lease(&dhcp_lease);
󰲧󰲧󰲧󰲧Wi-Fi_softap_dhcps_start();󰲧󰲧󰲧󰲧//󰲧enable󰲧soft-AP󰲧DHCP󰲧server
Espressif
! /!8 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals