Skip to content

Commit

Permalink
Added channel, ssid scan (esp8266#4636)
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
dtworth authored and devyte committed Apr 13, 2018
1 parent b08d282 commit 7820fb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ std::function<void(int)> ESP8266WiFiScanClass::_onComplete;
* Start scan WiFi networks available
* @param async run in async mode
* @param show_hidden show hidden networks
* @param channel scan only this channel (0 for all channels)
* @param ssid* scan for only this ssid (NULL for all ssid's)
* @return Number of discovered networks
*/
int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden) {
int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden, uint8 channel, uint8* ssid) {
if(ESP8266WiFiScanClass::_scanStarted) {
return WIFI_SCAN_RUNNING;
}
Expand All @@ -84,6 +86,8 @@ int8_t ESP8266WiFiScanClass::scanNetworks(bool async, bool show_hidden) {

struct scan_config config;
memset(&config, 0, sizeof(config));
config.ssid = ssid;
config.channel = channel;
config.show_hidden = show_hidden;
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiScanClass::_scanDone))) {
ESP8266WiFiScanClass::_scanComplete = false;
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ESP8266WiFiScanClass {

public:

int8_t scanNetworks(bool async = false, bool show_hidden = false);
int8_t scanNetworks(bool async = false, bool show_hidden = false, uint8 channel = 0, uint8* ssid = NULL);
void scanNetworksAsync(std::function<void(int)> onComplete, bool show_hidden = false);

int8_t scanComplete();
Expand Down

0 comments on commit 7820fb7

Please sign in to comment.