From 30335eaf93f8db5ad2147942d5d42f9b6a1a6eeb Mon Sep 17 00:00:00 2001 From: Rapsssito Date: Sat, 13 Jul 2024 12:03:34 +0200 Subject: [PATCH] Fix linting issues --- .../components/esp32_ble_server/ble_characteristic.cpp | 6 +++--- esphome/core/event_emitter.cpp | 2 +- esphome/core/event_emitter.h | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/components/esp32_ble_server/ble_characteristic.cpp b/esphome/components/esp32_ble_server/ble_characteristic.cpp index 200092b39a..867aad4126 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.cpp +++ b/esphome/components/esp32_ble_server/ble_characteristic.cpp @@ -180,7 +180,7 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt if (!param->read.need_rsp) break; // For some reason you can request a read but not want a response - this->EventEmitter::emit(BLECharacteristicEvt::EmptyEvt::ON_READ); + this->EventEmitter::emit_(BLECharacteristicEvt::EmptyEvt::ON_READ); uint16_t max_offset = 22; @@ -248,7 +248,7 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt } if (!param->write.is_prep) { - this->EventEmitter>::emit( + this->EventEmitter>::emit_( BLECharacteristicEvt::VectorEvt::ON_WRITE, this->value_); } @@ -260,7 +260,7 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt break; this->write_event_ = false; if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) { - this->EventEmitter>::emit( + this->EventEmitter>::emit_( BLECharacteristicEvt::VectorEvt::ON_WRITE, this->value_); } esp_err_t err = diff --git a/esphome/core/event_emitter.cpp b/esphome/core/event_emitter.cpp index f86b221dad..7bd3ad51ca 100644 --- a/esphome/core/event_emitter.cpp +++ b/esphome/core/event_emitter.cpp @@ -4,7 +4,7 @@ namespace esphome { static const char *const TAG = "event_emitter"; -void RaiseEventEmitterFullError() { +void raise_event_emitter_full_error() { ESP_LOGE(TAG, "EventEmitter has reached the maximum number of listeners for event"); ESP_LOGW(TAG, "Removing listener to make space for new listener"); } diff --git a/esphome/core/event_emitter.h b/esphome/core/event_emitter.h index a5d4bea978..7a78361456 100644 --- a/esphome/core/event_emitter.h +++ b/esphome/core/event_emitter.h @@ -9,14 +9,14 @@ namespace esphome { using EventEmitterListenerID = uint32_t; -void RaiseEventEmitterFullError(); +void raise_event_emitter_full_error(); // EventEmitter class that can emit events with a specific name (it is highly recommended to use an enum class for this) // and a list of arguments. Supports multiple listeners for each event. template class EventEmitter { public: EventEmitterListenerID on(EvtType event, std::function listener) { - EventEmitterListenerID listener_id = get_next_id(event); + EventEmitterListenerID listener_id = get_next_id_(event); listeners_[event][listener_id] = listener; return listener_id; } @@ -28,7 +28,7 @@ template class EventEmitter { } protected: - void emit(EvtType event, Args... args) { + void emit_(EvtType event, Args... args) { if (listeners_.count(event) == 0) return; for (const auto &listener : listeners_[event]) { @@ -36,11 +36,11 @@ template class EventEmitter { } } - EventEmitterListenerID get_next_id(EvtType event) { + EventEmitterListenerID get_next_id_(EvtType event) { // Check if the map is full if (listeners_[event].size() == std::numeric_limits::max()) { // Raise an error if the map is full - RaiseEventEmitterFullError(); + raise_event_emitter_full_error(); off(event, 0); return 0; }