Skip to content

Commit

Permalink
ESP32: Fix data copy in BLE HandleRxNotify() (#34204)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqx6 authored and pull[bot] committed Jul 29, 2024
1 parent 9ca7d1b commit 8575029
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/platform/ESP32/nimble/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,10 +1749,12 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg)
#ifdef CONFIG_ENABLE_ESP32_BLE_CONTROLLER
CHIP_ERROR BLEManagerImpl::HandleRXNotify(struct ble_gap_event * ble_event)
{
uint8_t * data = OS_MBUF_DATA(ble_event->notify_rx.om, uint8_t *);
size_t dataLen = OS_MBUF_PKTLEN(ble_event->notify_rx.om);
System::PacketBufferHandle buf = System::PacketBufferHandle::NewWithData(data, dataLen);
System::PacketBufferHandle buf = System::PacketBufferHandle::New(dataLen, 0);
VerifyOrReturnError(!buf.IsNull(), CHIP_ERROR_NO_MEMORY);
VerifyOrExit(buf->AvailableDataLength() >= data_len, err = CHIP_ERROR_BUFFER_TOO_SMALL);
ble_hs_mbuf_to_flat(ble_event->notify_rx.om, buf->Start(), data_len, NULL);
buf->SetDataLength(data_len);

ChipLogDetail(DeviceLayer, "Indication received, conn = %d", ble_event->notify_rx.conn_handle);

Expand Down

0 comments on commit 8575029

Please sign in to comment.