Skip to content

Commit

Permalink
ota: arduinoota error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Dec 7, 2024
1 parent fa5af86 commit bb9fac1
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions code/espurna/ota_arduinoota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>

#include <ArduinoOTA.h>

namespace espurna {
namespace ota {
namespace arduino {
namespace {
Expand Down Expand Up @@ -79,30 +80,36 @@ void progress(unsigned int progress, unsigned int total) {

void error(ota_error_t error) {
#if DEBUG_SUPPORT
const __FlashStringHelper* ptr { F("Unknown") };
StringView reason = STRING_VIEW("Unknown");

switch (error) {
case OTA_AUTH_ERROR:
ptr = F("Authentication");
reason = STRING_VIEW("Authentication");
break;
case OTA_BEGIN_ERROR:
ptr = F("Begin");
reason = STRING_VIEW("Begin");
break;
case OTA_CONNECT_ERROR:
ptr = F("Connection");
reason = STRING_VIEW("Connection");
break;
case OTA_RECEIVE_ERROR:
ptr = F("Receive");
reason = STRING_VIEW("Receive");
break;
#if !defined(ARDUINO_ESP8266_RELEASE_2_7_2) \
|| !defined(ARDUINO_ESP8266_RELEASE_2_7_3) \
|| !defined(ARDUINO_ESP8266_RELEASE_2_7_4)
case OTA_ERASE_SETTINGS_ERROR:
reason = STRING_VIEW("Settings erase");
break;
case OTA_END_ERROR:
ptr = F("End");
reason = STRING_VIEW("End");
break;
#endif
}

DEBUG_MSG_P(PSTR("[OTA] \"%s\" (%u, updater code %u)\n"),
reinterpret_cast<const char*>(ptr),
static_cast<unsigned int>(error),
Update.getError());
DEBUG_MSG_P(PSTR("[OTA] OTA Stopped: %.*s\n"),
reason.length(), reason.data());
otaPrintError();
#endif

eepromRotate(true);
Expand All @@ -123,9 +130,10 @@ void setup() {
} // namespace
} // namespace arduino
} // namespace ota
} // namespace espurna

void otaArduinoSetup() {
ota::arduino::setup();
espurna::ota::arduino::setup();
}

#endif // OTA_ARDUINOOTA_SUPPORT

0 comments on commit bb9fac1

Please sign in to comment.