Remove old and modified libs, switch to ESPAsyncWebserver, add support for ESP32-H2 and multiple Ethernet modules (#455)
* Asyncwebserver * Squashed commit of the following: commit 575ef02f593918ec6654c87407a4d11fc17071b8 Author: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 17:56:11 2024 +0200 merge master commit 35e5adf4ecd80f9829e8801181f35dd2c1d94759 Merge: a2cc7be221adca01Author: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 17:41:04 2024 +0200 Merge branch 'master' of github.com:technyon/nuki_hub into DM9051 commit a2cc7be2954cbd8767ab8186296c0b14134d1d0b Author: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 10:51:50 2024 +0200 update nuki ble commit 20c809f3dca28b29b219d1ff3a183f1981316de5 Author: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 10:44:46 2024 +0200 backup commit dd41c218efb5270f5efeb734e64dff695920db16 Merge: 153000b5e84b944aAuthor: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 10:40:03 2024 +0200 Merge branch 'master' of github.com:technyon/nuki_hub into DM9051 commit 153000b5b1af7df1fbeb5263df94eb26f689cc0a Author: technyon <j.o.schuemann@gmx.de> Date: Mon Aug 12 10:23:07 2024 +0200 fix linker error commit a93bbfbfc4301e46ff3696a763dd13c6c89efefb Author: technyon <j.o.schuemann@gmx.de> Date: Sun Aug 11 11:27:07 2024 +0200 backup commit f611c75ce8c35f829bcad6cf7e86188f4b3ec331 Merge: f1964917063fbab6Author: technyon <j.o.schuemann@gmx.de> Date: Sun Aug 11 11:24:47 2024 +0200 merge master commit f1964917b4dade3920f1ecdb699c58630199e6da Author: technyon <j.o.schuemann@gmx.de> Date: Sat Aug 10 15:17:45 2024 +0200 update platformio.ini commit f448e5e8a7e93be38e09e2ab0b622199a3721af6 Author: technyon <j.o.schuemann@gmx.de> Date: Sat Aug 10 11:28:09 2024 +0200 add SPIClass instance for DM9051 commit 1f190e9aa08033535a2eb442a92e6e20409bbda1 Author: technyon <j.o.schuemann@gmx.de> Date: Sat Aug 10 11:22:26 2024 +0200 add definitions and constructor for DM9051 commit 726b3602ae91594ee1210ad5b6714f75cc5e42a7 Merge: 50a2eb134af90cbcAuthor: technyon <j.o.schuemann@gmx.de> Date: Sat Aug 10 10:19:34 2024 +0200 merge master commit 50a2eb136d75d90921f1c6974f18bc107bddc123 Author: technyon <j.o.schuemann@gmx.de> Date: Fri Aug 9 11:52:09 2024 +0200 add comment commit 9437e485cae169efdf8e5a7bf188a1c7e792d1e5 Author: technyon <j.o.schuemann@gmx.de> Date: Sun Aug 4 08:29:21 2024 +0200 move LAN8720 definitions to seperate file * Remove Core 2 Ethernet library * Custom Ethernet * GPIO and Preferences * H2
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include "WiFiManager.h"
|
||||
#include "hardware/WifiEthServer.h"
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
|
||||
@@ -292,6 +291,11 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
DEBUG_WM(F("AutoConnect"));
|
||||
#endif
|
||||
|
||||
// no getter for autoreconnectpolicy before this
|
||||
// https://github.com/esp8266/Arduino/pull/4359
|
||||
// so we must force it on else, if not connectimeout then waitforconnectionresult gets stuck endless loop
|
||||
WiFi_autoReconnect();
|
||||
|
||||
// bool wifiIsSaved = getWiFiIsSaved();
|
||||
bool wifiIsSaved = true; // workaround until I can check esp32 wifiisinit and has nvs
|
||||
|
||||
@@ -334,11 +338,6 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
|
||||
_usermode = WIFI_STA; // When using autoconnect , assume the user wants sta mode on permanently.
|
||||
|
||||
// no getter for autoreconnectpolicy before this
|
||||
// https://github.com/esp8266/Arduino/pull/4359
|
||||
// so we must force it on else, if not connectimeout then waitforconnectionresult gets stuck endless loop
|
||||
WiFi_autoReconnect();
|
||||
|
||||
#ifdef ESP8266
|
||||
if(_hostname != ""){
|
||||
setupHostname(true);
|
||||
@@ -629,56 +628,46 @@ boolean WiFiManager::configPortalHasTimeout(){
|
||||
|
||||
void WiFiManager::setupHTTPServer(){
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("Starting Web Portal"));
|
||||
#endif
|
||||
|
||||
if(_httpPort != 80) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("http server started with custom port: "),_httpPort); // @todo not showing ip
|
||||
#endif
|
||||
}
|
||||
|
||||
server.reset(new WM_WebServer(new WifiEthServer(80)));
|
||||
// This is not the safest way to reset the webserver, it can cause crashes on callbacks initilized before this and since its a shared pointer...
|
||||
|
||||
if ( _webservercallback != NULL) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("[CB] _webservercallback calling"));
|
||||
#endif
|
||||
_webservercallback(); // @CALLBACK
|
||||
}
|
||||
// @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
|
||||
server.reset(new WM_WebServer(_httpPort));
|
||||
|
||||
/* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */
|
||||
server->on(String(FPSTR(R_wifi)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleWifi, this,std::placeholders::_1,true));
|
||||
server->on(String(FPSTR(R_wifinoscan)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleWifi, this,std::placeholders::_1,false));
|
||||
server->on(String(FPSTR(R_erase)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleErase, this,std::placeholders::_1,false));
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
server->on(String(FPSTR(R_root)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleRoot, this,_1));
|
||||
server->on(String(FPSTR(R_wifisave)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleWifiSave, this,_1));
|
||||
server->on(String(FPSTR(R_info)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleInfo, this,_1));
|
||||
server->on(String(FPSTR(R_param)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleParam, this,_1));
|
||||
server->on(String(FPSTR(R_paramsave)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleParamSave, this,_1));
|
||||
server->on(String(FPSTR(R_restart)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleReset, this,_1));
|
||||
server->on(String(FPSTR(R_exit)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleExit, this,_1));
|
||||
server->on(String(FPSTR(R_close)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleClose, this,_1));
|
||||
server->on(String(FPSTR(R_status)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleWiFiStatus, this,_1));
|
||||
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this, _1));
|
||||
|
||||
// G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102
|
||||
server->on(WM_G(R_root), std::bind(&WiFiManager::handleRoot, this));
|
||||
server->on(WM_G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true));
|
||||
server->on(WM_G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false));
|
||||
server->on(WM_G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on(WM_G(R_info), std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on(WM_G(R_param), std::bind(&WiFiManager::handleParam, this));
|
||||
server->on(WM_G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this));
|
||||
server->on(WM_G(R_restart), std::bind(&WiFiManager::handleReset, this));
|
||||
server->on(WM_G(R_exit), std::bind(&WiFiManager::handleExit, this));
|
||||
server->on(WM_G(R_close), std::bind(&WiFiManager::handleClose, this));
|
||||
server->on(WM_G(R_erase), std::bind(&WiFiManager::handleErase, this, false));
|
||||
server->on(WM_G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this));
|
||||
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
|
||||
|
||||
server->on(WM_G(R_update), std::bind(&WiFiManager::handleUpdate, this));
|
||||
server->on(WM_G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this));
|
||||
|
||||
server->on(String(FPSTR(R_update)).c_str(), HTTP_ANY, std::bind(&WiFiManager::handleUpdate, this, _1));
|
||||
server->on(String(FPSTR(R_updatedone)).c_str(), HTTP_POST,std::bind(&WiFiManager::handleUpdateDone, this, _1), std::bind(&WiFiManager::handleUpdating, this, _1,_2,_3,_4,_5,_6));
|
||||
}
|
||||
server->begin(); // Web server start
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("HTTP server started"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void WiFiManager::teardownHTTPServer(){
|
||||
|
||||
}
|
||||
|
||||
void WiFiManager::setupDNSD(){
|
||||
dnsServer.reset(new DNSServer());
|
||||
|
||||
if(_httpPort != 80) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("http server starting with custom port: "),_httpPort); // @todo not showing ip
|
||||
#endif
|
||||
}
|
||||
|
||||
setupHTTPServer();
|
||||
|
||||
/* Setup the DNS server redirecting all the domains to the apIP */
|
||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -824,7 +813,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
|
||||
if(!configPortalActive) break;
|
||||
|
||||
yield(); // watchdog
|
||||
vTaskDelay( 50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -881,7 +870,11 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
}
|
||||
|
||||
//HTTP handler
|
||||
#ifndef WM_ASYNCWEBSERVER
|
||||
server->handleClient();
|
||||
#endif
|
||||
|
||||
if(_rebootNeeded) reboot();
|
||||
|
||||
// Waiting for save...
|
||||
if(connect) {
|
||||
@@ -978,21 +971,27 @@ bool WiFiManager::shutdownConfigPortal(){
|
||||
dnsServer->processNextRequest();
|
||||
}
|
||||
|
||||
#ifndef WM_ASYNCWEBSERVER
|
||||
//HTTP handler
|
||||
server->handleClient();
|
||||
#endif
|
||||
|
||||
// @todo what is the proper way to shutdown and free the server up
|
||||
// debug - many open issues aobut port not clearing for use with other servers
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
server->end();
|
||||
#else
|
||||
server->stop();
|
||||
#endif
|
||||
server.reset();
|
||||
|
||||
dnsServer->stop(); // free heap ?
|
||||
dnsServer.reset();
|
||||
|
||||
WiFi.scanDelete(); // free wifi scan results
|
||||
|
||||
if(!configPortalActive) return false;
|
||||
|
||||
dnsServer->stop(); // free heap ?
|
||||
dnsServer.reset();
|
||||
|
||||
// turn off AP
|
||||
// @todo bug workaround
|
||||
// https://github.com/esp8266/Arduino/issues/3793
|
||||
@@ -1126,7 +1125,7 @@ bool WiFiManager::wifiConnectNew(String ssid, String pass,bool connect){
|
||||
if (_findBestRSSI) {
|
||||
WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
|
||||
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("find best RSSI: TRUE"));
|
||||
#endif
|
||||
@@ -1206,7 +1205,7 @@ bool WiFiManager::wifiConnectDefault(){
|
||||
DEBUG_WM(F("Connecting to SAVED AP:"),ssid);
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Using Password:"),pass);
|
||||
#endif
|
||||
|
||||
|
||||
ret = WiFi_enableSTA(true,storeSTAmode);
|
||||
delay(500); // THIS DELAY ?
|
||||
|
||||
@@ -1424,8 +1423,10 @@ String WiFiManager::getHTTPHead(String title){
|
||||
return page;
|
||||
}
|
||||
|
||||
void WiFiManager::HTTPSend(const String &content){
|
||||
server->send(200, FPSTR(HTTP_HEAD_CT), content);
|
||||
void WiFiManager::HTTPSend(AsyncWebServerRequest *request, String page){
|
||||
AsyncWebServerResponse *response = request->beginResponse(200,FPSTR(HTTP_HEAD_CT), page);
|
||||
response->addHeader(FPSTR(HTTP_HEAD_CL), String(page.length()));
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1440,32 +1441,17 @@ void WiFiManager::handleRequest() {
|
||||
// bool authenticate(const char * username, const char * password);
|
||||
// bool authenticateDigest(const String& username, const String& H1);
|
||||
// void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("") );
|
||||
|
||||
// 2.3 NO AUTH available
|
||||
bool testauth = false;
|
||||
if(!testauth) return;
|
||||
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("DOING AUTH"));
|
||||
bool res = server->authenticate("admin","12345");
|
||||
if(!res){
|
||||
#ifndef WM_NOAUTH
|
||||
server->requestAuthentication(HTTPAuthMethod::BASIC_AUTH); // DIGEST_AUTH
|
||||
#endif
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("AUTH FAIL"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTPD CALLBACK root or redirect to captive portal
|
||||
*/
|
||||
void WiFiManager::handleRoot() {
|
||||
void WiFiManager::handleRoot(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Root"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
if (captivePortal(request)) return; // If captive portal redirect instead of displaying the page
|
||||
handleRequest();
|
||||
String page = getHTTPHead(_title); // @token options @todo replace options with title
|
||||
String str = FPSTR(HTTP_ROOT_MAIN); // @todo custom title
|
||||
@@ -1477,7 +1463,7 @@ void WiFiManager::handleRoot() {
|
||||
reportStatus(page);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
if(_preloadwifiscan) WiFi_scanNetworks(_scancachetime,true); // preload wifiscan throttled, async
|
||||
// @todo buggy, captive portals make a query on every page load, causing this to run every time in addition to the real page load
|
||||
// I dont understand why, when you are already in the captive portal, I guess they want to know that its still up and not done or gone
|
||||
@@ -1487,20 +1473,18 @@ void WiFiManager::handleRoot() {
|
||||
/**
|
||||
* HTTPD CALLBACK Wifi config page handler
|
||||
*/
|
||||
void WiFiManager::handleWifi(boolean scan) {
|
||||
void WiFiManager::handleWifi(AsyncWebServerRequest *request,bool scan = true) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Wifi"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titlewifi)); // @token titlewifi
|
||||
if (scan) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
// DEBUG_WM(WM_DEBUG_DEV,"refresh flag:",server->hasArg(F("refresh")));
|
||||
// DEBUG_WM(WM_DEBUG_DEV,"refresh flag:",request->hasArg(F("refresh")));
|
||||
#endif
|
||||
WiFi_scanNetworks(server->hasArg(F("refresh")),false); //wifiscan, force if arg refresh
|
||||
WiFi_scanNetworks(request->hasArg(F("refresh")),false); //wifiscan, force if arg refresh
|
||||
page += getScanItemOut();
|
||||
}
|
||||
String pitem = "";
|
||||
@@ -1536,7 +1520,7 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
reportStatus(page);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Sent config page"));
|
||||
@@ -1546,13 +1530,11 @@ void WiFiManager::handleWifi(boolean scan) {
|
||||
/**
|
||||
* HTTPD CALLBACK Wifi param page handler
|
||||
*/
|
||||
void WiFiManager::handleParam(){
|
||||
void WiFiManager::handleParam(AsyncWebServerRequest *request){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Param"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titleparam)); // @token titlewifi
|
||||
|
||||
@@ -1568,7 +1550,7 @@ void WiFiManager::handleParam(){
|
||||
reportStatus(page);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Sent param page"));
|
||||
@@ -1623,17 +1605,9 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){
|
||||
// DEBUG_WM(WM_DEBUG_DEV,"scanNetworks force:",force == true);
|
||||
#endif
|
||||
|
||||
// if 0 networks, rescan @note this was a kludge, now disabling to test real cause ( maybe wifi not init etc)
|
||||
// enable only if preload failed?
|
||||
if(_numNetworks == 0 && _autoforcerescan){
|
||||
DEBUG_WM(WM_DEBUG_DEV,"NO APs found forcing new scan");
|
||||
force = true;
|
||||
}
|
||||
|
||||
// if scan is empty or stale (last scantime > _scancachetime), this avoids fast reloading wifi page and constant scan delayed page loads appearing to freeze.
|
||||
if(!_lastscan || (_lastscan>0 && (millis()-_lastscan > _scancachetime))){
|
||||
force = true;
|
||||
}
|
||||
force = false;
|
||||
async = true;
|
||||
force = _lastscan == 0;
|
||||
|
||||
if(force){
|
||||
int8_t res;
|
||||
@@ -1933,38 +1907,34 @@ String WiFiManager::getParamOut(){
|
||||
return page;
|
||||
}
|
||||
|
||||
void WiFiManager::handleWiFiStatus(){
|
||||
void WiFiManager::handleWiFiStatus(AsyncWebServerRequest *request){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP WiFi status "));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page;
|
||||
// String page = "{\"result\":true,\"count\":1}";
|
||||
#ifdef WM_JSTEST
|
||||
page = FPSTR(HTTP_JS);
|
||||
#endif
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTPD CALLBACK save form and redirect to WLAN config page again
|
||||
*/
|
||||
void WiFiManager::handleWifiSave() {
|
||||
void WiFiManager::handleWifiSave(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP WiFi save "));
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Method:"),server->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Method:"),request->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
|
||||
//SAVE/connect here
|
||||
_ssid = server->arg(F("s")).c_str();
|
||||
_pass = server->arg(F("p")).c_str();
|
||||
_ssid = request->arg(F("s")).c_str();
|
||||
_pass = request->arg(F("p")).c_str();
|
||||
|
||||
if(_ssid == "" && _pass != ""){
|
||||
_ssid = WiFi_SSID(true); // password change, placeholder ssid, @todo compare pass to old?, confirm ssid is clean
|
||||
@@ -1976,44 +1946,44 @@ void WiFiManager::handleWifiSave() {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
String requestinfo = "SERVER_REQUEST\n----------------\n";
|
||||
requestinfo += "URI: ";
|
||||
requestinfo += server->uri();
|
||||
requestinfo += request->url();
|
||||
requestinfo += "\nMethod: ";
|
||||
requestinfo += (server->method() == HTTP_GET) ? "GET" : "POST";
|
||||
requestinfo += (request->method() == HTTP_GET) ? "GET" : "POST";
|
||||
requestinfo += "\nArguments: ";
|
||||
requestinfo += server->args();
|
||||
requestinfo += request->args();
|
||||
requestinfo += "\n";
|
||||
for (uint8_t i = 0; i < server->args(); i++) {
|
||||
requestinfo += " " + server->argName(i) + ": " + server->arg(i) + "\n";
|
||||
for (uint8_t i = 0; i < request->args(); i++) {
|
||||
requestinfo += " " + request->argName(i) + ": " + request->arg(i) + "\n";
|
||||
}
|
||||
|
||||
DEBUG_WM(WM_DEBUG_MAX,requestinfo);
|
||||
#endif
|
||||
|
||||
// set static ips from server args
|
||||
if (server->arg(FPSTR(S_ip)) != "") {
|
||||
//_sta_static_ip.fromString(server->arg(FPSTR(S_ip));
|
||||
String ip = server->arg(FPSTR(S_ip));
|
||||
if (request->arg(FPSTR(S_ip)) != "") {
|
||||
//_sta_static_ip.fromString(request->arg(FPSTR(S_ip));
|
||||
String ip = request->arg(FPSTR(S_ip));
|
||||
optionalIPFromString(&_sta_static_ip, ip.c_str());
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("static ip:"),ip);
|
||||
#endif
|
||||
}
|
||||
if (server->arg(FPSTR(S_gw)) != "") {
|
||||
String gw = server->arg(FPSTR(S_gw));
|
||||
if (request->arg(FPSTR(S_gw)) != "") {
|
||||
String gw = request->arg(FPSTR(S_gw));
|
||||
optionalIPFromString(&_sta_static_gw, gw.c_str());
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("static gateway:"),gw);
|
||||
#endif
|
||||
}
|
||||
if (server->arg(FPSTR(S_sn)) != "") {
|
||||
String sn = server->arg(FPSTR(S_sn));
|
||||
if (request->arg(FPSTR(S_sn)) != "") {
|
||||
String sn = request->arg(FPSTR(S_sn));
|
||||
optionalIPFromString(&_sta_static_sn, sn.c_str());
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("static netmask:"),sn);
|
||||
#endif
|
||||
}
|
||||
if (server->arg(FPSTR(S_dns)) != "") {
|
||||
String dns = server->arg(FPSTR(S_dns));
|
||||
if (request->arg(FPSTR(S_dns)) != "") {
|
||||
String dns = request->arg(FPSTR(S_dns));
|
||||
optionalIPFromString(&_sta_static_dns, dns.c_str());
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("static DNS:"),dns);
|
||||
@@ -2024,7 +1994,7 @@ void WiFiManager::handleWifiSave() {
|
||||
_presavewificallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
if(_paramsInWifi) doParamSave();
|
||||
if(_paramsInWifi) doParamSave(request);
|
||||
|
||||
String page;
|
||||
|
||||
@@ -2040,8 +2010,8 @@ void WiFiManager::handleWifiSave() {
|
||||
if(_showBack) page += FPSTR(HTTP_BACKBTN);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors
|
||||
HTTPSend(page);
|
||||
//server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Sent wifi save page"));
|
||||
@@ -2050,34 +2020,32 @@ void WiFiManager::handleWifiSave() {
|
||||
connect = true; //signal ready to connect/reset process in processConfigPortal
|
||||
}
|
||||
|
||||
void WiFiManager::handleParamSave() {
|
||||
void WiFiManager::handleParamSave(AsyncWebServerRequest *request) {
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Param save "));
|
||||
#endif
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Method:"),server->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Method:"),request->method() == HTTP_GET ? (String)FPSTR(S_GET) : (String)FPSTR(S_POST));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
|
||||
doParamSave();
|
||||
doParamSave(request);
|
||||
|
||||
String page = getHTTPHead(FPSTR(S_titleparamsaved)); // @token titleparamsaved
|
||||
page += FPSTR(HTTP_PARAMSAVED);
|
||||
if(_showBack) page += FPSTR(HTTP_BACKBTN);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Sent param save page"));
|
||||
#endif
|
||||
}
|
||||
|
||||
void WiFiManager::doParamSave(){
|
||||
void WiFiManager::doParamSave(AsyncWebServerRequest *request){
|
||||
// @todo use new callback for before paramsaves, is this really needed?
|
||||
if ( _presaveparamscallback != NULL) {
|
||||
_presaveparamscallback(); // @CALLBACK
|
||||
@@ -2100,10 +2068,10 @@ void WiFiManager::doParamSave(){
|
||||
//read parameter from server
|
||||
String name = (String)FPSTR(S_parampre)+(String)i;
|
||||
String value;
|
||||
if(server->hasArg(name)) {
|
||||
value = server->arg(name);
|
||||
if(request->hasArg(name.c_str())) {
|
||||
value = request->arg(name);
|
||||
} else {
|
||||
value = server->arg(_params[i]->getID());
|
||||
value = request->arg(_params[i]->getID());
|
||||
}
|
||||
|
||||
//store it in params array
|
||||
@@ -2126,14 +2094,12 @@ void WiFiManager::doParamSave(){
|
||||
/**
|
||||
* HTTPD CALLBACK info page
|
||||
*/
|
||||
void WiFiManager::handleInfo() {
|
||||
void WiFiManager::handleInfo(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Info"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
handleRequest();
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
//handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titleinfo)); // @token titleinfo
|
||||
reportStatus(page);
|
||||
|
||||
@@ -2230,7 +2196,7 @@ void WiFiManager::handleInfo() {
|
||||
page += FPSTR(HTTP_HELP);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,F("Sent info page"));
|
||||
@@ -2474,19 +2440,18 @@ String WiFiManager::getInfoData(String id){
|
||||
/**
|
||||
* HTTPD CALLBACK exit, closes configportal if blocking, if non blocking undefined
|
||||
*/
|
||||
void WiFiManager::handleExit() {
|
||||
void WiFiManager::handleExit(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Exit"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titleexit)); // @token titleexit
|
||||
page += FPSTR(S_exiting); // @token exiting
|
||||
// ('Logout', 401, {'WWW-Authenticate': 'Basic realm="Login required"'})
|
||||
server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // @HTTPHEAD send cache
|
||||
HTTPSend(page);
|
||||
AsyncWebServerResponse *response = request->beginResponse(200,FPSTR(HTTP_HEAD_CT), page);
|
||||
response->addHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
|
||||
request->send(response);
|
||||
delay(2000);
|
||||
abort = true;
|
||||
}
|
||||
@@ -2494,25 +2459,22 @@ void WiFiManager::handleExit() {
|
||||
/**
|
||||
* HTTPD CALLBACK reset page
|
||||
*/
|
||||
void WiFiManager::handleReset() {
|
||||
void WiFiManager::handleReset(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP Reset"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titlereset)); //@token titlereset
|
||||
page += FPSTR(S_resetting); //@token resetting
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("RESETTING ESP"));
|
||||
#endif
|
||||
delay(1000);
|
||||
reboot();
|
||||
_rebootNeeded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2522,13 +2484,11 @@ void WiFiManager::handleReset() {
|
||||
// void WiFiManager::handleErase() {
|
||||
// handleErase(false);
|
||||
// }
|
||||
void WiFiManager::handleErase(boolean opt) {
|
||||
void WiFiManager::handleErase(AsyncWebServerRequest *request,bool opt = false) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_NOTIFY,F("<- HTTP Erase"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titleerase)); // @token titleerase
|
||||
|
||||
@@ -2543,43 +2503,40 @@ void WiFiManager::handleErase(boolean opt) {
|
||||
}
|
||||
|
||||
page += FPSTR(HTTP_END);
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
if(ret){
|
||||
delay(2000);
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("RESETTING ESP"));
|
||||
#endif
|
||||
reboot();
|
||||
_rebootNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTPD CALLBACK 404
|
||||
*/
|
||||
void WiFiManager::handleNotFound() {
|
||||
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
void WiFiManager::handleNotFound(AsyncWebServerRequest *request) {
|
||||
if (captivePortal(request)) return; // If captive portal redirect instead of displaying the page
|
||||
handleRequest();
|
||||
String message = FPSTR(S_notfound); // @token notfound
|
||||
|
||||
bool verbose404 = false; // show info in 404 body, uri,method, args
|
||||
if(verbose404){
|
||||
message += FPSTR(S_uri); // @token uri
|
||||
message += server->uri();
|
||||
message += request->url();
|
||||
message += FPSTR(S_method); // @token method
|
||||
message += ( server->method() == HTTP_GET ) ? FPSTR(S_GET) : FPSTR(S_POST);
|
||||
message += ( request->method() == HTTP_GET ) ? FPSTR(S_GET) : FPSTR(S_POST);
|
||||
message += FPSTR(S_args); // @token args
|
||||
message += server->args();
|
||||
message += request->args();
|
||||
message += F("\n");
|
||||
|
||||
for ( uint8_t i = 0; i < server->args(); i++ ) {
|
||||
message += " " + server->argName ( i ) + ": " + server->arg ( i ) + "\n";
|
||||
for ( uint8_t i = 0; i < request->args(); i++ ) {
|
||||
message += " " + request->argName ( i ) + ": " + request->arg ( i ) + "\n";
|
||||
}
|
||||
}
|
||||
server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // @HTTPHEAD send cache
|
||||
server->sendHeader(F("Pragma"), F("no-cache"));
|
||||
server->sendHeader(F("Expires"), F("-1"));
|
||||
server->send ( 404, FPSTR(HTTP_HEAD_CT2), message );
|
||||
AsyncWebServerResponse *response = request->beginResponse(404,FPSTR(HTTP_HEAD_CT2), message);
|
||||
response->addHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
|
||||
response->addHeader(F("Pragma"), F("no-cache"));
|
||||
response->addHeader(F("Expires"), F("-1"));
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2587,15 +2544,15 @@ void WiFiManager::handleNotFound() {
|
||||
* Redirect to captive portal if we got a request for another domain.
|
||||
* Return true in that case so the page handler do not try to handle the request again.
|
||||
*/
|
||||
boolean WiFiManager::captivePortal() {
|
||||
boolean WiFiManager::captivePortal(AsyncWebServerRequest *request) {
|
||||
|
||||
if(!_enableCaptivePortal || !configPortalActive) return false; // skip redirections if cp not enabled or not in ap mode
|
||||
|
||||
String serverLoc = toStringIp(server->client()->localIP());
|
||||
String serverLoc = toStringIp(request->client()->localIP());
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_DEV,"-> " + server->hostHeader());
|
||||
DEBUG_WM(WM_DEBUG_DEV,"serverLoc " + serverLoc);
|
||||
//DEBUG_WM(WM_DEBUG_DEV,"-> " + request->host());
|
||||
//DEBUG_WM(WM_DEBUG_DEV,"serverLoc " + serverLoc);
|
||||
#endif
|
||||
|
||||
// fallback for ipv6 bug
|
||||
@@ -2607,16 +2564,16 @@ boolean WiFiManager::captivePortal() {
|
||||
}
|
||||
|
||||
if(_httpPort != 80) serverLoc += ":" + (String)_httpPort; // add port if not default
|
||||
bool doredirect = serverLoc != server->hostHeader(); // redirect if hostheader not server ip, prevent redirect loops
|
||||
bool doredirect = serverLoc != request->host(); // redirect if hostheader not server ip, prevent redirect loops
|
||||
|
||||
if (doredirect) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- Request redirected to captive portal"));
|
||||
DEBUG_WM(WM_DEBUG_DEV,"serverLoc " + serverLoc);
|
||||
#endif
|
||||
server->sendHeader(F("Location"), (String)F("http://") + serverLoc, true); // @HTTPHEAD send redirect
|
||||
server->send ( 302, FPSTR(HTTP_HEAD_CT2), ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
|
||||
server->client()->stop(); // Stop is needed because we sent no content length
|
||||
AsyncWebServerResponse *response = request->beginResponse(302,FPSTR(HTTP_HEAD_CT2), "");
|
||||
response->addHeader(F("Location"), (String)F("http://") + serverLoc);
|
||||
request->send(response);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -2628,11 +2585,9 @@ void WiFiManager::stopCaptivePortal(){
|
||||
}
|
||||
|
||||
// HTTPD CALLBACK, handle close, stop captive portal, if not enabled undefined
|
||||
void WiFiManager::handleClose(){
|
||||
void WiFiManager::handleClose(AsyncWebServerRequest *request){
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("Disabling Captive Portal"));
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
stopCaptivePortal();
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- HTTP close"));
|
||||
@@ -2640,7 +2595,7 @@ void WiFiManager::handleClose(){
|
||||
handleRequest();
|
||||
String page = getHTTPHead(FPSTR(S_titleclose)); // @token titleclose
|
||||
page += FPSTR(S_closing); // @token closing
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
}
|
||||
|
||||
void WiFiManager::reportStatus(String &page){
|
||||
@@ -2735,7 +2690,10 @@ bool WiFiManager::disconnect(){
|
||||
void WiFiManager::reboot(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("Restarting"));
|
||||
_debugPort.flush();
|
||||
#endif
|
||||
delay(2000); // time for serial and web flsuh
|
||||
shutdownConfigPortal();
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
@@ -4046,14 +4004,12 @@ void WiFiManager::WiFi_autoReconnect(){
|
||||
}
|
||||
|
||||
// Called when /update is requested
|
||||
void WiFiManager::handleUpdate() {
|
||||
void WiFiManager::handleUpdate(AsyncWebServerRequest *request) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("<- Handle update"));
|
||||
#endif
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
if (captivePortal(request)) return; // If captive portal redirect instead of displaying the page
|
||||
String page = getHTTPHead(_title); // @token options
|
||||
String str = FPSTR(HTTP_ROOT_MAIN);
|
||||
str.replace(FPSTR(T_t), _title);
|
||||
@@ -4063,12 +4019,12 @@ void WiFiManager::handleUpdate() {
|
||||
page += FPSTR(HTTP_UPDATE);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
}
|
||||
|
||||
// upload via /u POST
|
||||
void WiFiManager::handleUpdating(){
|
||||
void WiFiManager::handleUpdating(AsyncWebServerRequest *request,String filename, size_t index, uint8_t *data, size_t len, bool final){
|
||||
// @todo
|
||||
// cannot upload files in captive portal, file select is not allowed, show message with link or hide
|
||||
// cannot upload if softreset after upload, maybe check for hard reset at least for dev, ERROR[11]: Invalid bootstrapping state, reset ESP8266 before updating
|
||||
@@ -4084,13 +4040,10 @@ void WiFiManager::handleUpdating(){
|
||||
bool error = false;
|
||||
unsigned long _configPortalTimeoutSAV = _configPortalTimeout; // store cp timeout
|
||||
_configPortalTimeout = 0; // disable timeout
|
||||
|
||||
// handler for the file upload, get's the sketch bytes, and writes
|
||||
// them through the Update object
|
||||
HTTPUpload& upload = server->upload();
|
||||
bool otadebug = false;
|
||||
|
||||
// UPLOAD START
|
||||
if (upload.status == UPLOAD_FILE_START) {
|
||||
if (!index) {
|
||||
// if(_debug) Serial.setDebugOutput(true);
|
||||
uint32_t maxSketchSpace;
|
||||
|
||||
@@ -4109,7 +4062,7 @@ void WiFiManager::handleUpdating(){
|
||||
#endif
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,"[OTA] Update file: ", upload.filename.c_str());
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,"[OTA] Update file: ", filename.c_str());
|
||||
#endif
|
||||
|
||||
// Update.onProgress(THandlerFunction_Progress fn);
|
||||
@@ -4124,11 +4077,14 @@ void WiFiManager::handleUpdating(){
|
||||
error = true;
|
||||
Update.end(); // Not sure the best way to abort, I think client will keep sending..
|
||||
}
|
||||
#ifdef ESP8266
|
||||
Update.runAsync(true); // tell the updaterClass to run in async mode
|
||||
#endif
|
||||
}
|
||||
// UPLOAD WRITE
|
||||
else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
if (index<len) {
|
||||
// Serial.print(".");
|
||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||
if (Update.write(data,len) != len) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError());
|
||||
//Update.printError(Serial); // write failure
|
||||
@@ -4137,11 +4093,11 @@ void WiFiManager::handleUpdating(){
|
||||
}
|
||||
}
|
||||
// UPLOAD FILE END
|
||||
else if (upload.status == UPLOAD_FILE_END) {
|
||||
if (final) {
|
||||
if (Update.end(true)) { // true to set the size to the current progress
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("\n\n[OTA] OTA FILE END bytes: "), upload.totalSize);
|
||||
// Serial.printf("Updated: %u bytes\r\nRebooting...\r\n", upload.totalSize);
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE,F("\n\n[OTA] OTA FILE END bytes: "), index+len);
|
||||
// Serial.printf("Updated: %u bytes\r\nRebooting...\r\n", index+len);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@@ -4150,23 +4106,20 @@ void WiFiManager::handleUpdating(){
|
||||
}
|
||||
}
|
||||
// UPLOAD ABORT
|
||||
else if (upload.status == UPLOAD_FILE_ABORTED) {
|
||||
Update.end();
|
||||
DEBUG_WM(F("[OTA] Update was aborted"));
|
||||
error = true;
|
||||
}
|
||||
// if (abort) {
|
||||
// Update.end();
|
||||
// DEBUG_WM(F("[OTA] Update was aborted"));
|
||||
// error = true;
|
||||
// }
|
||||
if(error) _configPortalTimeout = _configPortalTimeoutSAV;
|
||||
delay(0);
|
||||
}
|
||||
|
||||
// upload and ota done, show status
|
||||
void WiFiManager::handleUpdateDone() {
|
||||
void WiFiManager::handleUpdateDone(AsyncWebServerRequest *request) {
|
||||
DEBUG_WM(WM_DEBUG_VERBOSE, F("<- Handle update done"));
|
||||
// if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
|
||||
if (_hasCredentials && !server->authenticate(_credUser, _credPassword)) {
|
||||
return server->requestAuthentication();
|
||||
}
|
||||
// if (captivePortal(request)) return; // If captive portal redirect instead of displaying the page
|
||||
if(strlen(_credUser) > 0 && strlen(_credPassword) > 0) if(!request->authenticate(_credUser, _credPassword)) return request->requestAuthentication();
|
||||
String page = getHTTPHead(FPSTR(S_options)); // @token options
|
||||
String str = FPSTR(HTTP_ROOT_MAIN);
|
||||
str.replace(FPSTR(T_t),_title);
|
||||
@@ -4188,11 +4141,12 @@ void WiFiManager::handleUpdateDone() {
|
||||
}
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
HTTPSend(request,page);
|
||||
|
||||
delay(1000); // send page
|
||||
// delay(1000); // send page
|
||||
if (!Update.hasError()) {
|
||||
ESP.restart();
|
||||
//ESP.restart();
|
||||
_rebootNeeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* WiFiManager.h
|
||||
*
|
||||
*
|
||||
* WiFiManager, a library for the ESP8266/Arduino platform
|
||||
* for configuration of WiFi credentials using a Captive Portal
|
||||
*
|
||||
*
|
||||
* @author Creator tzapu
|
||||
* @author tablatronix
|
||||
* @version 0.0.0
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
// #define WM_MDNS // includes MDNS, also set MDNS with sethostname
|
||||
// #define WM_FIXERASECONFIG // use erase flash fix
|
||||
// #define WM_ERASE_NVS // esp32 erase(true) will erase NVS
|
||||
// #define WM_ERASE_NVS // esp32 erase(true) will erase NVS
|
||||
// #define WM_RTC // esp32 info page will include reset reasons
|
||||
|
||||
// #define WM_JSTEST // build flag for enabling js xhr tests
|
||||
// #define WIFI_MANAGER_OVERRIDE_STRINGS // build flag for using own strings include
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
#warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled"
|
||||
#warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled"
|
||||
// @todo check failing on platform = espressif8266@1.7.3
|
||||
#define WM_NOASYNC // esp8266 no async scan wifi
|
||||
#define WM_NOCOUNTRY // esp8266 no country
|
||||
@@ -62,6 +62,7 @@
|
||||
// autoreconnect is WORKING https://github.com/espressif/arduino-esp32/issues/653#issuecomment-405604766
|
||||
|
||||
#define WM_WEBSERVERSHIM // use webserver shim lib
|
||||
#define WM_ASYNCWEBSERVER // use async webserver
|
||||
|
||||
#define WM_G(string_literal) (String(FPSTR(string_literal)).c_str())
|
||||
|
||||
@@ -71,31 +72,42 @@
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#else
|
||||
#include <ESP8266WebServer.h>
|
||||
#endif
|
||||
|
||||
#ifdef WM_MDNS
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
|
||||
#define WIFI_getChipId() ESP.getChipId()
|
||||
#define WIFI_getChipId() ESP.getChipId()
|
||||
#define WM_WIFIOPEN ENC_TYPE_NONE
|
||||
|
||||
#elif defined(ESP32)
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <Update.h>
|
||||
|
||||
|
||||
#define WIFI_getChipId() (uint32_t)ESP.getEfuseMac()
|
||||
#define WM_WIFIOPEN WIFI_AUTH_OPEN
|
||||
|
||||
#ifndef WEBSERVER_H
|
||||
#ifdef WM_WEBSERVERSHIM
|
||||
#include <WebServer.h>
|
||||
#else
|
||||
#include <ESP8266WebServer.h>
|
||||
// Forthcoming official ? probably never happening
|
||||
// https://github.com/esp8266/ESPWebServer
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#else
|
||||
#ifndef WEBSERVER_H
|
||||
#ifdef WM_WEBSERVERSHIM
|
||||
#include <WebServer.h>
|
||||
#else
|
||||
#include <ESP8266WebServer.h>
|
||||
// Forthcoming official ? probably never happening
|
||||
// https://github.com/esp8266/ESPWebServer
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -142,7 +154,7 @@
|
||||
|
||||
// prep string concat vars
|
||||
#define WM_STRING2(x) #x
|
||||
#define WM_STRING(x) WM_STRING2(x)
|
||||
#define WM_STRING(x) WM_STRING2(x)
|
||||
|
||||
// #include <esp_idf_version.h>
|
||||
#ifdef ESP_IDF_VERSION
|
||||
@@ -150,7 +162,7 @@
|
||||
// #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR)
|
||||
// #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH)
|
||||
#define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH)
|
||||
#else
|
||||
#else
|
||||
#define VER_IDF_STR "Unknown"
|
||||
#endif
|
||||
|
||||
@@ -179,7 +191,7 @@
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#else
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
#endif
|
||||
|
||||
@@ -197,7 +209,7 @@
|
||||
|
||||
class WiFiManagerParameter {
|
||||
public:
|
||||
/**
|
||||
/**
|
||||
Create custom parameters that can be added to the WiFiManager setup web page
|
||||
@id is used for HTTP queries and must not contain spaces nor other special characters
|
||||
*/
|
||||
@@ -228,7 +240,7 @@ class WiFiManagerParameter {
|
||||
char *_value;
|
||||
int _length;
|
||||
int _labelPlacement;
|
||||
|
||||
|
||||
const char *_customHTML;
|
||||
friend class WiFiManager;
|
||||
};
|
||||
@@ -263,8 +275,8 @@ class WiFiManager
|
||||
|
||||
//manually stop the config portal if started manually, stop immediatly if non blocking, flag abort if blocking
|
||||
bool stopConfigPortal();
|
||||
|
||||
//manually start the web portal, autoconnect does this automatically on connect failure
|
||||
|
||||
//manually start the web portal, autoconnect does this automatically on connect failure
|
||||
void startWebPortal();
|
||||
|
||||
//manually stop the web portal if started manually
|
||||
@@ -279,7 +291,7 @@ class WiFiManager
|
||||
|
||||
// erase wifi credentials
|
||||
void resetSettings();
|
||||
|
||||
|
||||
// reset wifi scan
|
||||
void resetScan();
|
||||
|
||||
@@ -342,13 +354,13 @@ class WiFiManager
|
||||
|
||||
// sets number of retries for autoconnect, force retry after wait failure exit
|
||||
void setConnectRetries(uint8_t numRetries); // default 1
|
||||
|
||||
|
||||
//sets timeout for which to attempt connecting on saves, useful if there are bugs in esp waitforconnectloop
|
||||
void setSaveConnectTimeout(unsigned long seconds);
|
||||
|
||||
|
||||
// lets you disable automatically connecting after save from webportal
|
||||
void setSaveConnect(bool connect = true);
|
||||
|
||||
|
||||
// toggle debug output
|
||||
void setDebugOutput(boolean debug);
|
||||
void setDebugOutput(boolean debug, String prefix); // log line prefix, default "*wm:"
|
||||
@@ -356,24 +368,24 @@ class WiFiManager
|
||||
|
||||
//set min quality percentage to include in scan, defaults to 8% if not specified
|
||||
void setMinimumSignalQuality(int quality = 8);
|
||||
|
||||
|
||||
//sets a custom ip /gateway /subnet configuration
|
||||
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
|
||||
|
||||
//sets config for a static IP
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
|
||||
|
||||
//sets config for a static IP with DNS
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns);
|
||||
|
||||
|
||||
//if this is set, it will exit after config, even if connection is unsuccessful.
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
|
||||
// if this is set, portal will be blocking and wait until save or exit,
|
||||
|
||||
// if this is set, portal will be blocking and wait until save or exit,
|
||||
// is false user must manually `process()` to handle config portal,
|
||||
// setConfigPortalTimeout is ignored in this mode, user is responsible for closing configportal
|
||||
void setConfigPortalBlocking(boolean shouldBlock);
|
||||
|
||||
|
||||
//add custom html at inside <head> for all pages
|
||||
void setCustomHeadElement(const char* html);
|
||||
|
||||
@@ -382,40 +394,40 @@ class WiFiManager
|
||||
|
||||
//if this is true, remove duplicated Access Points - defaut true
|
||||
void setRemoveDuplicateAPs(boolean removeDuplicates);
|
||||
|
||||
|
||||
//setter for ESP wifi.persistent so we can remember it and restore user preference, as WIFi._persistent is protected
|
||||
void setRestorePersistent(boolean persistent);
|
||||
|
||||
|
||||
//if true, always show static net inputs, IP, subnet, gateway, else only show if set via setSTAStaticIPConfig
|
||||
void setShowStaticFields(boolean alwaysShow);
|
||||
|
||||
|
||||
//if true, always show static dns, esle only show if set via setSTAStaticIPConfig
|
||||
void setShowDnsFields(boolean alwaysShow);
|
||||
|
||||
|
||||
// toggle showing the saved wifi password in wifi form, could be a security issue.
|
||||
void setShowPassword(boolean show);
|
||||
|
||||
|
||||
//if false, disable captive portal redirection
|
||||
void setCaptivePortalEnable(boolean enabled);
|
||||
|
||||
|
||||
//if false, timeout captive portal even if a STA client connected to softAP (false), suggest disabling if captiveportal is open
|
||||
void setAPClientCheck(boolean enabled);
|
||||
|
||||
//if true, reset timeout when webclient connects (true), suggest disabling if captiveportal is open
|
||||
|
||||
//if true, reset timeout when webclient connects (true), suggest disabling if captiveportal is open
|
||||
void setWebPortalClientCheck(boolean enabled);
|
||||
|
||||
|
||||
// if true, enable autoreconnecting
|
||||
void setWiFiAutoReconnect(boolean enabled);
|
||||
|
||||
|
||||
// if true, wifiscan will show percentage instead of quality icons, until we have better templating
|
||||
void setScanDispPerc(boolean enabled);
|
||||
|
||||
|
||||
// if true (default) then start the config portal from autoConnect if connection failed
|
||||
void setEnableConfigPortal(boolean enable);
|
||||
|
||||
// if true (default) then stop the config portal from autoConnect when wifi is saved
|
||||
void setDisableConfigPortal(boolean enable);
|
||||
|
||||
|
||||
// if true then find the AP with the best RSSI for the given SSID
|
||||
void setFindBestRSSI(boolean enabled);
|
||||
|
||||
@@ -431,10 +443,10 @@ class WiFiManager
|
||||
|
||||
// set ap channel
|
||||
void setWiFiAPChannel(int32_t channel);
|
||||
|
||||
|
||||
// set ap hidden
|
||||
void setWiFiAPHidden(bool hidden); // default false
|
||||
|
||||
|
||||
// clean connect, always disconnect before connecting
|
||||
void setCleanConnect(bool enable); // default false
|
||||
|
||||
@@ -442,7 +454,7 @@ class WiFiManager
|
||||
// see _menutokens for ids
|
||||
void setMenu(std::vector<const char*>& menu);
|
||||
void setMenu(const char* menu[], uint8_t size);
|
||||
|
||||
|
||||
// set the webapp title, default WiFiManager
|
||||
void setTitle(String title);
|
||||
|
||||
@@ -451,10 +463,10 @@ class WiFiManager
|
||||
|
||||
// get last connection result, includes autoconnect and wifisave
|
||||
uint8_t getLastConxResult();
|
||||
|
||||
|
||||
// get a status as string
|
||||
String getWLStatusString(uint8_t status);
|
||||
String getWLStatusString();
|
||||
String getWLStatusString(uint8_t status);
|
||||
String getWLStatusString();
|
||||
|
||||
// get wifi mode as string
|
||||
String getModeString(uint8_t mode);
|
||||
@@ -462,7 +474,7 @@ class WiFiManager
|
||||
// check if the module has a saved ap to connect to
|
||||
bool getWiFiIsSaved();
|
||||
|
||||
// helper to get saved password, if persistent get stored, else get current if connected
|
||||
// helper to get saved password, if persistent get stored, else get current if connected
|
||||
String getWiFiPass(bool persistent = true);
|
||||
|
||||
// helper to get saved ssid, if persistent get stored, else get current if connected
|
||||
@@ -476,7 +488,7 @@ class WiFiManager
|
||||
|
||||
// helper for html
|
||||
String htmlEntities(String str, bool whitespace = false);
|
||||
|
||||
|
||||
// set the country code for wifi settings, CN
|
||||
void setCountry(String cc);
|
||||
|
||||
@@ -488,13 +500,13 @@ class WiFiManager
|
||||
|
||||
// get default ap esp uses , esp_chipid etc
|
||||
String getDefaultAPName();
|
||||
|
||||
|
||||
// set port of webserver, 80
|
||||
void setHttpPort(uint16_t port);
|
||||
|
||||
// check if config portal is active (true)
|
||||
bool getConfigPortalActive();
|
||||
|
||||
|
||||
// check if web portal is active (true)
|
||||
bool getWebPortalActive();
|
||||
|
||||
@@ -508,11 +520,19 @@ class WiFiManager
|
||||
std::unique_ptr<DNSServer> dnsServer;
|
||||
|
||||
#if defined(ESP32) && defined(WM_WEBSERVERSHIM)
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
using WM_WebServer = AsyncWebServer;
|
||||
#else
|
||||
using WM_WebServer = WebServer;
|
||||
#endif
|
||||
#else
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
using WM_WebServer = AsyncWebServer;
|
||||
#else
|
||||
using WM_WebServer = ESP8266WebServer;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
std::unique_ptr<WM_WebServer> server;
|
||||
|
||||
protected:
|
||||
@@ -552,7 +572,7 @@ class WiFiManager
|
||||
unsigned long _configPortalTimeout = 0; // ms close config portal loop if set (depending on _cp/webClientCheck options)
|
||||
unsigned long _connectTimeout = 0; // ms stop trying to connect to ap if set
|
||||
unsigned long _saveTimeout = 0; // ms stop trying to connect to ap on saves, in case bugs in esp waitforconnectresult
|
||||
|
||||
|
||||
WiFiMode_t _usermode = WIFI_STA; // Default user mode
|
||||
String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid
|
||||
int _cpclosedelay = 2000; // delay before wifisave, prevents captive portal from closing to fast.
|
||||
@@ -587,7 +607,7 @@ class WiFiManager
|
||||
boolean _removeDuplicateAPs = true; // remove dup aps from wifiscan
|
||||
boolean _showPassword = false; // show or hide saved password on wifi form, might be a security issue!
|
||||
boolean _shouldBreakAfterConfig = false; // stop configportal on save failure
|
||||
boolean _configPortalIsBlocking = true; // configportal enters blocking loop
|
||||
boolean _configPortalIsBlocking = true; // configportal enters blocking loop
|
||||
boolean _enableCaptivePortal = true; // enable captive portal redirection
|
||||
boolean _userpersistent = true; // users preffered persistence to restore
|
||||
boolean _wifiAutoReconnect = true; // there is no platform getter for this, we must assume its true and make it so
|
||||
@@ -609,7 +629,9 @@ class WiFiManager
|
||||
String _title = FPSTR(S_brand); // app title - default WiFiManager
|
||||
|
||||
// internal options
|
||||
|
||||
|
||||
bool _rebootNeeded = false; // async reboot flag
|
||||
|
||||
// wifiscan notes
|
||||
// currently disabled due to issues with caching, sometimes first scan is empty esp32 wifi not init yet race, or portals hit server nonstop flood
|
||||
// The following are background wifi scanning optimizations
|
||||
@@ -620,12 +642,12 @@ class WiFiManager
|
||||
// async enables asyncronous scans, so they do not block anything
|
||||
// the refresh button bypasses cache
|
||||
// no aps found is problematic as scans are always going to want to run, leading to page load delays
|
||||
//
|
||||
//
|
||||
// These settings really only make sense with _preloadwifiscan true
|
||||
// but not limited to, we could run continuous background scans on various page hits, or xhr hits
|
||||
// which would be better coupled with asyncscan
|
||||
// atm preload is only done on root hit and startcp
|
||||
//
|
||||
//
|
||||
// preload scanning causes AP to delay showing for users, but also caches and lets the cp load faster once its open
|
||||
// my scan takes 7-10 seconds
|
||||
public:
|
||||
@@ -636,7 +658,7 @@ public:
|
||||
protected:
|
||||
|
||||
boolean _autoforcerescan = false; // automatically force rescan if scan networks is 0, ignoring cache
|
||||
|
||||
|
||||
boolean _disableIpFields = false; // modify function of setShow_X_Fields(false), forces ip fields off instead of default show if set, eg. _staShowStaticFields=-1
|
||||
|
||||
String _wificountry = ""; // country code, @todo define in strings lang
|
||||
@@ -650,7 +672,9 @@ protected:
|
||||
void setupConfigPortal();
|
||||
bool shutdownConfigPortal();
|
||||
bool setupHostname(bool restart);
|
||||
|
||||
void setupHTTPServer();
|
||||
void teardownHTTPServer();
|
||||
|
||||
#ifdef NO_EXTRA_4K_HEAP
|
||||
boolean _tryWPS = false; // try WPS on save failure, unsupported
|
||||
void startWPS();
|
||||
@@ -658,7 +682,6 @@ protected:
|
||||
|
||||
bool startAP();
|
||||
void setupDNSD();
|
||||
void setupHTTPServer();
|
||||
|
||||
uint8_t connectWifi(String ssid, String pass, bool connect = true);
|
||||
bool setSTAConfig();
|
||||
@@ -667,38 +690,36 @@ protected:
|
||||
uint8_t waitForConnectResult();
|
||||
uint8_t waitForConnectResult(uint32_t timeout);
|
||||
void updateConxResult(uint8_t status);
|
||||
|
||||
// webserver handlers
|
||||
public:
|
||||
void handleNotFound();
|
||||
bool WiFi_scanNetworks(bool force,bool async);
|
||||
protected:
|
||||
void HTTPSend(const String &content);
|
||||
void handleRoot();
|
||||
void handleWifi(boolean scan);
|
||||
void handleWifiSave();
|
||||
void handleInfo();
|
||||
void handleReset();
|
||||
// webserver handlers
|
||||
void handleRoot(AsyncWebServerRequest *request);
|
||||
void handleWifi(AsyncWebServerRequest *request,bool scan);
|
||||
void handleWifiSave(AsyncWebServerRequest *request);
|
||||
void handleInfo(AsyncWebServerRequest *request);
|
||||
void handleReset(AsyncWebServerRequest *request);
|
||||
void handleNotFound(AsyncWebServerRequest *request);
|
||||
void handleExit(AsyncWebServerRequest *request);
|
||||
void handleClose(AsyncWebServerRequest *request);
|
||||
// void handleErase(AsyncWebServerRequest *request);
|
||||
void handleErase(AsyncWebServerRequest *request, bool opt);
|
||||
void handleParam(AsyncWebServerRequest *request);
|
||||
void handleWiFiStatus(AsyncWebServerRequest *request);
|
||||
void handleParamSave(AsyncWebServerRequest *request);
|
||||
void doParamSave(AsyncWebServerRequest *request);
|
||||
|
||||
void handleExit();
|
||||
void handleClose();
|
||||
// void handleErase();
|
||||
void handleErase(boolean opt);
|
||||
void handleParam();
|
||||
void handleWiFiStatus();
|
||||
void handleRequest();
|
||||
void handleParamSave();
|
||||
void doParamSave();
|
||||
void HTTPSend(AsyncWebServerRequest *request, String page);
|
||||
|
||||
boolean captivePortal();
|
||||
boolean captivePortal(AsyncWebServerRequest *request);
|
||||
boolean configPortalHasTimeout();
|
||||
uint8_t processConfigPortal();
|
||||
void stopCaptivePortal();
|
||||
// OTA Update handler
|
||||
void handleUpdate();
|
||||
void handleUpdating();
|
||||
void handleUpdateDone();
|
||||
|
||||
// OTA Update handler
|
||||
void handleUpdate(AsyncWebServerRequest *request);
|
||||
void handleUpdating(AsyncWebServerRequest *request,String filename, size_t index, uint8_t *data, size_t len, bool final);
|
||||
void handleUpdateDone(AsyncWebServerRequest *request);
|
||||
|
||||
// wifi platform abstractions
|
||||
bool WiFi_Mode(WiFiMode_t m);
|
||||
@@ -737,12 +758,12 @@ protected:
|
||||
#define WM_DISCONWORKAROUND
|
||||
#endif
|
||||
|
||||
#else
|
||||
#else
|
||||
#define WM_NOCOUNTRY
|
||||
#endif
|
||||
|
||||
#ifdef WM_NOCOUNTRY
|
||||
#warning "ESP32 set country unavailable"
|
||||
#warning "ESP32 set country unavailable"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -783,9 +804,9 @@ protected:
|
||||
boolean portalTimeoutResult = false;
|
||||
|
||||
boolean portalAbortResult = false;
|
||||
boolean storeSTAmode = true; // option store persistent STA mode in connectwifi
|
||||
boolean storeSTAmode = true; // option store persistent STA mode in connectwifi
|
||||
int timer = 0; // timer for debug throttle for numclients, and portal timeout messages
|
||||
|
||||
|
||||
// WiFiManagerParameter
|
||||
int _paramsCount = 0;
|
||||
int _max_params;
|
||||
@@ -798,7 +819,7 @@ protected:
|
||||
|
||||
// build debuglevel support
|
||||
// @todo use DEBUG_ESP_x?
|
||||
|
||||
|
||||
// Set default debug level
|
||||
#ifndef WM_DEBUG_LEVEL
|
||||
#define WM_DEBUG_LEVEL WM_DEBUG_NOTIFY
|
||||
@@ -811,7 +832,7 @@ protected:
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
uint8_t _debugLevel = (uint8_t)WM_DEBUG_LEVEL;
|
||||
#else
|
||||
#else
|
||||
uint8_t _debugLevel = 0; // default debug level
|
||||
#endif
|
||||
|
||||
@@ -843,7 +864,7 @@ protected:
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
std::function<void()> _configportaltimeoutcallback;
|
||||
|
||||
|
||||
bool _hasCredentials = false;
|
||||
char _credUser[31] = {0};
|
||||
char _credPassword[31] = {0};
|
||||
|
||||
Reference in New Issue
Block a user