From ecd6a42aeef37000fc3c5c9fc2bdc50366a0dffd Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Thu, 28 May 2026 16:06:18 +0000 Subject: [PATCH] Remove unused abstractions There's only 1 protocol (secplus2) and board (esp32) --- components/ratgdo/protocol.h | 38 ------------------------- components/ratgdo/ratgdo.cpp | 2 +- components/ratgdo/ratgdo.h | 5 ++-- components/ratgdo/ratgdo_uart.h | 4 --- components/ratgdo/ratgdo_uart_esp32.cpp | 2 +- components/ratgdo/secplus2.h | 13 ++++----- 6 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 components/ratgdo/protocol.h delete mode 100644 components/ratgdo/ratgdo_uart.h diff --git a/components/ratgdo/protocol.h b/components/ratgdo/protocol.h deleted file mode 100644 index c38a5df..0000000 --- a/components/ratgdo/protocol.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "common.h" -#include "ratgdo_state.h" - -namespace esphome { - -class Scheduler; -class InternalGPIOPin; - -} // namespace esphome - -namespace esphome::ratgdo { - -class RATGDOComponent; - -namespace protocol { - - class Protocol { - public: - virtual void setup(RATGDOComponent* ratgdo, Scheduler* scheduler, InternalGPIOPin* rx_pin, InternalGPIOPin* tx_pin); - virtual void loop(); - virtual void dump_config(); - - virtual void on_shutdown() { } - - virtual void sync(); - - virtual void light_action(LightAction action); - virtual void lock_action(LockAction action); - virtual void door_action(DoorAction action); - - virtual void query_status() {} - virtual void query_openings() {} - }; - -} -} // namespace esphome::ratgdo diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 38069ac..c46a330 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -23,7 +23,7 @@ namespace esphome::ratgdo { -using namespace protocol; + static const char* const TAG = "ratgdo"; static constexpr int SYNC_DELAY = 5000; diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 382c862..0af31b3 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -24,11 +24,12 @@ #include "callbacks.h" #include "observable.h" -#include "protocol.h" #include "ratgdo_state.h" namespace esphome::ratgdo { +namespace secplus2 { class Secplus2; } + class RATGDOComponent; typedef Parented RATGDOClient; @@ -185,7 +186,7 @@ public: protected: // Pointers first (4-byte aligned) - protocol::Protocol* protocol_; + secplus2::Secplus2* protocol_; InternalGPIOPin* output_gdo_pin_; InternalGPIOPin* input_gdo_pin_; diff --git a/components/ratgdo/ratgdo_uart.h b/components/ratgdo/ratgdo_uart.h deleted file mode 100644 index 73d6bf6..0000000 --- a/components/ratgdo/ratgdo_uart.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "esphome/core/defines.h" -#include "ratgdo_uart_esp32.h" diff --git a/components/ratgdo/ratgdo_uart_esp32.cpp b/components/ratgdo/ratgdo_uart_esp32.cpp index 2755eeb..ac3c11d 100644 --- a/components/ratgdo/ratgdo_uart_esp32.cpp +++ b/components/ratgdo/ratgdo_uart_esp32.cpp @@ -1,4 +1,4 @@ -#include "ratgdo_uart.h" +#include "ratgdo_uart_esp32.h" #include "esphome/core/log.h" #include diff --git a/components/ratgdo/secplus2.h b/components/ratgdo/secplus2.h index ddec648..6da1b1c 100644 --- a/components/ratgdo/secplus2.h +++ b/components/ratgdo/secplus2.h @@ -3,12 +3,11 @@ #include "esphome/core/optional.h" #include "esphome/core/preferences.h" #include "esphome/components/mqtt/mqtt_client.h" -#include "ratgdo_uart.h" +#include "ratgdo_uart_esp32.h" #include "callbacks.h" #include "common.h" #include "observable.h" -#include "protocol.h" #include "ratgdo_state.h" namespace esphome { @@ -23,8 +22,6 @@ class RATGDOComponent; namespace secplus2 { - using namespace esphome::ratgdo::protocol; - static const uint8_t PACKET_LENGTH = 19; typedef uint8_t WirePacket[PACKET_LENGTH]; @@ -94,12 +91,12 @@ namespace secplus2 { } }; - class Secplus2 : public Protocol { + class Secplus2 { public: void setup(RATGDOComponent* ratgdo, Scheduler* scheduler, InternalGPIOPin* rx_pin, InternalGPIOPin* tx_pin); void loop(); void dump_config(); - void on_shutdown() override; + void on_shutdown(); void sync(); @@ -107,8 +104,8 @@ namespace secplus2 { void lock_action(LockAction action); void door_action(DoorAction action); - void query_status() override; - void query_openings() override; + void query_status(); + void query_openings(); protected: void increment_rolling_code_counter(int delta = 1);