mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-22 02:32:10 +10:00
clean up
This commit is contained in:
+11
-19
@@ -190,7 +190,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(WiFi.status() == WL_CONNECTED){
|
if(WiFi.status() == WL_CONNECTED){
|
||||||
DEBUG_WM("reconnecting to set new hostname");
|
DEBUG_WM(F("reconnecting to set new hostname"));
|
||||||
// WiFi.reconnect(); // This does not reset dhcp
|
// WiFi.reconnect(); // This does not reset dhcp
|
||||||
WiFi_Disconnect();
|
WiFi_Disconnect();
|
||||||
delay(200); // do not remove, need a delay for disconnect to change status()
|
delay(200); // do not remove, need a delay for disconnect to change status()
|
||||||
@@ -203,15 +203,6 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
|||||||
//connected
|
//connected
|
||||||
DEBUG_WM(F("IP Address:"),WiFi.localIP());
|
DEBUG_WM(F("IP Address:"),WiFi.localIP());
|
||||||
_lastconxresult = WL_CONNECTED;
|
_lastconxresult = WL_CONNECTED;
|
||||||
|
|
||||||
if(_hostname != ""){
|
|
||||||
#ifdef ESP8266
|
|
||||||
DEBUG_WM("hostname: ",WiFi.hostname());
|
|
||||||
#elif defined(ESP32)
|
|
||||||
DEBUG_WM("hostname: ",WiFi.getHostname());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// not connected start configportal
|
// not connected start configportal
|
||||||
@@ -220,6 +211,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
|||||||
|
|
||||||
// CONFIG PORTAL
|
// CONFIG PORTAL
|
||||||
bool WiFiManager::startAP(){
|
bool WiFiManager::startAP(){
|
||||||
|
bool ret = true;
|
||||||
DEBUG_WM(F("StartAP with SSID: "),_apName);
|
DEBUG_WM(F("StartAP with SSID: "),_apName);
|
||||||
|
|
||||||
// setup optional soft AP static ip config
|
// setup optional soft AP static ip config
|
||||||
@@ -228,8 +220,6 @@ bool WiFiManager::startAP(){
|
|||||||
WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn);
|
WiFi.softAPConfig(_ap_static_ip, _ap_static_gw, _ap_static_sn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
// start soft AP with password or anonymous
|
// start soft AP with password or anonymous
|
||||||
if (_apPassword != "") {
|
if (_apPassword != "") {
|
||||||
ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str());//password option
|
ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str());//password option
|
||||||
@@ -245,17 +235,19 @@ bool WiFiManager::startAP(){
|
|||||||
delay(500); // slight delay to make sure we get an AP IP
|
delay(500); // slight delay to make sure we get an AP IP
|
||||||
DEBUG_WM(F("AP IP address:"),WiFi.softAPIP());
|
DEBUG_WM(F("AP IP address:"),WiFi.softAPIP());
|
||||||
|
|
||||||
|
// set ap hostname
|
||||||
|
#ifdef ESP32
|
||||||
|
if(ret && _hostname != ""){
|
||||||
|
WiFi.softAPsetHostname(_hostname);
|
||||||
|
DEBUG_WM(F("aphostname: "),WiFi.softAPgetHostname());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// do AP callback if set
|
// do AP callback if set
|
||||||
if ( _apcallback != NULL) {
|
if ( _apcallback != NULL) {
|
||||||
_apcallback(this);
|
_apcallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ESP32
|
|
||||||
if(ret && _hostname != ""){
|
|
||||||
WiFi.softAPsetHostname(_hostname);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user