mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
make it work from web (thanks michael)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user