Skip to content

Commit

Permalink
[shell] Add 'server' command to shell app. (#13060)
Browse files Browse the repository at this point in the history
* [shell] Add command to start/stop zcl app server.

- Add 'server port' and 'server udcport' commands.
- Add 'server sessions' command.
- Add 'server endpoints' and 'server clusters' commands.

- Add docs for the new 'server' command subcommands (README_SERVER.md).
- Add 'server' command to build of linux and mac platforms only initially.

- Improve clean exit paths for 'server' command.
- Update 'ForEachSessionHandle' to use new Loop construct.
- Fix build failure in ota-provider (warning when logs disabled).

* [shell] Correct order of atexit and shutdown handling.

* [shell] Add OTA stubs.

* Apply suggestions from code review

Co-authored-by: Łukasz Duda <[email protected]>

* [session] Update ForEachSessionHandle to new API.

Co-authored-by: Łukasz Duda <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 21, 2023
1 parent d020705 commit 1709204
Show file tree
Hide file tree
Showing 22 changed files with 515 additions and 19 deletions.
14 changes: 9 additions & 5 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

14
15
16
17
ContentApp's
18
19
20
21
22

AAAA
aabbccddeeff
aarch
Expand All @@ -25,9 +24,9 @@ ACL
AdapterAddress
AdapterName
adb
addr
AddOrUpdateThreadNetwork
AddOrUpdateWiFiNetwork
addr
adk
adoc
AdvAutonomous
Expand Down Expand Up @@ -217,11 +216,13 @@ ConnectionData
ConnectIP
ConnectivityManager
ConnectivityManagerImpl
ConnectNetwork
connstring
conntype
const
ContentApp
ContentAppPlatform
ContentApp's
ContentLaunch
ContentLauncher
contrib
Expand Down Expand Up @@ -354,7 +355,6 @@ elftools
elock
emberAfExternalAttributeReadCallback
emberAfExternalAttributeWriteCallback
ConnectNetwork
EnableWiFiNetwork
EndpointId
endpointName
Expand Down Expand Up @@ -383,6 +383,7 @@ ExtendedPAN
extern
extpanid
FabricId
fabricIdx
factoryreset
fb
fbb
Expand Down Expand Up @@ -750,6 +751,8 @@ pcaps
PDFs
PDK
peerAddrStr
peerNodeId
peerSessionId
pem
percentageLiftValue
pexpect
Expand Down Expand Up @@ -1006,8 +1009,9 @@ ttyUSB
TXD
txt
UART
UDC
udc
UDC
udcport
udhcpc
UDP
UDPEndPoint
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/efr32/matter_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void WaitForShellActivity()

void startShellTask()
{
int status = chip::Shell::streamer_init(chip::Shell::streamer_get());
int status = chip::Shell::Engine::Root().Init();
assert(status == 0);

// For now also register commands from shell_common (shell app).
Expand Down
1 change: 1 addition & 0 deletions examples/shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Done
- [otcli](README_OTCLI.md)
- [ping](#ping)
- [rand](#rand)
- [server](README_SERVER.md)
- [version](#version)

## Matter Shell Command Details
Expand Down
206 changes: 206 additions & 0 deletions examples/shell/README_SERVER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Matter Shell - App Server module

The all-clusters-app server may be invoked and managed via the Matter Shell CLI.

## Command List

- [help](#help)
- [clusters](#clusters)
- [endpoints](#endpoints)
- [exchanges](#exchanges)
- [port](#port)
- [sessions](#sessions)
- [start](#start)
- [stop](#stop)
- [udcport](#udcport)

## Command Details

### help

List the Server CLI commands.

```bash
> server help
help Usage: server <subcommand>
start Start the ZCL application server.
stop Stop the ZCL application server.
port Get/Set operational port of server.
udcport Get/Set commissioning port of server.
sessions Manage active sessions on the server.
exchanges Manage active exchanges on the server.
endpoints Display endpoints on the server.
clusters Display clusters on the server.
Done
```

### clusters

Displays all clusters in endpoint hierarchy.

```bash
> server clusters
Endpoint 0:
- Cluster 0x0003
- Cluster 0x0004
- Cluster 0x001D
- Cluster 0x001E
- Cluster 0x001F
- Cluster 0x0028
- Cluster 0x0029
- Cluster 0x002A
- Cluster 0x002E
- Cluster 0x0030
- Cluster 0x0031
- Cluster 0x0032
- Cluster 0x0033
- Cluster 0x0034
- Cluster 0x0035
- Cluster 0x0036
- Cluster 0x0037
- Cluster 0x003C
- Cluster 0x003E
- Cluster 0x003F
- Cluster 0x0040
- Cluster 0x0041
- Cluster 0x0405
Endpoint 1:
- Cluster 0x0003
- Cluster 0x0004
- Cluster 0x0005
- Cluster 0x0006
- Cluster 0x0007
- Cluster 0x0008
- Cluster 0x000F
- Cluster 0x001D
- Cluster 0x001E
- Cluster 0x0025
- Cluster 0x002F
- Cluster 0x0039
- Cluster 0x003B
- Cluster 0x0040
- Cluster 0x0041
- Cluster 0x0045
- Cluster 0x0050
- Cluster 0x0101
- Cluster 0x0102
- Cluster 0x0103
- Cluster 0x0200
- Cluster 0x0201
- Cluster 0x0204
- Cluster 0x0300
- Cluster 0x0400
- Cluster 0x0402
- Cluster 0x0403
- Cluster 0x0404
- Cluster 0x0405
- Cluster 0x0406
- Cluster 0x0500
- Cluster 0x0503
- Cluster 0x0504
- Cluster 0x0505
- Cluster 0x0506
- Cluster 0x0507
- Cluster 0x0508
- Cluster 0x0509
- Cluster 0x050A
- Cluster 0x050B
- Cluster 0x050C
- Cluster 0x050D
- Cluster 0x050E
- Cluster 0x050F
- Cluster 0x0B04
Endpoint 2:
- Cluster 0x0004
- Cluster 0x0006
- Cluster 0x001D
- Cluster 0x0406
Done
```

### endpoints

Displays all endpoints in device hierarchy.

```bash
> server endpoints
Endpoint 0
Endpoint 1
Endpoint 2
Done
```

### port

Display the current operational port for the server node.

```bash
> server port
5540
Done
```

### port \<udp_port\>

Sets the operational port to the given value. NOTE: server must be restarted to
take effect.

- udp_port: new value to set operational port to

```bash
> server port 5541
Done
```

### sessions

Displays active session handles.

```bash
> server sessions
session id=0x0002 peerSessionId=0x0012 peerNodeId=0x000000000001b669 fabricIdx=1
Done
```

### start

Start the App Server on the Node. This also starts the commissioning window as
is done with the all-clusters-app.

```bash
> server start
...
[1639549415.105682][1468836:1468841] CHIP:SVR: Server Listening...
Done
```

### stop

Stops the App Server, closes all related sockets, and frees resources.

```bash
> server stop
Done
```

### udcport

Display the current commissioning port for the server node.

```bash
> server udcport
5550
Done
```

### udcport \<udp_port\>

Sets the commissioning port to the given value. NOTE: server must be restarted
to take effect.

- udp_port: new value to set commissioning port to

```bash
> server udcport 5551
Done
```
4 changes: 4 additions & 0 deletions examples/shell/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ extern "C" void app_main(void)
chip::Platform::MemoryInit();
chip::DeviceLayer::PlatformMgr().InitChipStack();
chip::DeviceLayer::PlatformMgr().StartEventLoopTask();

int ret = Engine::Root().Init();
assert(ret == 0);

cmd_ping_init();
xTaskCreate(&chip_shell_task, "chip_shell", 2048, NULL, 5, NULL);
}
2 changes: 1 addition & 1 deletion examples/shell/mbed/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main()
}

// Initialize the default streamer that was linked.
ret = streamer_init(streamer_get());
ret = Engine::Root().Init();
if (ret)
{
ChipLogError(Shell, "Streamer initialization failed [%d]", ret);
Expand Down
24 changes: 24 additions & 0 deletions examples/shell/shell_common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import("//build_overrides/openthread.gni")

import("${chip_root}/src/platform/device.gni")

declare_args() {
# Enable server command only on linux for now.
chip_shell_cmd_server = current_os == "linux" || current_os == "mac"
}

config("shell_common_config") {
include_dirs = [
".",
Expand All @@ -27,6 +32,7 @@ config("shell_common_config") {
defines = [
"ENABLE_CHIP_SHELL",
"OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE",
"CHIP_SHELL_ENABLE_CMD_SERVER=${chip_shell_cmd_server}",
]
}

Expand Down Expand Up @@ -61,5 +67,23 @@ static_library("shell_common") {
}
}

if (chip_shell_cmd_server) {
sources += [ "cmd_server.cpp" ]

import("${chip_root}/src/app/chip_data_model.gni")

sources += [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
]

include_dirs =
[ "${chip_root}/examples/all-clusters-app/all-clusters-common/include" ]

public_deps +=
[ "${chip_root}/examples/all-clusters-app/all-clusters-common" ]
}

public_configs = [ ":shell_common_config" ]
}
Loading

0 comments on commit 1709204

Please sign in to comment.