From 41561417c015cfc9d56f465620048de66f96105e Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 2 Dec 2020 11:33:55 -0800 Subject: [PATCH] Remove extra build constructs and update against the latest system API changes --- BUILD.gn | 2 ++ src/messaging/tests/echo/.gn | 23 ------------ src/messaging/tests/echo/README.md | 5 ++- src/messaging/tests/echo/args.gni | 17 --------- src/messaging/tests/echo/build | 1 - src/messaging/tests/echo/build_overrides | 1 - src/messaging/tests/echo/common.cpp | 2 +- src/messaging/tests/echo/common.h | 2 +- src/messaging/tests/echo/echo_requester.cpp | 36 +++++-------------- src/messaging/tests/echo/echo_responder.cpp | 2 +- .../tests/echo/third_party/connectedhomeip | 1 - 11 files changed, 16 insertions(+), 76 deletions(-) delete mode 100644 src/messaging/tests/echo/.gn delete mode 100644 src/messaging/tests/echo/args.gni delete mode 120000 src/messaging/tests/echo/build delete mode 120000 src/messaging/tests/echo/build_overrides delete mode 120000 src/messaging/tests/echo/third_party/connectedhomeip diff --git a/BUILD.gn b/BUILD.gn index c6209ba5f5e365..7809f5e9fe6f2d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -64,6 +64,8 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { if (chip_build_tools) { deps += [ "${chip_root}/examples/shell/standalone:chip-shell", + "${chip_root}/src/messaging/tests/echo:chip-echo-requester", + "${chip_root}/src/messaging/tests/echo:chip-echo-responder", "${chip_root}/src/qrcodetool", "${chip_root}/src/setup_payload", ] diff --git a/src/messaging/tests/echo/.gn b/src/messaging/tests/echo/.gn deleted file mode 100644 index c3cfa5fd40318d..00000000000000 --- a/src/messaging/tests/echo/.gn +++ /dev/null @@ -1,23 +0,0 @@ -# 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. - -# The location of the build configuration file. -buildconfig = "//build/config/BUILDCONFIG.gn" - -# CHIP uses angle bracket includes. -check_system_includes = true - -default_args = { - import("//args.gni") -} diff --git a/src/messaging/tests/echo/README.md b/src/messaging/tests/echo/README.md index 7d6b8e1b356229..f1c54859ce4efb 100644 --- a/src/messaging/tests/echo/README.md +++ b/src/messaging/tests/echo/README.md @@ -22,9 +22,8 @@ transport (TCP, UDP, or CRMP). ## Building ``` -cd echo -git submodule update --init -source third_party/connectedhomeip/scripts/activate.sh +source scripts/activate.sh +cd src/messaging/tests/echo gn gen out/debug ninja -C out/debug ``` diff --git a/src/messaging/tests/echo/args.gni b/src/messaging/tests/echo/args.gni deleted file mode 100644 index 311ddab32d5fe5..00000000000000 --- a/src/messaging/tests/echo/args.gni +++ /dev/null @@ -1,17 +0,0 @@ -# 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") - -import("${chip_root}/config/standalone/args.gni") diff --git a/src/messaging/tests/echo/build b/src/messaging/tests/echo/build deleted file mode 120000 index d56ed62ae4d1ff..00000000000000 --- a/src/messaging/tests/echo/build +++ /dev/null @@ -1 +0,0 @@ -third_party/connectedhomeip/build \ No newline at end of file diff --git a/src/messaging/tests/echo/build_overrides b/src/messaging/tests/echo/build_overrides deleted file mode 120000 index 5afb53da4ed522..00000000000000 --- a/src/messaging/tests/echo/build_overrides +++ /dev/null @@ -1 +0,0 @@ -../../../../examples/build_overrides \ No newline at end of file diff --git a/src/messaging/tests/echo/common.cpp b/src/messaging/tests/echo/common.cpp index e9502e72b520e1..6dcba4c6611a1f 100644 --- a/src/messaging/tests/echo/common.cpp +++ b/src/messaging/tests/echo/common.cpp @@ -28,7 +28,7 @@ #include // The ExchangeManager global object. -ExchangeManager gExchangeManager; +Messaging::ExchangeManager gExchangeManager; void InitializeChip(void) { diff --git a/src/messaging/tests/echo/common.h b/src/messaging/tests/echo/common.h index adf21c8731de45..d33df14d728752 100644 --- a/src/messaging/tests/echo/common.h +++ b/src/messaging/tests/echo/common.h @@ -42,7 +42,7 @@ using namespace chip; constexpr chip::NodeId kClientDeviceId = 12344321; constexpr chip::NodeId kServerDeviceId = 12344322; -extern ExchangeManager gExchangeManager; +extern Messaging::ExchangeManager gExchangeManager; void InitializeChip(void); void ShutdownChip(void); diff --git a/src/messaging/tests/echo/echo_requester.cpp b/src/messaging/tests/echo/echo_requester.cpp index 1bdbe9706fe14d..6445ccf5254c5a 100644 --- a/src/messaging/tests/echo/echo_requester.cpp +++ b/src/messaging/tests/echo/echo_requester.cpp @@ -77,49 +77,31 @@ bool EchoIntervalExpired(void) return (Now() >= gLastEchoTime + gEchoInterval); } -System::PacketBuffer * FormulateEchoRequestBuffer() +CHIP_ERROR SendEchoRequest(void) { - System::PacketBufferHandle buffer = System::PacketBuffer::New(); + CHIP_ERROR err = CHIP_NO_ERROR; + System::PacketBufferHandle payloadBuf = System::PacketBuffer::New(); - if (buffer.IsNull()) + if (payloadBuf.IsNull()) { printf("Unable to allocate PacketBuffer\n"); - return nullptr; + return CHIP_ERROR_NO_MEMORY; } else { // Add some application payload data in the buffer. - char * p = reinterpret_cast(buffer->Start()); + char * p = reinterpret_cast(payloadBuf->Start()); int32_t len = snprintf(p, CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE, "Echo Message %" PRIu64 "\n", gEchoCount); // Set the datalength in the buffer appropriately. - buffer->SetDataLength((uint16_t) len); - - return buffer.Release_ForNow(); + payloadBuf->SetDataLength((uint16_t) len); } -} - -CHIP_ERROR SendEchoRequest(void) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - System::PacketBuffer * payloadBuf = NULL; gLastEchoTime = Now(); - payloadBuf = FormulateEchoRequestBuffer(); - if (payloadBuf == NULL) - { - return CHIP_ERROR_NO_MEMORY; - } - printf("\nSend echo request message to Node: %lu\n", kServerDeviceId); - err = gEchoClient.SendEchoRequest(kServerDeviceId, payloadBuf); - - // Set the local buffer to NULL after passing it down to - // the lower layers who are now responsible for freeing - // the buffer. - payloadBuf = NULL; + err = gEchoClient.SendEchoRequest(kServerDeviceId, std::move(payloadBuf)); if (err == CHIP_NO_ERROR) { @@ -161,7 +143,7 @@ CHIP_ERROR EstablishSecureSession() return err; } -void HandleEchoResponseReceived(NodeId nodeId, System::PacketBuffer * payload) +void HandleEchoResponseReceived(NodeId nodeId, System::PacketBufferHandle payload) { uint32_t respTime = Now(); uint32_t transitTime = respTime - gLastEchoTime; diff --git a/src/messaging/tests/echo/echo_responder.cpp b/src/messaging/tests/echo/echo_responder.cpp index 7bce0013f41d25..4044c114b05391 100644 --- a/src/messaging/tests/echo/echo_responder.cpp +++ b/src/messaging/tests/echo/echo_responder.cpp @@ -41,7 +41,7 @@ SecureSessionMgr gSessionManager; SecurePairingUsingTestSecret gTestPairing; // Callback handler when a CHIP EchoRequest is received. -void HandleEchoRequestReceived(NodeId nodeId, System::PacketBuffer * payload) +void HandleEchoRequestReceived(NodeId nodeId, System::PacketBufferHandle payload) { printf("Echo Request from node %lu, len=%u ... sending response.\n", nodeId, payload->DataLength()); } diff --git a/src/messaging/tests/echo/third_party/connectedhomeip b/src/messaging/tests/echo/third_party/connectedhomeip deleted file mode 120000 index 3efed95be5dbe9..00000000000000 --- a/src/messaging/tests/echo/third_party/connectedhomeip +++ /dev/null @@ -1 +0,0 @@ -../../../../../ \ No newline at end of file