Skip to content

Commit

Permalink
[ESP32]: Fix ble scanning for esp32 (#34110)
Browse files Browse the repository at this point in the history
* [ESP32]: Fix ble scanning for esp32

* Restyled by clang-format

* Address review comment

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
jadhavrohit924 and restyled-commits authored Jun 28, 2024
1 parent 03ae36e commit 0460715
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/platform/ESP32/ChipDeviceScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#pragma once

#include <ble/Ble.h>
#include <lib/core/CHIPError.h>
#include <system/SystemLayer.h>

Expand All @@ -31,7 +32,6 @@
#include "esp_gattc_api.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include <ble/Ble.h>
#include <lib/core/CHIPError.h>
#include <system/SystemLayer.h>
#endif
Expand Down
8 changes: 7 additions & 1 deletion src/platform/ESP32/nimble/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,13 @@ 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);
if (pBuf->DataLength() > UINT16_MAX)
{
ChipLogError(Ble, "Buffer data Length is too long");
return false;
}
rc = ble_gattc_write_flat(conId, chr->chr.val_handle, pBuf->Start(), static_cast<uint16_t>(pBuf->DataLength()), OnWriteComplete,
this);
if (rc != 0)
{
ChipLogError(Ble, "ble_gattc_write_flat failed: %d", rc);
Expand Down

0 comments on commit 0460715

Please sign in to comment.