3

When in WIFI_AP mode all goes well, but when in WIFI_STA mode it is still in WIFI_STA_AP mode.

How do I set the WiFi to station only with no software access point available.

  if(wmode == "AP") {
     Serial.println("Starting in AP mode");
     WiFi.mode(WIFI_AP);
     WiFi.softAP(ssid, pwd);
     WiFi.softAPConfig(charToIPAddress(ip), charToIPAddress(gateway), mask); 
  } else if (wmode == "STA") {
     Serial.println("Starting in STA mode");
     WiFi.mode(WIFI_STA);
     WiFi.begin(ssid, pwd);
     WiFi.config(charToIPAddress(ip), charToIPAddress(gateway), mask);
  }

EDIT: this is not about wmode, this code's if statement works fine, re: arduino String class operator (shorthand)

ChrisAdmin
  • 982
  • 1
  • 12
  • 32

1 Answers1

4

The ESP8266 seems to OR the mode parameter when you use WiFi.begin instead of just setting it, and also remembers what mode is it was in previously (Through reboots, for example). Calling WiFi.disconnect(); followed by WiFi.softAPdisconnect(true); should explicitly tell the ESP to disable all currently running WiFi operations - Be it infrastructure mode, or AP mode - And then you can define what mode it should be.

Dawn Minion
  • 905
  • 5
  • 12