Skip to content

Commit f5c0c51

Browse files
committed
modules: cloud: shell: Update shell commands and documentation
Combine the att cloud shell command into a single command with subcommands for better usability. Update the documentation accordingly to reflect the new command structure. Align command structure among all shell commands offered by the template. Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
1 parent d10ee8f commit f5c0c51

File tree

11 files changed

+62
-34
lines changed

11 files changed

+62
-34
lines changed

app/src/modules/button/button_shell.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static int cmd_button_press(const struct shell *sh, size_t argc, char **argv)
2323

2424
if (argc != 2) {
2525
(void)shell_print(sh, "Invalid number of arguments (%d)", argc);
26-
(void)shell_print(sh, "Usage: att_button_press <button_number>");
26+
(void)shell_print(sh, "Usage: att_button press <button_number>");
2727
return 1;
2828
}
2929

@@ -45,4 +45,15 @@ static int cmd_button_press(const struct shell *sh, size_t argc, char **argv)
4545
return 0;
4646
}
4747

48-
SHELL_CMD_REGISTER(att_button_press, NULL, "Asset Tracker Template Button CMDs", cmd_button_press);
48+
SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmds,
49+
SHELL_CMD(press,
50+
NULL,
51+
"Simulate a button press. Usage: press <button_number>",
52+
cmd_button_press),
53+
SHELL_SUBCMD_SET_END
54+
);
55+
56+
SHELL_CMD_REGISTER(att_button,
57+
&sub_cmds,
58+
"Asset Tracker Template Button module commands",
59+
NULL);

app/src/modules/cloud/cloud.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LOG_MODULE_REGISTER(cloud, CONFIG_APP_CLOUD_LOG_LEVEL);
4747
* The cloud state machine does not support out of order provisioning via nRF Provisioning shell.
4848
*/
4949
BUILD_ASSERT(!IS_ENABLED(CONFIG_NRF_PROVISIONING_SHELL),
50-
"nRF Provisioning Shell not supported, use att_cloud_provision shell command instead");
50+
"nRF Provisioning Shell not supported, use 'att_cloud provision' shell command instead");
5151

5252
BUILD_ASSERT(CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS >
5353
CONFIG_APP_CLOUD_MSG_PROCESSING_TIMEOUT_SECONDS,

app/src/modules/cloud/cloud_shell.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int cmd_publish(const struct shell *sh, size_t argc, char **argv)
3131

3232
if (argc != 3) {
3333
(void)shell_print(sh, "Invalid number of arguments (%d)", argc);
34-
(void)shell_print(sh, "Usage: att_cloud_publish <appid> <data>");
34+
(void)shell_print(sh, "Usage: att_cloud publish <appid> <data>");
3535
return 1;
3636
}
3737

@@ -101,17 +101,26 @@ static int cmd_provisioning(const struct shell *sh, size_t argc, char **argv)
101101
return 0;
102102
}
103103

104-
SHELL_STATIC_SUBCMD_SET_CREATE(prov_sub_cmds,
105-
SHELL_CMD(now,
104+
SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmds,
105+
SHELL_CMD(publish,
106106
NULL,
107-
"Perform provisioning now",
107+
"Publish custom data message to cloud. "
108+
"Usage: publish <appid> <data>",
109+
cmd_publish),
110+
SHELL_CMD(provision,
111+
NULL,
112+
"Perform provisioning. The application will connect to the "
113+
"nRF Cloud provisioning service and check for pending commands",
108114
cmd_provisioning),
115+
SHELL_CMD(poll_shadow_delta,
116+
NULL,
117+
"Poll the device shadow delta to receive pending "
118+
"configuration updates",
119+
cmd_poll_shadow),
109120
SHELL_SUBCMD_SET_END
110121
);
111122

112-
SHELL_CMD_REGISTER(att_cloud_publish, NULL, "Asset Tracker Template Cloud CMDs",
113-
cmd_publish);
114-
SHELL_CMD_REGISTER(att_cloud_provision, &prov_sub_cmds, "Asset Tracker Template Provisioning CMDs",
123+
SHELL_CMD_REGISTER(att_cloud,
124+
&sub_cmds,
125+
"Asset Tracker Template Cloud module commands",
115126
NULL);
116-
SHELL_CMD_REGISTER(att_cloud_poll_shadow_delta, NULL, "Poll the device shadow delta from the cloud",
117-
cmd_poll_shadow);

app/src/modules/network/network_shell.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmds,
6363
SHELL_SUBCMD_SET_END
6464
);
6565

66-
SHELL_CMD_REGISTER(att_network, &sub_cmds, "Asset Tracker Template Network CMDs", NULL);
66+
SHELL_CMD_REGISTER(att_network,
67+
&sub_cmds,
68+
"Asset Tracker Template Network module commands",
69+
NULL);

app/src/modules/power/power_shell.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ static int cmd_power_sample(const struct shell *shell, size_t argc, char **argv)
5959

6060
SHELL_STATIC_SUBCMD_SET_CREATE(
6161
sub_cmds,
62-
SHELL_CMD(sample, NULL,
62+
SHELL_CMD(sample,
63+
NULL,
6364
"Request a battery sample (state of charge, voltage, charging state)",
6465
cmd_power_sample),
6566
SHELL_SUBCMD_SET_END);
6667

67-
SHELL_CMD_REGISTER(att_power, &sub_cmds, "Asset Tracker Template Power CMDs", NULL);
68+
SHELL_CMD_REGISTER(att_power,
69+
&sub_cmds,
70+
"Asset Tracker Template Power module commands",
71+
NULL);

app/src/modules/storage/storage_shell.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(storage_mode_sub_cmds,
155155
SHELL_SUBCMD_SET_END
156156
);
157157

158-
SHELL_STATIC_SUBCMD_SET_CREATE(storage_sub_cmds,
158+
SHELL_STATIC_SUBCMD_SET_CREATE(sub_cmds,
159159
SHELL_CMD(flush, NULL, "Flush stored data", cmd_storage_flush),
160160
SHELL_CMD(batch_request, NULL, "Request data from batch", cmd_storage_batch_request),
161161
SHELL_CMD(clear, NULL, "Clear all stored data", cmd_storage_clear),
@@ -165,4 +165,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(storage_sub_cmds,
165165
SHELL_SUBCMD_SET_END
166166
);
167167

168-
SHELL_CMD_REGISTER(att_storage, &storage_sub_cmds, "Storage module commands", NULL);
168+
SHELL_CMD_REGISTER(att_storage,
169+
&sub_cmds,
170+
"Asset Tracker Template Storage module commands",
171+
NULL);

docs/common/provisioning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ To update device credentials:
107107
1. Select **Cloud Access Key Generation** and click **Create Command**.
108108
1. Trigger on device:
109109

110-
- **Shell**: `att_cloud_provision now`
110+
- **Shell**: `att_cloud provision`
111111
- **Cloud**: Update device shadow with `{"desired": {"command": [1, 1]}}`.
112112

113113
For detailed information on sending commands to devices through REST API, including command structure and available command types, see [Sending commands through REST API](configuration.md#sending-commands-through-rest-api) in the configuration documentation.

docs/common/tooling_troubleshooting.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ uart:~$ help
5353
Available commands:
5454
app : Application version information commands
5555
at : Execute an AT command
56-
att_button_press : Asset Tracker Template Button CMDs
57-
att_cloud_poll_shadow_delta : Poll the device shadow delta from the cloud
58-
att_cloud_provision : Asset Tracker Template Provisioning CMDs
59-
att_cloud_publish : Asset Tracker Template Cloud CMDs
60-
att_network : Asset Tracker Template Network CMDs
61-
att_power : Asset Tracker Template Power CMDs
62-
att_storage : Storage module commands
56+
att_button : Asset Tracker Template Button module commands
57+
att_cloud : Asset Tracker Template Cloud module commands
58+
att_network : Asset Tracker Template Network module commands
59+
att_power : Asset Tracker Template Power module commands
60+
att_storage : Asset Tracker Template Storage module commands
6361
clear : Clear screen.
6462
date : Date commands
6563
device : Device commands
@@ -88,14 +86,14 @@ Available commands:
8886
#### Cloud Publishing
8987
9088
```bash
91-
uart:~$ att_cloud_publish TEMP "24"
89+
uart:~$ att_cloud publish TEMP "24"
9290
Sending on payload channel: {"messageType":"DATA","appId":"TEMP","data":"24","ts":1744359144653} (68 bytes)
9391
```
9492
9593
#### Perform cloud provisioning
9694
9795
```bash
98-
uart:~$ att_cloud_provision now
96+
uart:~$ att_cloud provision
9997
[00:00:42.258,361] <dbg> cloud: state_connected_ready_run: Provisioning request received
10098
[00:00:42.258,453] <dbg> cloud: state_connected_exit: state_connected_exit
10199
...

tests/on_target/tests/test_functional/test_fota.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def run_fota_reschedule(dut_fota, fota_type):
144144
for i in range(3):
145145
try:
146146
time.sleep(30)
147-
dut_fota.uart.write("att_button_press 1\r\n")
147+
dut_fota.uart.write("att_button press 1\r\n")
148148
dut_fota.uart.wait_for_str("nrf_cloud_fota_poll: Starting FOTA download")
149149
break
150150
except AssertionError:
@@ -174,7 +174,7 @@ def _run_fota(bundle_id="", fota_type="app", fotatimeout=APP_FOTA_TIMEOUT, new_v
174174
for i in range(3):
175175
try:
176176
time.sleep(10)
177-
dut_fota.uart.write("att_button_press 1\r\n")
177+
dut_fota.uart.write("att_button press 1\r\n")
178178
dut_fota.uart.wait_for_str("nrf_cloud_fota_poll: Starting FOTA download", timeout=30)
179179
break
180180
except AssertionError:
@@ -236,7 +236,7 @@ def _run_fota(bundle_id="", fota_type="app", fotatimeout=APP_FOTA_TIMEOUT, new_v
236236
for i in range(3):
237237
try:
238238
time.sleep(10)
239-
dut_fota.uart.write("att_button_press 1\r\n")
239+
dut_fota.uart.write("att_button press 1\r\n")
240240
dut_fota.uart.wait_for_str("nrf_cloud_fota_poll: Starting FOTA download", timeout=30)
241241
break
242242
except AssertionError:

tests/on_target/tests/test_functional/test_shell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def test_shell(dut_cloud, hex_file):
4545

4646
# Button press
4747
dut_cloud.uart.flush()
48-
dut_cloud.uart.write("att_button_press 1\r\n")
48+
dut_cloud.uart.write("att_button press 1\r\n")
4949
dut_cloud.uart.wait_for_str(patterns_button_press, timeout=20)
5050

5151
# Cloud publish
5252
dut_cloud.uart.flush()
53-
dut_cloud.uart.write("att_cloud_publish donald duck\r\n")
53+
dut_cloud.uart.write("att_cloud publish donald duck\r\n")
5454
dut_cloud.uart.wait_for_str(patterns_cloud_publish, timeout=20)
5555

5656
messages = dut_cloud.cloud.get_messages(dut_cloud.device_id, appname="donald", max_records=20, max_age_hrs=0.25)

0 commit comments

Comments
 (0)