From ea1dbf4239879339840f65069f455139a5b11ab3 Mon Sep 17 00:00:00 2001 From: wrfz <77174685+wrfz@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:49:26 +0100 Subject: [PATCH] Remove PartitionDumper --- .../daikin_rotex_can/partitions_dumper.cpp | 65 ------------------- .../daikin_rotex_can/partitions_dumper.h | 20 ------ examples/full.yaml | 10 +-- 3 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 components/daikin_rotex_can/partitions_dumper.cpp delete mode 100644 components/daikin_rotex_can/partitions_dumper.h diff --git a/components/daikin_rotex_can/partitions_dumper.cpp b/components/daikin_rotex_can/partitions_dumper.cpp deleted file mode 100644 index 9298dcf..0000000 --- a/components/daikin_rotex_can/partitions_dumper.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "partitions_dumper.h" -#include -#include -#include -#include -#include "esphome/core/log.h" - -namespace esphome { -namespace daikin_rotex_can { - -std::string PartitionsDumper::to_hex(std::array const& data) { - std::stringstream str; - str.setf(std::ios_base::hex, std::ios::basefield); - str.setf(std::ios_base::uppercase); - str.fill('0'); - - bool first = true; - for (uint8_t chr : data) - { - if (first) { - first = false; - } else { - str << " "; - } - str << std::setw(2) << (unsigned short)(std::byte)chr; - } - return str.str(); -} - -void PartitionsDumper::print_ota_partition(esp_partition_t const* partition, std::string const& partition_getter) { - std::string label; - esp_err_t err_state; - esp_ota_img_states_t ota_state; - std::string data; - - if (partition) { - label = partition->label; - err_state = esp_ota_get_state_partition(partition, &ota_state); - - uint8_t buf[16]; - const auto state = esp_partition_read(partition, 0, buf, sizeof(buf)); - - std::array buf_array; - std::copy(std::begin(buf), std::end(buf), buf_array.begin()); - - data = to_hex(buf_array); - } else { - label = "nullptr"; - } - ESP_LOGE("TEST", "%s: %s, err_state: %d, ota_state:%d, data: %s", - partition_getter.c_str(), label.c_str(), err_state, ota_state, data.c_str()); -} - -void PartitionsDumper::dump() { - ESP_LOGE("TEST", "esp_ota_get_app_partition_count: %d", - esp_ota_get_app_partition_count()); - - print_ota_partition(esp_ota_get_boot_partition(), "esp_ota_get_boot_partition"); - print_ota_partition(esp_ota_get_last_invalid_partition(), "esp_ota_get_last_invalid_partition"); - print_ota_partition(esp_ota_get_running_partition(), "esp_ota_get_running_partition"); - print_ota_partition(esp_ota_get_next_update_partition(nullptr), "esp_ota_get_next_update_partition"); -} - -} -} \ No newline at end of file diff --git a/components/daikin_rotex_can/partitions_dumper.h b/components/daikin_rotex_can/partitions_dumper.h deleted file mode 100644 index 4a46381..0000000 --- a/components/daikin_rotex_can/partitions_dumper.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include -#include "esp_partition.h" - -namespace esphome { -namespace daikin_rotex_can { - -class PartitionsDumper { -public: - static void dump(); - -private: - static std::string to_hex(std::array const& data); - static void print_ota_partition(esp_partition_t const* partition, std::string const& partition_getter); -}; - -} -} \ No newline at end of file diff --git a/examples/full.yaml b/examples/full.yaml index 57857f1..96b1c8b 100644 --- a/examples/full.yaml +++ b/examples/full.yaml @@ -1,14 +1,12 @@ esphome: - name: rotex - friendly_name: Rotex + name: hpsu-can + friendly_name: HPSU.CAN platformio_options: build_unflags: - "-std=gnu++11" - "-fno-rtti" build_flags: - "-std=gnu++17" - includes: - - "components/daikin_rotex_can/partitions_dumper.h" esp32: board: esp32-s3-devkitc-1 @@ -75,10 +73,6 @@ sensor: button: - platform: restart name: "Rotex ESP Restart" - - platform: template - name: Dump Partitions - on_press: - - lambda: esphome::daikin_rotex_can::PartitionsDumper::dump(); #switch: # - platform: gpio # name: Smart Grid