diff --git a/esphome/components/esp32_ble_server/ble_server_automations.cpp b/esphome/components/esp32_ble_server/ble_server_automations.cpp index 697928a58f..f9e1706ba4 100644 --- a/esphome/components/esp32_ble_server/ble_server_automations.cpp +++ b/esphome/components/esp32_ble_server/ble_server_automations.cpp @@ -20,7 +20,7 @@ Trigger> *BLETriggers::create_on_write_trigger(BLECharacter void BLECharacteristicSetValueActionManager::set_listener(BLECharacteristic *characteristic, EventEmitterListenerID listener_id, - std::function pre_notify_listener) { + const std::function& pre_notify_listener) { // Check if there is already a listener for this characteristic if (this->listeners_.count(characteristic) > 0) { // Unpack the pair listener_id, pre_notify_listener_id diff --git a/esphome/components/esp32_ble_server/ble_server_automations.h b/esphome/components/esp32_ble_server/ble_server_automations.h index d293621426..d9bc88268c 100644 --- a/esphome/components/esp32_ble_server/ble_server_automations.h +++ b/esphome/components/esp32_ble_server/ble_server_automations.h @@ -37,7 +37,7 @@ class BLECharacteristicSetValueActionManager return &instance; } void set_listener(BLECharacteristic *characteristic, EventEmitterListenerID listener_id, - std::function pre_notify_listener); + const std::function& pre_notify_listener); EventEmitterListenerID get_listener(BLECharacteristic *characteristic) { return this->listeners_[characteristic].first; }