make it work from web (thanks michael)

This commit is contained in:
proddy
2024-08-18 16:17:03 +02:00
parent 92a8a268a7
commit 119dcaa7fc
8 changed files with 68 additions and 123 deletions

View File

@@ -176,37 +176,11 @@ void UploadFileService::handleEarlyDisconnect() {
// upload firmware from a URL, like GitHub Release assets, Cloudflare R2 or Amazon S3
void UploadFileService::uploadURL(AsyncWebServerRequest * request, JsonVariant json) {
if (json.is<JsonObject>()) {
String url = json["url"].as<String>();
// this will keep a copy of the URL, but won't initiate the download yet
emsesp::EMSESP::system_.uploadFirmwareURL(json["url"].as<const char *>());
// TODO fix this from WDT crashing
// calling from "test upload" in a console, it works
// but via the web it crashes with the error message:
// E (253289) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
// E (253289) task_wdt: - async_tcp (CPU 0/1)
// E (253289) task_wdt: Tasks currently running:
// E (253289) task_wdt: CPU 0: ipc0
// E (253289) task_wdt: CPU 1: loopTask
// E (253289) task_wdt: Aborting.
//
// I think we need to stop all async services before uploading the firmware. Like MQTT?
// force close the connection
request->client()->close(true);
// start the upload
if (!emsesp::EMSESP::system_.uploadFirmwareURL(url.c_str())) {
emsesp::EMSESP::system_.upload_status(false); // tell ems-esp we're not uploading anymore
}
/*
if (!emsesp::EMSESP::system_.uploadFirmwareURL(url.c_str())) {
emsesp::EMSESP::system_.upload_status(false);
handleError(request, 500); // internal error, failed
} else {
request->onDisconnect(RestartService::restartNow);
AsyncWebServerResponse * response = request->beginResponse(200);
request->send(response);
}
*/
// end the connection
AsyncWebServerResponse * response = request->beginResponse(200);
request->send(response);
}
}