From 12c71aa8995b481faf09ebcf21d7bbaf9309c588 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Mon, 30 Nov 2015 15:00:47 +0200 Subject: [PATCH 1/4] memory housekeeping --- .../ESP8266WebServer/src/ESP8266WebServer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp index bc9a3fa3a..e9f88684f 100644 --- a/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp +++ b/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp @@ -87,17 +87,25 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password authReq.trim(); char toencodeLen = strlen(username)+strlen(password)+1; char *toencode = new char[toencodeLen]; - if(toencode == NULL) + if(toencode == NULL){ + authReq = String(); return false; + } char *encoded = new char[base64_encode_expected_len(toencodeLen)+1]; - if(encoded == NULL) + if(encoded == NULL){ + authReq = String(); + delete[] toencode; return false; - + } sprintf(toencode, "%s:%s", username, password); if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){ authReq = String(); + delete[] toencode; + delete[] encoded; return true; } + delete[] toencode; + delete[] encoded; } authReq = String(); } From 1da7f91a080e6b68bf3e9efbe2005bb826a4460f Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Tue, 1 Dec 2015 05:26:05 +0200 Subject: [PATCH 2/4] Make progress print on the same line. --- libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino index ec621bb79..21e6761a1 100644 --- a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino +++ b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino @@ -33,7 +33,7 @@ void setup() { Serial.println("End"); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { - Serial.printf("Progress: %u%%\n", (progress / (total / 100))); + Serial.printf("Progress: %u%%\r", (progress / (total / 100))); }); ArduinoOTA.onError([](ota_error_t error) { Serial.printf("Error[%u]: ", error); From 239352b7cfc0168f64b164333699d7a7e7e54b97 Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Tue, 1 Dec 2015 05:27:06 +0200 Subject: [PATCH 3/4] Add linebreak. --- libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino index 21e6761a1..e0e98c150 100644 --- a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino +++ b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino @@ -35,6 +35,7 @@ void setup() { ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { Serial.printf("Progress: %u%%\r", (progress / (total / 100))); }); + Serial.println("") ArduinoOTA.onError([](ota_error_t error) { Serial.printf("Error[%u]: ", error); if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); From c2c7cc3a7145f80d6d289bc85626b7e9faccc994 Mon Sep 17 00:00:00 2001 From: Stavros Korokithakis Date: Tue, 1 Dec 2015 05:32:42 +0200 Subject: [PATCH 4/4] Print a newline properly. --- libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino index e0e98c150..50e926efe 100644 --- a/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino +++ b/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino @@ -30,12 +30,11 @@ void setup() { Serial.println("Start"); }); ArduinoOTA.onEnd([]() { - Serial.println("End"); + Serial.println("\nEnd"); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { Serial.printf("Progress: %u%%\r", (progress / (total / 100))); }); - Serial.println("") ArduinoOTA.onError([](ota_error_t error) { Serial.printf("Error[%u]: ", error); if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");