diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 854086f..a959836 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -371,20 +371,21 @@ bool WiFiManager::startAP(){ } // start soft AP with password or anonymous + // default channel is 1 here and in esplib, @todo just change to default remove conditionals if (_apPassword != "") { if(channel>0){ - ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str(),channel); + ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str(),channel,_apHidden); } else{ - ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str());//password option + ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str(),1,_apHidden);//password option } } else { DEBUG_WM(DEBUG_VERBOSE,F("AP has anonymous access!")); if(channel>0){ - ret = WiFi.softAP(_apName.c_str(),"",channel); + ret = WiFi.softAP(_apName.c_str(),"",channel,_apHidden); } else{ - ret = WiFi.softAP(_apName.c_str()); + ret = WiFi.softAP(_apName.c_str(),"",1,_apHidden); } } @@ -2285,6 +2286,15 @@ void WiFiManager::setWiFiAPChannel(int32_t channel){ _apChannel = channel; } +/** + * set the soft ap hidden + * @param bool wifi ap hidden, default is false + */ +void WiFiManager::setWiFiAPHidden(bool hidden){ + _apHidden = hidden; +} + + /** * toggle showing erase wifi config button on info page * @param boolean enabled diff --git a/WiFiManager.h b/WiFiManager.h index b1728b7..e6fa349 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -257,7 +257,8 @@ class WiFiManager void setShowInfoErase(boolean enabled); // set ap channel void setWiFiAPChannel(int32_t channel); - + // set ap hidden + void setWiFiAPHidden(bool hidden); // default false // set custom menu // set custom menu items and order @@ -339,6 +340,7 @@ class WiFiManager bool _disableSTAConn = true; // disable sta when starting ap, if sta is not connected ( stability ) bool _channelSync = false; // use same wifi sta channel when starting ap int32_t _apChannel = 0; // channel to use for ap + bool _apHidden = false; // store softap hidden value #ifdef ESP32 static uint8_t _lastconxresulttmp; // tmp var for esp32 callback diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 3044d8a..7b5e3ec 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -175,6 +175,9 @@ void setup() { // set channel wm.setWiFiAPChannel(13); + // set AP hidden + // wm.setAPHidden(true); + // set configrportal timeout wm.setConfigPortalTimeout(120); // wm.startConfigPortal("AutoConnectAP", "password");