From 0486dbe3d522c361bd168f77bc4b6b0582c22162 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Thu, 27 Jun 2024 17:04:41 +0530 Subject: [PATCH] [ESP32]: Fix ble scanning for esp32 --- src/platform/ESP32/ChipDeviceScanner.h | 2 +- src/platform/ESP32/nimble/BLEManagerImpl.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/platform/ESP32/ChipDeviceScanner.h b/src/platform/ESP32/ChipDeviceScanner.h index d921ba08e859a2..81c23d8f921fa8 100644 --- a/src/platform/ESP32/ChipDeviceScanner.h +++ b/src/platform/ESP32/ChipDeviceScanner.h @@ -17,6 +17,7 @@ #pragma once +#include #include #include @@ -31,7 +32,6 @@ #include "esp_gattc_api.h" #include "esp_log.h" #include "freertos/FreeRTOS.h" -#include #include #include #endif diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index b43f866c0577f2..c6bf6b3bfad70a 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -659,7 +659,8 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBle return false; } - rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), pBuf->DataLength(), OnWriteComplete, this); + assert(pBuf->DataLength() <= UINT16_MAX); + rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), static_cast(pBuf->DataLength()), OnWriteComplete, this); if (rc != 0) { ChipLogError(Ble, "ble_gattc_write_flat failed: %d", rc);