From 55c3b66ed8884357ddc000102376ee4aeef927d3 Mon Sep 17 00:00:00 2001 From: Rapsssito Date: Mon, 1 Jul 2024 14:36:04 +0200 Subject: [PATCH] Rework notify notation --- .../components/esp32_ble_server/ble_characteristic.cpp | 8 ++++---- esphome/components/esp32_ble_server/ble_characteristic.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/esphome/components/esp32_ble_server/ble_characteristic.cpp b/esphome/components/esp32_ble_server/ble_characteristic.cpp index b0b5501cde..92a85bdd25 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.cpp +++ b/esphome/components/esp32_ble_server/ble_characteristic.cpp @@ -84,10 +84,10 @@ void BLECharacteristic::set_value(bool &data) { this->set_value(temp, 1); } -void BLECharacteristic::notify(bool notification) { - if (!notification) { - ESP_LOGW(TAG, "notification=false is not yet supported"); - // TODO: Handle when notification=false +void BLECharacteristic::notify(bool require_ack) { + if (require_ack) { + ESP_LOGW(TAG, "require_ack=true is not yet supported (i.e. INDICATE is not yet supported)"); + // TODO: Handle when require_ack=true } if (this->service_->get_server()->get_connected_client_count() == 0) return; diff --git a/esphome/components/esp32_ble_server/ble_characteristic.h b/esphome/components/esp32_ble_server/ble_characteristic.h index 8837c796a5..a43ba05ac0 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.h +++ b/esphome/components/esp32_ble_server/ble_characteristic.h @@ -45,7 +45,8 @@ class BLECharacteristic { void set_write_property(bool value); void set_write_no_response_property(bool value); - void notify(bool notification = true); + void indicate() { this->notify(true); } + void notify(bool require_ack = false); void do_create(BLEService *service); void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);