diff --git a/esphome/components/ble_client/automation.cpp b/esphome/components/ble_client/automation.cpp deleted file mode 100644 index 49f72d095b..0000000000 --- a/esphome/components/ble_client/automation.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "esphome/core/defines.h" - -#ifdef USE_ESP32 -#include "automation.h" -#elif defined(USE_BLE_GATT_CLIENT) -#include "automation_gatt.h" -#endif - -#if defined(USE_ESP32) || defined(USE_BLE_GATT_CLIENT) -namespace esphome::ble_client { - -const char *const Automation::TAG = "ble_client.automation"; - -} // namespace esphome::ble_client -#endif diff --git a/esphome/components/ble_client/automation.h b/esphome/components/ble_client/automation.h index f4585d01e2..74ce9f82b2 100644 --- a/esphome/components/ble_client/automation.h +++ b/esphome/components/ble_client/automation.h @@ -7,13 +7,6 @@ namespace esphome::ble_client { -// placeholder class for static TAG . -class Automation { - public: - // could be made inline with C++17 - static const char *const TAG; -}; - // implement on_connect automation. class BLEClientConnectTrigger final : public Trigger<>, public BLEClientNode { public: diff --git a/esphome/components/ble_client/automation_gatt.h b/esphome/components/ble_client/automation_gatt.h index 9ea2518ccf..be5a861684 100644 --- a/esphome/components/ble_client/automation_gatt.h +++ b/esphome/components/ble_client/automation_gatt.h @@ -18,12 +18,6 @@ namespace esphome::ble_client { -// placeholder class for static TAG (shared with automation.cpp). -class Automation { - public: - static const char *const TAG; -}; - class BLEClientConnectTrigger final : public Trigger<> { public: explicit BLEClientConnectTrigger(BLEClient *parent) { diff --git a/esphome/components/ble_client/connect_backoff.h b/esphome/components/ble_client/connect_backoff.h index f99c0fdd94..ec2bf67077 100644 --- a/esphome/components/ble_client/connect_backoff.h +++ b/esphome/components/ble_client/connect_backoff.h @@ -17,12 +17,12 @@ namespace esphome::ble_client { class ConnectBackoff { public: bool holding_off() const { - return this->failures_ != 0 && static_cast(now_() - this->start_) < this->failures_ * STEP_TICKS; + return this->failures_ != 0 && static_cast(now() - this->start_) < this->failures_ * STEP_TICKS; } void register_failure(const char *address_str) { if (this->failures_ < MAX_STEPS) this->failures_++; - this->start_ = now_(); + this->start_ = now(); esph_log_w("ble_client", "[%s] Holding off reconnect for %u s", address_str, this->failures_ * 10u); } void reset() { this->failures_ = 0; } @@ -32,7 +32,7 @@ class ConnectBackoff { // a minute at worst. static constexpr uint16_t STEP_TICKS = 40; // x 256 ms static constexpr uint8_t MAX_STEPS = 6; - static uint16_t now_() { return static_cast(millis() >> 8); } + static uint16_t now() { return static_cast(millis() >> 8); } uint16_t start_{0}; uint8_t failures_{0};