Skip to content

Commit 9dcc5a1

Browse files
committed
improve mode handling for ESP8266WiFiClass::scanNetworks and ESP8266WiFiClass::beginSmartConfig
1 parent 2af8acd commit 9dcc5a1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,14 @@ void ESP8266WiFiClass::_scanDone(void* result, int status)
333333

334334
int8_t ESP8266WiFiClass::scanNetworks()
335335
{
336-
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
337-
{
336+
if(_useApMode) {
337+
// turn on AP+STA mode
338338
mode(WIFI_AP_STA);
339+
} else {
340+
// turn on STA mode
341+
mode(WIFI_STA);
339342
}
343+
340344
int status = wifi_station_get_connect_status();
341345
if (status != STATION_GOT_IP && status != STATION_IDLE)
342346
{
@@ -508,9 +512,12 @@ void ESP8266WiFiClass::beginSmartConfig()
508512
if (_smartConfigStarted)
509513
return;
510514

511-
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
512-
{
515+
if(_useApMode) {
516+
// turn on AP+STA mode
513517
mode(WIFI_AP_STA);
518+
} else {
519+
// turn on STA mode
520+
mode(WIFI_STA);
514521
}
515522

516523
_smartConfigStarted = true;

0 commit comments

Comments
 (0)