Skip to content

Commit

Permalink
Implement ExchangeManager for messaging layer (#3290)
Browse files Browse the repository at this point in the history
* Implement ExchangeManager for messaging layer

* Update OnMessageReceived API documentation

* Remove unused header include and use static constexpr instead of enum for typesafety

* Restyled by clang-format

* Address the review comments
  • Loading branch information
yufengwangca authored Oct 22, 2020
1 parent f545a43 commit 4fc19f1
Show file tree
Hide file tree
Showing 19 changed files with 1,169 additions and 18 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
"${chip_root}/src/lib/shell",
"${chip_root}/src/lib/support",
"${chip_root}/src/lwip:all",
"${chip_root}/src/messaging",
"${chip_root}/src/setup_payload",
"${chip_root}/src/system",
"${chip_root}/src/transport",
Expand Down
4 changes: 2 additions & 2 deletions examples/common/chip-app-server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace {
class ServerCallback : public SecureSessionMgrDelegate
{
public:
void OnMessageReceived(const PacketHeader & header, Transport::PeerConnectionState * state, System::PacketBuffer * buffer,
SecureSessionMgrBase * mgr) override
void OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader, Transport::PeerConnectionState * state,
System::PacketBuffer * buffer, SecureSessionMgrBase * mgr) override
{
const size_t data_len = buffer->DataLength();
char src_addr[PeerAddress::kMaxToStringSize];
Expand Down
4 changes: 2 additions & 2 deletions examples/wifi-echo/server/esp32/main/EchoServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ static size_t odc(const uint8_t * bytes, size_t bytes_len, char * out, size_t ou
class EchoServerCallback : public SecureSessionMgrDelegate
{
public:
void OnMessageReceived(const PacketHeader & header, Transport::PeerConnectionState * state, System::PacketBuffer * buffer,
SecureSessionMgrBase * mgr) override
void OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader, Transport::PeerConnectionState * state,
System::PacketBuffer * buffer, SecureSessionMgrBase * mgr) override
{
CHIP_ERROR err;
const size_t data_len = buffer->DataLength();
Expand Down
1 change: 1 addition & 0 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (chip_build_tests) {
deps = [
"${chip_root}/src/crypto/tests",
"${chip_root}/src/inet/tests",
"${chip_root}/src/messaging/tests",
"${chip_root}/src/system/tests",
"${chip_root}/src/transport/raw/tests",
"${chip_root}/src/transport/retransmit/tests",
Expand Down
5 changes: 3 additions & 2 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,9 @@ void ChipDeviceController::ClearRequestState()

void ChipDeviceController::OnNewConnection(Transport::PeerConnectionState * state, SecureSessionMgrBase * mgr) {}

void ChipDeviceController::OnMessageReceived(const PacketHeader & header, Transport::PeerConnectionState * state,
System::PacketBuffer * msgBuf, SecureSessionMgrBase * mgr)
void ChipDeviceController::OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader,
Transport::PeerConnectionState * state, System::PacketBuffer * msgBuf,
SecureSessionMgrBase * mgr)
{
if (header.GetSourceNodeId().HasValue())
{
Expand Down
4 changes: 2 additions & 2 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class DLL_EXPORT ChipDeviceController : public SecureSessionMgrDelegate,
*/
CHIP_ERROR ServiceEventSignal();

void OnMessageReceived(const PacketHeader & header, Transport::PeerConnectionState * state, System::PacketBuffer * msgBuf,
SecureSessionMgrBase * mgr) override;
void OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader, Transport::PeerConnectionState * state,
System::PacketBuffer * msgBuf, SecureSessionMgrBase * mgr) override;

void OnNewConnection(Transport::PeerConnectionState * state, SecureSessionMgrBase * mgr) override;

Expand Down
1 change: 1 addition & 0 deletions src/lib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static_library("lib") {
"${chip_root}/src/inet",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
"${chip_root}/src/platform",
"${chip_root}/src/setup_payload",
"${chip_root}/src/system",
Expand Down
37 changes: 37 additions & 0 deletions src/messaging/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")

static_library("messaging") {
output_name = "libMessagingLayer"

sources = [
"ExchangeContext.cpp",
"ExchangeContext.h",
"ExchangeMgr.cpp",
"ExchangeMgr.h",
]

cflags = [ "-Wconversion" ]

public_deps = [
"${chip_root}/src/crypto",
"${chip_root}/src/inet",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
"${chip_root}/src/transport",
"${chip_root}/src/transport/raw",
]
}
Loading

0 comments on commit 4fc19f1

Please sign in to comment.