EasyManua.ls Logo

Espressif Systems ESP8266EX - Scan Nearby Aps

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
unique and exclusive. If users want to reset the MAC address, the uniqueness of the
MAC address should be assured.
2. Set ESP8266 to Station+SoftAP mode.
󰲧󰲧󰲧󰲧Wi-Fi_set_opmode(STATIONAP_MODE);
3. Read the MAC addresses of the Station and SoftAP interfaces.
󰲧󰲧󰲧󰲧Wi-Fi_get_macaddr(SOFTAP_IF,󰲧sofap_mac);
󰲧󰲧󰲧󰲧Wi-Fi_get_macaddr(STATION_IF,󰲧sta_mac);
4. Set the MAC addresses of the Station and SoftAP interfaces. The setting of MAC
addresses is not stored in the flash, and the setting can only be done when the
corresponding interface is enabled first.
󰲧󰲧󰲧󰲧char󰲧sofap_mac[6]󰲧=󰲧{0x16,󰲧0x34,󰲧0x56,󰲧0x78,󰲧0x90,󰲧0xab};
󰲧󰲧󰲧󰲧char󰲧sta_mac[6]󰲧=󰲧{0x12,󰲧0x34,󰲧0x56,󰲧0x78,󰲧0x90,󰲧0xab};
󰲧󰲧󰲧󰲧Wi-Fi_set_macaddr(SOFTAP_IF,󰲧sofap_mac);
󰲧󰲧󰲧󰲧Wi-Fi_set_macaddr(STATION_IF,󰲧sta_mac);
5. Compile the application program, generate firmware and download it into the ESP8266
module.
6. Power off the module, and change it to operation mode, then power on the module and
run the program.
Result:
ESP8266󰲧station󰲧MAC󰲧:18:fe:34:97:f7:40
ESP8266󰲧soft-AP󰲧MAC󰲧:1a:fe:34:97:f7:40
ESP8266󰲧station󰲧new󰲧MAC󰲧:12:34:56:78:90:ab
ESP8266󰲧soft-AP󰲧new󰲧MAC󰲧:16:34:56:78:90:ab
3.2.7. Scan Nearby APs
1. Set ESP8266 to work in Station mode, or Station+SoftAP mode.
󰲧󰲧󰲧󰲧Wi-Fi_set_opmode(STATIONAP_MODE);
2. Scan nearby APs.
If the first parameter of Wi-Fi_station_scan is NULL, all APs around will be scanned; if
certain information including SSID and channel is defined in the first parameter, then that
specific AP info will be returned.
󰲧󰲧󰲧󰲧Wi-Fi_station_scan(NULL,scan_done);
Notice:
Mac addresses are different for the two distinct modes of ESP8266 (SoftAP and Station). Please do
not set the same MAC address for ESP8266 SoftAP and ESP8266 Station.
Bit 0 of the first byte of the MAC address should not be 1. For example, the MAC address can be set
as “1a:fe:36:97:d5:7b”, but not as “15:fe:36:97:d5:7b”.
Espressif
! /!11 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals