Unverified Commit 21228117 authored by Me No Dev's avatar Me No Dev Committed by GitHub

feat(scan): Allow setting scan timeout in milliseconds (#9738)

parent 58e61efa
...@@ -44,10 +44,14 @@ extern "C" { ...@@ -44,10 +44,14 @@ extern "C" {
bool WiFiScanClass::_scanAsync = false; bool WiFiScanClass::_scanAsync = false;
uint32_t WiFiScanClass::_scanStarted = 0; uint32_t WiFiScanClass::_scanStarted = 0;
uint32_t WiFiScanClass::_scanTimeout = 10000; uint32_t WiFiScanClass::_scanTimeout = 60000;
uint16_t WiFiScanClass::_scanCount = 0; uint16_t WiFiScanClass::_scanCount = 0;
void *WiFiScanClass::_scanResult = 0; void *WiFiScanClass::_scanResult = 0;
void WiFiScanClass::setScanTimeout(uint32_t ms) {
WiFiScanClass::_scanTimeout = ms;
}
/** /**
* Start scan WiFi networks available * Start scan WiFi networks available
* @param async run in async mode * @param async run in async mode
...@@ -60,7 +64,6 @@ int16_t ...@@ -60,7 +64,6 @@ int16_t
return WIFI_SCAN_RUNNING; return WIFI_SCAN_RUNNING;
} }
WiFiScanClass::_scanTimeout = max_ms_per_chan * 20;
WiFiScanClass::_scanAsync = async; WiFiScanClass::_scanAsync = async;
WiFi.enableSTA(true); WiFi.enableSTA(true);
...@@ -92,7 +95,7 @@ int16_t ...@@ -92,7 +95,7 @@ int16_t
if (WiFiScanClass::_scanAsync) { if (WiFiScanClass::_scanAsync) {
return WIFI_SCAN_RUNNING; return WIFI_SCAN_RUNNING;
} }
if (WiFiGenericClass::waitStatusBits(WIFI_SCAN_DONE_BIT, 10000)) { if (WiFiGenericClass::waitStatusBits(WIFI_SCAN_DONE_BIT, _scanTimeout)) {
return (int16_t)WiFiScanClass::_scanCount; return (int16_t)WiFiScanClass::_scanCount;
} }
} }
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
class WiFiScanClass { class WiFiScanClass {
public: public:
void setScanTimeout(uint32_t ms);
int16_t scanNetworks( int16_t scanNetworks(
bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300, uint8_t channel = 0, const char *ssid = nullptr, bool async = false, bool show_hidden = false, bool passive = false, uint32_t max_ms_per_chan = 300, uint8_t channel = 0, const char *ssid = nullptr,
const uint8_t *bssid = nullptr const uint8_t *bssid = nullptr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment