Skip to content

Commit 1ea9d89

Browse files
Links2004igrr
authored andcommitted
improve mode handling for ESP8266WiFiClass::scanNetworks and ESP8266WiFiClass::beginSmartConfig
1 parent 9862bf6 commit 1ea9d89

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
@@ -328,10 +328,14 @@ void ESP8266WiFiClass::_scanDone(void* result, int status)
328328

329329
int8_t ESP8266WiFiClass::scanNetworks()
330330
{
331-
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
332-
{
331+
if(_useApMode) {
332+
// turn on AP+STA mode
333333
mode(WIFI_AP_STA);
334+
} else {
335+
// turn on STA mode
336+
mode(WIFI_STA);
334337
}
338+
335339
int status = wifi_station_get_connect_status();
336340
if (status != STATION_GOT_IP && status != STATION_IDLE)
337341
{
@@ -503,9 +507,12 @@ void ESP8266WiFiClass::beginSmartConfig()
503507
if (_smartConfigStarted)
504508
return;
505509

506-
if ((wifi_get_opmode() & 1) == 0)//1 and 3 have STA enabled
507-
{
510+
if(_useApMode) {
511+
// turn on AP+STA mode
508512
mode(WIFI_AP_STA);
513+
} else {
514+
// turn on STA mode
515+
mode(WIFI_STA);
509516
}
510517

511518
_smartConfigStarted = true;

0 commit comments

Comments
 (0)