From ccf04aa5b0cffd80c0f7170ab842e7b6034eb1fc Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:54:47 -0500 Subject: [PATCH] added some http debugging --- WiFiManager.cpp | 20 +++++++++++++++++++- WiFiManager.h | 11 ++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 45698b8..b7ec239 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1041,6 +1041,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) { #endif } // if ssid argument provided connect to that + // NOTE: this also catches preload() _defaultssid @todo rework if (ssid != "") { wifiConnectNew(ssid,pass,connect); // @todo connect=false seems to disconnect sta in begin() so not sure if _connectonsave is useful at all @@ -1812,6 +1813,22 @@ void WiFiManager::handleWifiSave() { _ssid = server->arg(F("s")).c_str(); _pass = server->arg(F("p")).c_str(); + #ifdef WM_DEBUG_LEVEL + String requestinfo = "SERVER_REQUEST\n----------------\n"; + requestinfo += "URI: "; + requestinfo += server->uri(); + requestinfo += "\nMethod: "; + requestinfo += (server->method() == HTTP_GET) ? "GET" : "POST"; + requestinfo += "\nArguments: "; + requestinfo += server->args(); + requestinfo += "\n"; + for (uint8_t i = 0; i < server->args(); i++) { + requestinfo += " " + server->argName(i) + ": " + server->arg(i) + "\n"; + } + + DEBUG_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)); @@ -3289,7 +3306,7 @@ template void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { if(!_debug || _debugLevel < level) return; - if(_debugLevel >= DEBUG_MAX){ + if(_debugLevel > DEBUG_MAX){ #ifdef ESP8266 // uint32_t free; // uint16_t max; @@ -3312,6 +3329,7 @@ void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { _debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag); #endif } + _debugPort.print(_debugPrefix); if(_debugLevel >= debugLvlShow) _debugPort.print("["+(String)level+"] "); _debugPort.print(text); diff --git a/WiFiManager.h b/WiFiManager.h index 36fe039..7b7cc72 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -760,11 +760,12 @@ class WiFiManager // debugging typedef enum { - DEBUG_ERROR = 0, - DEBUG_NOTIFY = 1, // default stable - DEBUG_VERBOSE = 2, - DEBUG_DEV = 3, // default dev - DEBUG_MAX = 4 + DEBUG_SILENT = 0, // debug OFF but still compiled for runtime + DEBUG_ERROR = 1, // error only + DEBUG_NOTIFY = 2, // default stable,INFO + DEBUG_VERBOSE = 3, // move verbose info + DEBUG_DEV = 4, // development useful debugging info + DEBUG_MAX = 5 // MAX extra dev auditing, var dumps etc (MAX+1 will print timing,mem and frag info) } wm_debuglevel_t; boolean _debug = true;