Skip to content

Commit

Permalink
Some conversions to use PacketBufferHandle (project-chip#4011)
Browse files Browse the repository at this point in the history
* Some conversions to use PacketBufferHandle

#### Problem

Code should use `PacketBufferHandle` rather than `PacketBuffer *`.

#### Summary of Changes

- Converts remaining receive path in //src/inet and //src/transport.
- Converts most of //src/ble.
- Introduces Handle versions of the `AddToEnd`/`DetachTail` pair.

Part of issue project-chip#2707 - Figure out a way to express PacketBuffer ownership in the type system

* Restyled by clang-format

* review

* revive BtpEngine::Clear[TR]xPacket()
* simplify conditional
* (void) message.DetachTail() → message.FreeHead()
* remove ExchangeContext::kSendFlag_RetainBuffer
* missed pBuf.IsNull()
* DetachHead() → PopTail()
* typos

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and hnnajh committed Dec 10, 2020
1 parent 2f5c829 commit 15e719c
Show file tree
Hide file tree
Showing 62 changed files with 354 additions and 424 deletions.
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/EchoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class EchoServerCallback : public SecureSessionMgrDelegate
ESP_LOGI(TAG, "Client sent: %s", logmsg);

// Attempt to echo back
err = mgr->SendMessage(header.GetSourceNodeId().Value(), buffer.Release_ForNow());
err = mgr->SendMessage(header.GetSourceNodeId().Value(), std::move(buffer));
if (err != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Unable to echo back to client: %s", ErrorStr(err));
Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/NetworkCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ CHIP_ERROR NetworkCommand::RunCommandInternal(ChipDevice * device)
PrintBuffer(buffer);
#endif

err = device->SendMessage(buffer.Release_ForNow());
err = device->SendMessage(std::move(buffer));
VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Failed to send message: %s", ErrorStr(err)));

exit:
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/chip-message-send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ EmberStatus chipSendUnicast(NodeId destination, EmberApsFrame * apsFrame, uint16
memcpy(buffer->Start() + frameSize, message, messageLength);
buffer->SetDataLength(dataLength);

CHIP_ERROR err = SessionManager().SendMessage(destination, buffer.Release_ForNow());
CHIP_ERROR err = SessionManager().SendMessage(destination, std::move(buffer));
if (err != CHIP_NO_ERROR)
{
// FIXME: Figure out better translations between our error types?
Expand Down
Loading

0 comments on commit 15e719c

Please sign in to comment.