This commit is contained in:
tablatronix
2022-09-16 10:21:34 -05:00
parent 7bdcfd501e
commit 297a1af260
2 changed files with 60 additions and 3 deletions
+9 -3
View File
@@ -828,13 +828,19 @@ boolean WiFiManager::process(){
return false;
}
uint8_t state = processConfigPortal();
uint8_t state = processConfigPortal(); // state is WL_IDLE or WL_CONNECTED/FAILED
return state == WL_CONNECTED;
}
return false;
}
//using esp wl_status enums as returns for now, should be fine
/**
* [processConfigPortal description]
* using esp wl_status enums as returns for now, should be fine
* returns WL_IDLE_STATUS or WL_CONNECTED/WL_CONNECT_FAILED upon connect/save flag
*
* @return {[type]} [description]
*/
uint8_t WiFiManager::processConfigPortal(){
if(configPortalActive){
//DNS handler
@@ -2354,7 +2360,7 @@ void WiFiManager::handleNotFound() {
*/
boolean WiFiManager::captivePortal() {
#ifdef WM_DEBUG_LEVEL
DEBUG_WM(DEBUG_DEV,"-> " + server->hostHeader());
DEBUG_WM(DEBUG_MAX,"-> " + server->hostHeader());
#endif
if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful
@@ -0,0 +1,51 @@
// wifi_basic.ino
#include <Arduino.h>
#include <WiFi.h>
// #define NVSERASE
#ifdef NVSERASE
#include <nvs.h>
#include <nvs_flash.h>
#endif
void setup(){
Serial.begin(115200);
delay(2000);
Serial.println("Startup....");
#ifdef NVSERASE
esp_err_t err;
err = nvs_flash_init();
err = nvs_flash_erase();
#endif
Serial.setDebugOutput(true);
WiFi.begin("hellowifi","noonehere");
while (WiFi.status() != WL_CONNECTED && millis()<15000) {
delay(500);
Serial.print(".");
}
if(WiFi.status() == WL_CONNECTED){
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
// Serial.println(WiFi.localIP());
}
else {
Serial.println("WiFi NOT CONNECTED, starting ap");
///////////////
/// BUG
// WiFi.enableSTA(false); // BREAKS softap start, says ok BUT no ap found
delay(2000);
WiFi.softAP("espsoftap","12345678");
}
}
void loop(){
}