Skip to content

Commit

Permalink
Revert using esp_err_t like enum
Browse files Browse the repository at this point in the history
  • Loading branch information
MathewHDYT committed Oct 9, 2024
1 parent 23ec4f3 commit 621e32c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void otaSDToFlashTask(void* pvParameter) {
ESP_LOGE("MAIN", "Failed to open file for Update");
vTaskDelete(NULL);
} else {
esp_err_t error = esp_err_t::ESP_OK;
esp_err_t error = ESP_OK;
ESP_LOGI("MAIN", "Opened File for Update");
fseek(ota_bin_file, 0, SEEK_END);
data.size = ftell(ota_bin_file);
Expand All @@ -158,16 +158,16 @@ void otaSDToFlashTask(void* pvParameter) {
data.remaining_size -= FIRMWARE_PACKET_SIZE;
vTaskDelay(0);
}
if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
ESP_LOGE("MAIN", "Failed to write OTA data: 0x%X (%s)", error, esp_err_to_name(error));
}
error = esp_ota_end(update_handle);
if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
ESP_LOGE("MAIN", "Failed to end OTA update: 0x%X (%s)", error, esp_err_to_name(error));
}

error = esp_ota_set_boot_partition(update_partition);
if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
ESP_LOGE("MAIN", "Failed to set boot partition: 0x%X (%s)", error, esp_err_to_name(error));
} else {
ESP_LOGI("MAIN", "Updated with data from SD card, Restarting");
Expand Down
2 changes: 1 addition & 1 deletion src/Callback_Watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Callback_Watchdog : public Callback<void> {
};

const esp_err_t error = esp_timer_create(&oneshot_timer_args, &m_oneshot_timer);
if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
return;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Espressif_MQTT_Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Espressif_MQTT_Client : public IMQTT_Client {
#endif // ESP_IDF_VERSION_MAJOR < 5

if (x509_bundle != nullptr) {
esp_err_t error = esp_err_t::ESP_OK;
esp_err_t error = ESP_OK;
#ifdef ARDUINO
arduino_esp_crt_bundle_set(x509_bundle);
#else
Expand Down Expand Up @@ -283,19 +283,19 @@ class Espressif_MQTT_Client : public IMQTT_Client {
// but simply force reconnection with the client because it has lost that connection
if (m_mqtt_client != nullptr) {
const esp_err_t error = esp_mqtt_client_reconnect(m_mqtt_client);
return error == esp_err_t::ESP_OK;
return error == ESP_OK;
}

// The client is first initalized once the connect has actually been called, this is done because the passed setting are required for the client inizialitation structure,
// additionally before we attempt to connect with the client we have to ensure it is configued by then.
m_mqtt_client = esp_mqtt_client_init(&m_mqtt_configuration);
esp_err_t error = esp_mqtt_client_register_event(m_mqtt_client, esp_mqtt_event_id_t::MQTT_EVENT_ANY, Espressif_MQTT_Client::static_mqtt_event_handler, this);

if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
return false;
}
error = esp_mqtt_client_start(m_mqtt_client);
return error == esp_err_t::ESP_OK;
return error == ESP_OK;
}

void disconnect() override {
Expand Down Expand Up @@ -366,7 +366,7 @@ class Espressif_MQTT_Client : public IMQTT_Client {
#if THINGSBOARD_ENABLE_DEBUG
Logger::printfln(UPDATING_CONFIGURATION, esp_err_to_name(error));
#endif // THINGSBOARD_ENABLE_DEBUG
return error == esp_err_t::ESP_OK;
return error == ESP_OK;
}

#if THINGSBOARD_ENABLE_DEBUG
Expand Down
8 changes: 4 additions & 4 deletions src/Espressif_Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Espressif_Updater : public IUpdater {
esp_ota_handle_t ota_handle;
esp_err_t const error = esp_ota_begin(update_partition, firmware_size, &ota_handle);

if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
Logger::printfln(BEGIN_UPDATE_FAILED, esp_err_to_name(error));
return false;
}
Expand All @@ -59,7 +59,7 @@ class Espressif_Updater : public IUpdater {

size_t write(uint8_t * payload, size_t const & total_bytes) override {
esp_err_t const error = esp_ota_write(m_ota_handle, payload, total_bytes);
size_t const written_bytes = (error == esp_err_t::ESP_OK) ? total_bytes : 0U;
size_t const written_bytes = (error == ESP_OK) ? total_bytes : 0U;
return written_bytes;
}

Expand All @@ -73,12 +73,12 @@ class Espressif_Updater : public IUpdater {

bool end() override {
esp_err_t error = esp_ota_end(m_ota_handle);
if (error != esp_err_t::ESP_OK) {
if (error != ESP_OK) {
return false;
}

error = esp_ota_set_boot_partition(m_update_partition);
return error == esp_err_t::ESP_OK;
return error == ESP_OK;
}

private:
Expand Down

0 comments on commit 621e32c

Please sign in to comment.