testing sta ap modes

This commit is contained in:
tablatronix
2018-08-23 13:35:07 -05:00
parent 2074d85da7
commit 8f03b5df10
2 changed files with 10 additions and 6 deletions
+7 -6
View File
@@ -328,10 +328,12 @@ bool WiFiManager::startAP(){
// start soft AP with password or anonymous
if (_apPassword != "") {
ret = WiFi.softAP(_apName.c_str(), _apPassword.c_str());//password option
if(_channelSync) ret = WiFi.softAxP(_apName.c_str(), _apPassword.c_str(),WiFi.channel());
else ret = WiFi.softAxP(_apName.c_str(), _apPassword.c_str());//password option
} else {
DEBUG_WM(DEBUG_VERBOSE,F("AP has anonymous access!"));
ret = WiFi.softAP(_apName.c_str());
if(_channelSync) ret = WiFi.softAP(_apName.c_str(),"",WiFi.channel());
else ret = WiFi.softAP(_apName.c_str());
}
if(_debugLevel > DEBUG_DEV) debugSoftAPConfig();
@@ -465,11 +467,9 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
if(_apName == "") _apName = _wifissidprefix + "_" + String(WIFI_getChipId());
if(!validApPassword()) return false;
bool disableSTA = false; // debug, always disable sta
// HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond
// @todo sometimes still cannot connect to AP for no known reason, no events in log either
if(!WiFi.isConnected() || disableSTA){
if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){
// this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect`
WiFi_Disconnect();
WiFi_enableSTA(false);
@@ -652,7 +652,8 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) {
//@todo catch failures in set_config
// make sure sta is on before `begin` so it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !)
if(cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect
if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status
// if ssid argument provided connect to that
if (ssid != "") {
+3
View File
@@ -284,6 +284,9 @@ class WiFiManager
unsigned long _lastscan = 0; // ms
int _cpclosedelay = 2000; // delay before wifisave, prevents captive portal from closing to fast.
bool _cleanConnect = true; // disconnect before connect in connectwifi, increases stability on connects
bool _disableSTA = false; // disable sta when starting ap, always
bool _disableSTAConn = true; // disable sta when starting ap, if sta is not connected ( stability )
bool _channelSync = false; // use wifi channel when starting ap
#ifdef ESP32
static uint8_t _lastconxresulttmp; // tmp var for esp32 callback