Skip to content

Commit

Permalink
[shell] Add send cmd to allow send any CHIP message for testing (#6239)
Browse files Browse the repository at this point in the history
* Add send cmd for testing

* Enable ping/send commands only on CHIP controller

* Move global varibles to common.cpp

* Enable ping and send commands on accessory side

* Address review comments
  • Loading branch information
yufengwangca authored and pull[bot] committed Jul 21, 2021
1 parent dfa12a7 commit 1984018
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 20 deletions.
2 changes: 2 additions & 0 deletions examples/shell/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ set(CHIP_SHELL_DIR "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/she


idf_component_register(SRCS main.cpp
"${CHIP_SHELL_DIR}/shell_common/globals.cpp"
"${CHIP_SHELL_DIR}/shell_common/cmd_ping.cpp"
"${CHIP_SHELL_DIR}/shell_common/cmd_send.cpp"
PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src"
"${CHIP_SHELL_DIR}/shell_common/include"
Expand Down
4 changes: 3 additions & 1 deletion examples/shell/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ target_include_directories(app PRIVATE
${APP_ROOT}/shell_common/include)

target_sources(app PRIVATE
${APP_ROOT}/shell_common/globals.cpp
${APP_ROOT}/shell_common/cmd_base64.cpp
${APP_ROOT}/shell_common/cmd_device.cpp
${APP_ROOT}/shell_common/cmd_misc.cpp
${APP_ROOT}/shell_common/cmd_otcli.cpp
${APP_ROOT}/shell_common/cmd_ping.cpp
${APP_ROOT}/shell_common/cmd_ping.cpp
${APP_ROOT}/shell_common/cmd_send.cpp
${APP_ROOT}/shell_common/cmd_btp.cpp
${APP_ROOT}/standalone/main.cpp
)
Expand Down
2 changes: 2 additions & 0 deletions examples/shell/shell_common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static_library("shell_common") {
"cmd_misc.cpp",
"cmd_otcli.cpp",
"cmd_ping.cpp",
"cmd_send.cpp",
"globals.cpp",
]

public_deps = [
Expand Down
21 changes: 2 additions & 19 deletions examples/shell/shell_common/cmd_ping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@
#include <transport/raw/UDP.h>

#include <ChipShellCollection.h>
#include <Globals.h>

using namespace chip;
using namespace Shell;
using namespace Logging;
using chip::Inet::IPAddress;

#if INET_CONFIG_ENABLE_TCP_ENDPOINT
constexpr size_t kMaxTcpActiveConnectionCount = 4;
constexpr size_t kMaxTcpPendingPackets = 4;
#endif
constexpr size_t kMaxPayloadSize = 1280;

namespace {

class PingArguments
Expand Down Expand Up @@ -132,20 +127,8 @@ class PingArguments
bool mUsingCRMP;
} gPingArguments;

constexpr Transport::AdminId gAdminId = 0;

Protocols::Echo::EchoClient gEchoClient;

TransportMgr<Transport::UDP> gUDPManager;

#if INET_CONFIG_ENABLE_TCP_ENDPOINT
TransportMgr<Transport::TCP<kMaxTcpActiveConnectionCount, kMaxTcpPendingPackets>> gTCPManager;
#endif

Messaging::ExchangeManager gExchangeManager;
SecureSessionMgr gSessionManager;
IPAddress gDestAddr;

bool EchoIntervalExpired(void)
{
uint64_t now = System::Timer::GetCurrentEpoch();
Expand Down Expand Up @@ -426,7 +409,7 @@ int cmd_ping(int argc, char ** argv)
case 'p':
if (++optIndex >= argc || argv[optIndex][0] == '-')
{
streamer_printf(sout, "Invalid argument specified for -c\n");
streamer_printf(sout, "Invalid argument specified for -p\n");
return -1;
}
else
Expand Down
Loading

0 comments on commit 1984018

Please sign in to comment.