Skip to content

Commit 7820fb7

Browse files
dtworthdevyte
authored andcommitted
Added channel, ssid scan (#4636)
* Added channel, ssid scan Overloaded scanNetworks so scan can occur on a single channel and/or for a particular ssid. * Added parameters to scanNetworks channel number and ssid have been added as optional parameters to the orginal scanNetworks()
1 parent b08d282 commit 7820fb7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ std::function<void(int)> ESP8266WiFiScanClass::_onComplete;
6464
* Start scan WiFi networks available
6565
* @param async run in async mode
6666
* @param show_hidden show hidden networks
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) {
71+
int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 channel, uint8* ssid) {
7072
if(ESP8266WiFiScanClass::_scanStarted) {
7173
return WIFI_SCAN_RUNNING;
7274
}
@@ -84,6 +86,8 @@ int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden) {
8486

8587
struct scan_config config;
8688
memset(&config, 0, sizeof(config));
89+
config.ssid = ssid;
90+
config.channel = channel;
8791
config.show_hidden = show_hidden;
8892
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiScanClass::_scanDone))) {
8993
ESP8266WiFiScanClass::_scanComplete = false;

libraries/ESP8266WiFi/src/ESP8266WiFiScan.h

+1-1
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);
37+
int8_t scanNetworks(bool async = false, bool show_hidden = false, uint8 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)