pull/166/head
Peter Buchegger 2022-03-19 22:29:38 +01:00
rodzic ee25e0194f
commit 9c2fb18d1b
1 zmienionych plików z 22 dodań i 24 usunięć

Wyświetl plik

@ -13,35 +13,33 @@ OTATask::~OTATask() {
bool OTATask::setup(System &system) {
_ota.onStart([&]() {
String type;
if (_ota.getCommand() == U_FLASH)
if (_ota.getCommand() == U_FLASH) {
type = "sketch";
else // U_SPIFFS
} else { // U_SPIFFS
type = "filesystem";
logPrintlnI("Start updating " + type);
}
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Start updating %s", type);
})
.onEnd([]() {
logPrintlnI("");
logPrintlnI("OTA End");
.onEnd([&]() {
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "OTA End");
})
.onProgress([](unsigned int progress, unsigned int total) {
logPrintI("Progress: ");
logPrintI(String(progress / (total / 100)));
logPrintlnI("%");
.onProgress([&](unsigned int progress, unsigned int total) {
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Progress: %f", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
logPrintE("Error[");
logPrintE(String(error));
logPrintE("]: ");
if (error == OTA_AUTH_ERROR)
logPrintlnE("Auth Failed");
else if (error == OTA_BEGIN_ERROR)
logPrintlnE("Begin Failed");
else if (error == OTA_CONNECT_ERROR)
logPrintlnE("Connect Failed");
else if (error == OTA_RECEIVE_ERROR)
logPrintlnE("Receive Failed");
else if (error == OTA_END_ERROR)
logPrintlnE("End Failed");
.onError([&](ota_error_t error) {
String error_str;
if (error == OTA_AUTH_ERROR) {
error_str = "Auth Failed";
} else if (error == OTA_BEGIN_ERROR) {
error_str = "Begin Failed";
} else if (error == OTA_CONNECT_ERROR) {
error_str = "Connect Failed";
} else if (error == OTA_RECEIVE_ERROR) {
error_str = "Receive Failed";
} else if (error == OTA_END_ERROR) {
error_str = "End Failed";
}
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Error[%d]: %s", error, error_str);
});
if (system.getUserConfig()->network.hostname.overwrite) {
_ota.setHostname(system.getUserConfig()->network.hostname.name.c_str());