Fix linting issues

This commit is contained in:
Rapsssito 2024-07-13 11:24:39 +02:00
parent c3d5b7803d
commit 03ff9fca0b
4 changed files with 7 additions and 7 deletions

View file

@ -10,8 +10,8 @@ namespace esp32_ble_server_automations {
using namespace esp32_ble;
Trigger<std::vector<uint8_t>> *BLETriggers::create_on_write_trigger(BLECharacteristic *characteristic) {
Trigger<std::vector<uint8_t>> *on_write_trigger =
new Trigger<std::vector<uint8_t>>(); // NOLINT(cppcoreguidelines-owning-memory)
Trigger<std::vector<uint8_t>> *on_write_trigger = // NOLINT(cppcoreguidelines-owning-memory)
new Trigger<std::vector<uint8_t>>();
characteristic->EventEmitter<BLECharacteristicEvt::VectorEvt, std::vector<uint8_t>>::on(
BLECharacteristicEvt::VectorEvt::ON_WRITE,
[on_write_trigger](const std::vector<uint8_t> &data) { on_write_trigger->trigger(data); });

View file

@ -49,7 +49,7 @@ template<typename... Ts> class BLECharacteristicSetValueAction : public Action<T
this->parent_->set_value(this->value_.value(x...));
// Set the listener for read events
this->listener_id_ = this->parent_->EventEmitter<BLECharacteristicEvt::EmptyEvt>::on(
BLECharacteristicEvt::EmptyEvt::ON_READ, [this, x...](void) {
BLECharacteristicEvt::EmptyEvt::ON_READ, [this, x...]() {
// Set the value of the characteristic every time it is read
this->parent_->set_value(this->value_.value(x...));
});

View file

@ -4,9 +4,9 @@ namespace esphome {
static const char *const TAG = "event_emitter";
void RaiseEventEmitterFullError(EventEmitterListenerID id) {
void RaiseEventEmitterFullError() {
ESP_LOGE(TAG, "EventEmitter has reached the maximum number of listeners for event");
ESP_LOGW(TAG, "Removing listener with ID %ld to make space for new listener", id);
ESP_LOGW(TAG, "Removing listener to make space for new listener");
}
} // namespace esphome

View file

@ -9,7 +9,7 @@
namespace esphome {
using EventEmitterListenerID = uint32_t;
void RaiseEventEmitterFullError(EventEmitterListenerID id);
void RaiseEventEmitterFullError();
// 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.
@ -40,7 +40,7 @@ template<typename EvtType, typename... Args> class EventEmitter {
// Check if the map is full
if (listeners_[event].size() == std::numeric_limits<EventEmitterListenerID>::max()) {
// Raise an error if the map is full
RaiseEventEmitterFullError(0);
RaiseEventEmitterFullError();
off(event, 0);
return 0;
}