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,