From d69abeff087d180ddd3f890144f609741a4ae2a9 Mon Sep 17 00:00:00 2001 From: Jonathas Barbosa Date: Sun, 2 Apr 2023 10:20:04 -0300 Subject: [PATCH] fix clockwise update bug --- firmware/lib/cw-commons/CWWebServer.h | 17 ++++--------- firmware/lib/cw-commons/SettingsWebPage.h | 23 +++++++++++------- firmware/lib/cw-commons/WiFiController.h | 5 +++- firmware/src/main.cpp | 29 ++++++++--------------- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/firmware/lib/cw-commons/CWWebServer.h b/firmware/lib/cw-commons/CWWebServer.h index 37d5a82..055b5ac 100644 --- a/firmware/lib/cw-commons/CWWebServer.h +++ b/firmware/lib/cw-commons/CWWebServer.h @@ -1,8 +1,5 @@ #pragma once -#define HTTP_GET_SIZE 3 -#define HTTP_POST_SIZE 4 - #include #include #include "StatusController.h" @@ -47,8 +44,6 @@ struct ClockwiseWebServer if (c == '\n') { - //Serial.println(httpBuffer); - uint8_t method_pos = httpBuffer.indexOf(' '); uint8_t path_pos = httpBuffer.indexOf(' ', method_pos + 1); @@ -57,7 +52,7 @@ struct ClockwiseWebServer String key = ""; String value = ""; - if (method == "POST") + if (method == "POST" && path.indexOf('?') > 0) { key = path.substring(path.indexOf('?') + 1, path.indexOf('=')); value = path.substring(path.indexOf('=') + 1, ' '); @@ -77,12 +72,6 @@ struct ClockwiseWebServer void processRequest(WiFiClient client, String method, String path, String key, String value) { - - // Serial.println(method); - // Serial.println(path); - // Serial.println(key); - // Serial.println(value); - if (method == "GET" && path == "/") { client.println("HTTP/1.0 200 OK"); client.println("Content-Type: text/html"); @@ -90,6 +79,10 @@ struct ClockwiseWebServer client.println(SETTINGS_PAGE); } else if (method == "GET" && path == "/get") { getCurrentSettings(client); + } else if (method == "POST" && path == "/restart") { + client.println("HTTP/1.0 204 No Content"); + delay(1000); + ESP.restart(); } else if (method == "POST" && path == "/set") { ClockwiseParams::getInstance()->load(); //a baby seal has died due this ifs diff --git a/firmware/lib/cw-commons/SettingsWebPage.h b/firmware/lib/cw-commons/SettingsWebPage.h index 5199ff7..3cdf21c 100644 --- a/firmware/lib/cw-commons/SettingsWebPage.h +++ b/firmware/lib/cw-commons/SettingsWebPage.h @@ -13,15 +13,16 @@ const char SETTINGS_PAGE[] PROGMEM = R""""( href="https://github.com/jnthas/clockwise/raw/gh-pages/static/images/favicon.png"> -
+
Logo + src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOcAAAA4CAYAAAAGnO/aAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV/TilIqDnYQcchQxcGCqIijVqEIFUKt0KqDyaVf0KQhSXFxFFwLDn4sVh1cnHV1cBUEwQ8QVxcnRRcp8X9JoUWMB8f9eHfvcfcOEBoVplmhcUDTbTOdTIjZ3KrY/YoQBEQwirDMLGNOklLwHV/3CPD1Ls6z/M/9OXrVvMWAgEg8ywzTJt4gnt60Dc77xFFWklXic+Ixky5I/Mh1xeM3zkWXBZ4ZNTPpeeIosVjsYKWDWcnUiKeIY6qmU76Q9VjlvMVZq9RY6578hZG8vrLMdZpDSGIRS5AgQkENZVRgI06rToqFNO0nfPyDrl8il0KuMhg5FlCFBtn1g//B726twuSElxRJAF0vjvMxDHTvAs2643wfO07zBAg+A1d6219tADOfpNfbWuwI6NsGLq7bmrIHXO4AA0+GbMquFKQpFArA+xl9Uw7ovwXCa15vrX2cPgAZ6ip1AxwcAiNFyl73eXdPZ2//nmn19wMblHKELbNVEQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+cEAgwqMNi06jEAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAPeklEQVR42u2de7jVVZnHP+8+Fw54RAFJYLgYpKGGWopGHJmAZyClNPOCYJn0FKaNqM8Mo073mryFjxCOaCSjOOXdUixEMLUSQxkcFJXBAAVBAUFAOMC57O/88Vs7Npvfde/N4XjO7/s859GHva7vW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m2VGttQZ4Okn5bopCzzikh6txWDEGzks4qlpwuz7/EqPfWmAS9KaSMq0PyHReSb0lCC3IsckqaWOK43hvShiklln1boLwlXRSjgN2SLmghYk6I+a5yVEgZRUVCcCb/i11/k+IdSZ9N0M+hMZ3E87E4N3lV5Pc53fkmiqC3RBHULWabA85bR0QsTq+XwwiZgJwZd+Yr5h3trHyNJWQz+bCIq6IL43SytXw8d2bMjv13RFmXO4OE39/kGG3p7Ej6Sozd7GlJowNN49ETfJyzrobhBUlj8utwhqy3A/r4XES9k0Pkk/ubFKP9V/jkmx5TM1pbkO/hIuS3PKT9NQHW2iudsS5qrj8s751v3LYc5oxv70aUvdJdcx3u49fkf4Yg2WfnLzKzV8rpZID32fmjYySP/Ox8mReNI5xcugO5c9QOYAOwymxf/80S6ukDfBzvVYfhPc7dCKyOCi6Voih593Xj2gXv9U4D3gugDU7mu0souz/eu80unocR9XieZmvN7L1iChwgaWcCa+Tjkj5ZooBOlDQ/gSqwSVKPdGqlaI+rySkJPUBy56BrJfVK4NnyA3nRypJgm6SB6SilaKuIY4UbjBfnplMR5b8LrHL/3YIX1qMjXsiSnnhhLT5WRLkfAHWt7RsuKVK0KDkdQY/Be0nfGh5er8R7V7kmHb4UKfi79WmODi7ui/O6IEWK9krSSxIYisqFrQqJsJ0iRYq9BO3mnKMPNJqcS1TnVOopUiQjaV/n3lVfZlJ+KOmG9JokRYrSSVoj6ULni7qrSELulPSQe/hdlUo1RXuHHQCiZvAikw8GjsfzcumBF/W8Cu/bhNvwos+txvMwehF4Of0gbooUe/H/giwrLYVKpfgAAAAASUVORK5CYII=" alt="Logo" + style="width:20%">
-
+
Settings Page
+
Restart
@@ -29,7 +30,7 @@ const char SETTINGS_PAGE[] PROGMEM = R""""(