8000 Fixes #8053 · dok-net/arduino-esp8266@4449800 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4449800

Browse files
committed
Fixes esp8266#8053
1 parent 84a59aa commit 4449800

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ std::function<void(int)> ESP8266WiFiScanClass::_onComplete;
6060

6161
/**
6262
* Start scan WiFi networks available
63-
* @param async run in async mode
64-
* @param show_hidden show hidden networks
65-
* @param channel scan only this channel (0 for all channels)
66-
* @param ssid* scan for only this ssid (NULL for all ssid's)
63+
* @param async run in async mode
64+
* @param show_hidden show hidden networks
65+
* @param passive scan type passive or active
66+
* @param max_ms_per_chan scan time per channel
67+
* @param channel scan only this channel (0 for all channels)
68+
* @param ssid* scan for only this ssid (NULL for all ssid's)
6769
* @return Number of discovered networks
6870
*/
69-
int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 channel, uint8* ssid) {
71+
int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, bool passive, uint32_t max_ms_per_chan, uint8_t channel, uint8* ssid) {
7072
if(ESP8266WiFiScanClass::_scanStarted) {
7173
return WIFI_SCAN_RUNNING;
7274
}
@@ -87,6 +89,14 @@ int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 ch
8789
config.ssid = ssid;
8890
config.channel = channel;
8991
config.show_hidden = show_hidden;
92+
if(passive){
93+
config.scan_type = WIFI_SCAN_TYPE_PASSIVE;
94+
config.scan_time.passive = max_ms_per_chan;
95+
} else {
96+
config.scan_type = WIFI_SCAN_TYPE_ACTIVE;
97+
config.scan_time.active.min = 100;
98+
config.scan_time.active.max = max_ms_per_chan;
99+
}
90100
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiScanClass::_scanDone))) {
91101
ESP8266WiFiScanClass::_scanComplete = false;
92102
ESP8266WiFiScanClass::_scanStarted = true;

libraries/ESP8266WiFi/src/ESP8266WiFiScan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ESP8266WiFiScanClass {
3434

3535
public:
3636

37-
int8_t scanNetworks(bool async = false, bool show_hidden = false, uint8 channel = 0, uint8* ssid = NULL);
37+
int8_t scanNetworks(bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300, uint8_t channel = 0, uint8* ssid = NULL);
3838
void scanNetworksAsync(std::function<void(int)> onComplete, bool show_hidden = false);
3939

4040
int8_t scanComplete();

0 commit comments

Comments
 (0)
0