#54 code clean up

pull/1/head
Thomas Ballmann 3 years ago
parent a9a84dd06e
commit 345811c9e4

@ -198,7 +198,6 @@ void setupApiSettings()
root["system"]["dst"] = NVS.getInt("system.dst"); root["system"]["dst"] = NVS.getInt("system.dst");
root["system"]["wifi"] = NVS.getString("wifi.ssid"); root["system"]["wifi"] = NVS.getString("wifi.ssid");
//root["device"]["angle"] = NVS.getInt("device.angle");
root["device"]["theme"] = NVS.getString("device.theme"); root["device"]["theme"] = NVS.getString("device.theme");
root["device"]["name"] = NVS.getString("device.name"); root["device"]["name"] = NVS.getString("device.name");
@ -455,15 +454,16 @@ void setupApiCache()
} }
/** /**
* api data endpoint * ota update
*/ */
void setupOTA() void setupOTA()
{ {
// Simple Firmware Update Form // recovery update mode
server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request) { server.on("/update", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/html", "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='Update'></form>"); request->send(200, "text/html", "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='Update'></form>");
}); });
// handle update
server.on( server.on(
"/update", HTTP_POST, [](AsyncWebServerRequest *request) {}, "/update", HTTP_POST, [](AsyncWebServerRequest *request) {},
[](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {

@ -4,7 +4,7 @@
#include "device.h" #include "device.h"
#include "esp_task_wdt.h" #include "esp_task_wdt.h"
bool downloadFile(String url, const char *path, const char* CAcert) bool downloadFile(String url, const char *path, const char *CAcert)
{ {
// @note duration time: 200kb = 35sec write to flash // @note duration time: 200kb = 35sec write to flash
Serial.println("Download file: " + url); Serial.println("Download file: " + url);
@ -32,9 +32,12 @@ bool downloadFile(String url, const char *path, const char* CAcert)
// use the last 8 bytes of the unique serial id // use the last 8 bytes of the unique serial id
http.addHeader("X-PaperDash-Id", DeviceId); http.addHeader("X-PaperDash-Id", DeviceId);
if (CAcert) { if (CAcert)
{
http.begin(url, CAcert); http.begin(url, CAcert);
} else { }
else
{
http.begin(url); http.begin(url);
} }
@ -68,7 +71,6 @@ bool downloadFile(String url, const char *path, const char* CAcert)
return !hasError; return !hasError;
} }
bool downloadFile(String url, const char *path) bool downloadFile(String url, const char *path)
{ {
return downloadFile(url, path, NULL); return downloadFile(url, path, NULL);

Loading…
Cancel
Save