From 15b87b5fb708017f591cc751ed8387e6d63b68d5 Mon Sep 17 00:00:00 2001 From: Rapsssito Date: Fri, 23 Aug 2024 12:02:55 +0200 Subject: [PATCH] Fix compatibility with new ByteBuffer --- esphome/components/esp32_ble_server/ble_characteristic.cpp | 4 +--- esphome/components/esp32_ble_server/ble_descriptor.cpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/esphome/components/esp32_ble_server/ble_characteristic.cpp b/esphome/components/esp32_ble_server/ble_characteristic.cpp index 5ec74c2b47..48556974e5 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.cpp +++ b/esphome/components/esp32_ble_server/ble_characteristic.cpp @@ -33,10 +33,8 @@ BLECharacteristic::BLECharacteristic(const ESPBTUUID uuid, uint32_t properties) } void BLECharacteristic::set_value(ByteBuffer buffer) { - size_t length = buffer.get_capacity(); - uint8_t *data = buffer.array(); xSemaphoreTake(this->set_value_lock_, 0L); - this->value_ = std::vector(data, data + length); + this->value_ = buffer.get_data(); xSemaphoreGive(this->set_value_lock_); } diff --git a/esphome/components/esp32_ble_server/ble_descriptor.cpp b/esphome/components/esp32_ble_server/ble_descriptor.cpp index cc1d4ec62b..8f05ccfd2d 100644 --- a/esphome/components/esp32_ble_server/ble_descriptor.cpp +++ b/esphome/components/esp32_ble_server/ble_descriptor.cpp @@ -46,7 +46,7 @@ void BLEDescriptor::set_value(ByteBuffer buffer) { return; } this->value_.attr_len = length; - memcpy(this->value_.attr_value, buffer.array(), length); + memcpy(this->value_.attr_value, buffer.get_data().data(), length); } void BLEDescriptor::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if,