mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2025-12-06 07:42:00 +01:00
fixing ota
This commit is contained in:
parent
ee25e0194f
commit
9c2fb18d1b
|
|
@ -13,35 +13,33 @@ OTATask::~OTATask() {
|
||||||
bool OTATask::setup(System &system) {
|
bool OTATask::setup(System &system) {
|
||||||
_ota.onStart([&]() {
|
_ota.onStart([&]() {
|
||||||
String type;
|
String type;
|
||||||
if (_ota.getCommand() == U_FLASH)
|
if (_ota.getCommand() == U_FLASH) {
|
||||||
type = "sketch";
|
type = "sketch";
|
||||||
else // U_SPIFFS
|
} else { // U_SPIFFS
|
||||||
type = "filesystem";
|
type = "filesystem";
|
||||||
logPrintlnI("Start updating " + type);
|
}
|
||||||
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Start updating %s", type);
|
||||||
})
|
})
|
||||||
.onEnd([]() {
|
.onEnd([&]() {
|
||||||
logPrintlnI("");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "OTA End");
|
||||||
logPrintlnI("OTA End");
|
|
||||||
})
|
})
|
||||||
.onProgress([](unsigned int progress, unsigned int total) {
|
.onProgress([&](unsigned int progress, unsigned int total) {
|
||||||
logPrintI("Progress: ");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, getName(), "Progress: %f", (progress / (total / 100)));
|
||||||
logPrintI(String(progress / (total / 100)));
|
|
||||||
logPrintlnI("%");
|
|
||||||
})
|
})
|
||||||
.onError([](ota_error_t error) {
|
.onError([&](ota_error_t error) {
|
||||||
logPrintE("Error[");
|
String error_str;
|
||||||
logPrintE(String(error));
|
if (error == OTA_AUTH_ERROR) {
|
||||||
logPrintE("]: ");
|
error_str = "Auth Failed";
|
||||||
if (error == OTA_AUTH_ERROR)
|
} else if (error == OTA_BEGIN_ERROR) {
|
||||||
logPrintlnE("Auth Failed");
|
error_str = "Begin Failed";
|
||||||
else if (error == OTA_BEGIN_ERROR)
|
} else if (error == OTA_CONNECT_ERROR) {
|
||||||
logPrintlnE("Begin Failed");
|
error_str = "Connect Failed";
|
||||||
else if (error == OTA_CONNECT_ERROR)
|
} else if (error == OTA_RECEIVE_ERROR) {
|
||||||
logPrintlnE("Connect Failed");
|
error_str = "Receive Failed";
|
||||||
else if (error == OTA_RECEIVE_ERROR)
|
} else if (error == OTA_END_ERROR) {
|
||||||
logPrintlnE("Receive Failed");
|
error_str = "End Failed";
|
||||||
else if (error == OTA_END_ERROR)
|
}
|
||||||
logPrintlnE("End Failed");
|
system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "Error[%d]: %s", error, error_str);
|
||||||
});
|
});
|
||||||
if (system.getUserConfig()->network.hostname.overwrite) {
|
if (system.getUserConfig()->network.hostname.overwrite) {
|
||||||
_ota.setHostname(system.getUserConfig()->network.hostname.name.c_str());
|
_ota.setHostname(system.getUserConfig()->network.hostname.name.c_str());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue