From f122cc9509ab52d9c720faa4b511b3b2e26e33c2 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 4 Feb 2021 13:23:48 -0600 Subject: [PATCH] fix ota debug --- WiFiManager.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 599ab71..f751dae 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3449,7 +3449,9 @@ void WiFiManager::WiFi_autoReconnect(){ // Called when /update is requested void WiFiManager::handleUpdate() { + #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("<- Handle update")); + #endif if (captivePortal()) return; // If captive portal redirect instead of displaying the page String page = getHTTPHead(FPSTR(S_options)); // @token options String str = FPSTR(HTTP_ROOT_MAIN); @@ -3500,10 +3502,14 @@ void WiFiManager::handleUpdating(){ maxSketchSpace = UPDATE_SIZE_UNKNOWN; #endif - Serial.printf("Update: %s\r\n", upload.filename.c_str()); + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,"Update file: ", upload.filename.c_str()); + #endif if (!Update.begin(maxSketchSpace)) { // start with max available size - DEBUG_WM(F("[OTA] Update ERROR"), Update.getError()); + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update ERROR"), Update.getError()); + #endif error = true; Update.end(); // Not sure the best way to abort, I think client will keep sending.. } @@ -3512,14 +3518,20 @@ void WiFiManager::handleUpdating(){ else if (upload.status == UPLOAD_FILE_WRITE) { Serial.print("."); if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { - Update.printError(Serial); // write failure + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError()); + //Update.printError(Serial); // write failure + #endif error = true; } } // UPLOAD FILE END else if (upload.status == UPLOAD_FILE_END) { if (Update.end(true)) { // true to set the size to the current progress - Serial.printf("Updated: %u bytes\r\nRebooting...\r\n", upload.totalSize); + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[OTA] OTA FILE END bytes: "), upload.totalSize); + // Serial.printf("Updated: %u bytes\r\nRebooting...\r\n", upload.totalSize); + #endif } else { Update.printError(Serial);