Skip to content

Commit efd2843

Browse files
jadhavrohit924restyled-commits
authored andcommitted
[ESP32]: Fix ble scanning for esp32 (project-chip#34110)
* [ESP32]: Fix ble scanning for esp32 * Restyled by clang-format * Address review comment --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 74e5a13 commit efd2843

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/platform/ESP32/ChipDeviceScanner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#pragma once
1919

20+
#include <ble/Ble.h>
2021
#include <lib/core/CHIPError.h>
2122
#include <system/SystemLayer.h>
2223

@@ -31,7 +32,6 @@
3132
#include "esp_gattc_api.h"
3233
#include "esp_log.h"
3334
#include "freertos/FreeRTOS.h"
34-
#include <ble/Ble.h>
3535
#include <lib/core/CHIPError.h>
3636
#include <system/SystemLayer.h>
3737
#endif

src/platform/ESP32/nimble/BLEManagerImpl.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,13 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBle
659659
return false;
660660
}
661661

662-
rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), pBuf->DataLength(), OnWriteComplete, this);
662+
if (pBuf->DataLength() > UINT16_MAX)
663+
{
664+
ChipLogError(Ble, "Buffer data Length is too long");
665+
return false;
666+
}
667+
rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), static_cast<uint16_t>(pBuf->DataLength()), OnWriteComplete,
668+
this);
663669
if (rc != 0)
664670
{
665671
ChipLogError(Ble, "ble_gattc_write_flat failed: %d", rc);

0 commit comments

Comments
 (0)