Skip to content

Commit

Permalink
samples: update sidewalk cli
Browse files Browse the repository at this point in the history
[KRKNWK-19110]

Signed-off-by: Krzysztof Taborowski <krzysztof.taborowski@nordicsemi.no>
  • Loading branch information
ktaborowski committed Sep 27, 2024
1 parent e0b749f commit 4093842
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
19 changes: 15 additions & 4 deletions samples/sid_end_device/include/cli/app_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"link value is optional, it can take the same values as for sid init command. If link value is not present the one set with sid init will be used to call sid_stop api."

#define CMD_SID_SEND_DESCRIPTION \
"-t <tv> -d <dv> -l <lm> -i <id> -a <ack> <retry> <ttl> -r <data>\n" \
"-t <tv> -d <dv> -l <lm> -i <id> -o <low> -a <ack> <retry> <ttl> -r <data>\n" \
"send data over the SID_LINK_TYPE selected, calls the sid_put_msg()API.\n" \
"Data field must always be placed at the end of command patametrs. If -r parameter is not preset data filed is treated as ascii. Example usage:\n" \
" - sid send TEST\n" \
Expand All @@ -66,6 +66,10 @@
"- i message id that needs to be used to send response. Valid only for messages of type response\n" \
" <id> response id\n" \
"- r data is interpreted hex string e.g. 010203AAFF\n" \
"- o low laency configuration\n" \
"possible <low> values:\n" \
"0 - Default Setting. Send the message with low latency disabled\n" \
"1 - Send the message as a LoRa low latency message\n" \
"- a configure parameters for transport ack:\n" \
" <ack> - enable/disable ACK\n" \
" 1 - enable ACK\n" \
Expand All @@ -78,8 +82,8 @@
"factory reset the board, deleting all registration status. This calls the sid_set_factory_reset() API."

#define CMD_SID_GET_MTU_DESCRIPTION \
"<1,2,3>\n" \
"get the MTU for the selected link type, 1 is SID_LINK_TYPE_1 (BLE), 2 is SID_LINK_TYPE_2 (FSK), 3 is SID_LINK_TYPE_3 (LORA). This calls the sid_get_mtu() API."
"<1,2,3,8>\n" \
"get the MTU for the selected link type, 1 is SID_LINK_TYPE_1 (BLE), 2 is SID_LINK_TYPE_2 (FSK), 3 is SID_LINK_TYPE_3 (LORA), 8 is SID_LINK_TYPE_ANY. This calls the sid_get_mtu() API."

#define CMD_SID_SET_OPTION_DESCRIPTION \
"<option> <val1>...<valN>\n" \
Expand Down Expand Up @@ -121,7 +125,7 @@
"<policy>\n" \
"Set Multi link policy parameters\n" \
"<policy> - The multi link policy that needs to be applied. valid values are only (0,1,2,3,4)\n" \
" 0 - SID_LINK_MULTI_LINK_POLICY_ACTIVE\n" \
" 0 - SID_LINK_MULTI_LINK_POLICY_DEFAULT\n" \
" 1 - SID_LINK_MULTI_LINK_POLICY_POWER_SAVE\n" \
" 2 - SID_LINK_MULTI_LINK_POLICY_PERFORMANCE\n" \
" 3 - SID_LINK_MULTI_LINK_POLICY_LATENCY\n" \
Expand Down Expand Up @@ -149,6 +153,10 @@
"-lp_set 0x83 <rxwc> - for SID_LINK3_PROFILE_D, where <rxwc> is the rx_window count parameter\n" \
"<rxwc> - (uint8) rx window count. 0 represents infinite windows\n"

#define CMD_SID_OPTION_GSI_DESCRIPTION \
"\n" \
"Get Sidewalk ID, ex: SIDEWALK_ID: BFFFFFCAFE\n"

#define CMD_SID_LAST_STATUS_DESCRIPTION \
"\n" \
"get last status of Sidewalk library. Result is printed in the same format as EVENT SID STATUS. This call the sid_get_status() API."
Expand Down Expand Up @@ -219,6 +227,8 @@
#define CMD_SID_SET_OPTION_C_ARG_OPTIONAL 2
#define CMD_SID_SET_OPTION_LP_SET_ARG_REQUIRED 2
#define CMD_SID_SET_OPTION_LP_SET_ARG_OPTIONAL 1
#define CMD_SID_OPTION_GSI_ARG_REQUIRED 1
#define CMD_SID_OPTION_GSI_ARG_OPTIONAL 0
#define CMD_SID_LAST_STATUS_ARG_REQUIRED 1
#define CMD_SID_LAST_STATUS_ARG_OPTIONAL 0
#define CMD_SID_CONN_REQUEST_ARG_REQUIRED 2
Expand Down Expand Up @@ -260,6 +270,7 @@ int cmd_sid_option_m(const struct shell *shell, int32_t argc, const char **argv)
int cmd_sid_option_c(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_option_ml(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_option_gc(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_option_sid_id(const struct shell *shell, int32_t argc, const char **argv);

int cmd_sid_last_status(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_conn_request(const struct shell *shell, int32_t argc, const char **argv);
Expand Down
6 changes: 6 additions & 0 deletions samples/sid_end_device/src/cli/app_dut.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ void dut_event_get_option(sidewalk_ctx_t *sid, void *ctx)
stats.msg_stats.tx_fail, stats.msg_stats.retries,
stats.msg_stats.duplicates, stats.msg_stats.acks_recv, stats.msg_stats.rx);
} break;
case SID_OPTION_GET_SIDEWALK_ID: {
struct sid_id id = { 0 };
sid_error_t e = sid_option(sid->handle, opt, &id, sizeof(id));
LOG_INF("sid_option returned %d (%s); SIDEWALK_ID: %02X%02X%02X%02X%02X", e,
SID_ERROR_T_STR(e), id.id[0], id.id[1], id.id[2], id.id[3], id.id[4]);
} break;
case SID_OPTION_GET_LINK_POLICY_AUTO_CONNECT_PARAMS: {
struct sid_link_auto_connect_params params = { 0 };
memcpy(&params.link_type, p_option->data, sizeof(uint32_t));
Expand Down
40 changes: 40 additions & 0 deletions samples/sid_end_device/src/cli/app_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
CMD_SID_SET_OPTION_ML_ARG_REQUIRED, CMD_SID_SET_OPTION_ML_ARG_OPTIONAL),
SHELL_CMD_ARG(-gc, NULL, CMD_SID_SET_OPTION_GC_DESCRIPTION, cmd_sid_option_gc,
CMD_SID_SET_OPTION_GC_ARG_REQUIRED, CMD_SID_SET_OPTION_GC_ARG_OPTIONAL),
SHELL_CMD_ARG(-gsi, NULL, CMD_SID_OPTION_GSI_DESCRIPTION, cmd_sid_option_sid_id,
CMD_SID_OPTION_GSI_ARG_REQUIRED, CMD_SID_OPTION_GSI_ARG_OPTIONAL),

SHELL_SUBCMD_SET_END);

Expand Down Expand Up @@ -440,6 +442,28 @@ int cmd_sid_send(const struct shell *shell, int32_t argc, const char **argv)
}
continue;
}
if (strcmp("-o", argv[opt]) == 0) {
opt++;
if (opt >= argc) {
shell_error(shell, "-o need a value");
return -EINVAL;
}
switch (argv[opt][0]) {
case '0':
desc.msg_desc_attr.tx_attr.additional_attr =
SID_MSG_DESC_TX_ADDITIONAL_ATTRIBUTES_NONE;
break;
case '1':
desc.msg_desc_attr.tx_attr.additional_attr =
SID_MSG_DESC_TX_ADDITIONAL_ATTRIBUTES_LORA_LOW_LATENCY;
break;
default: {
shell_error(shell, "invalid configuration");
return -EINVAL;
}
}
continue;
}
if (strcmp("-r", argv[opt]) == 0) {
opt++;
if (opt >= argc) {
Expand Down Expand Up @@ -587,6 +611,10 @@ int cmd_sid_get_mtu(const struct shell *shell, int32_t argc, const char **argv)
case '3':
link_mask = SID_LINK_TYPE_3;
break;
case CLI_CMD_OPT_LINK_ANY: {
link_mask = SID_LINK_TYPE_ANY;
break;
}
default:
shell_error(shell, "invalid value");
return -EINVAL;
Expand Down Expand Up @@ -800,6 +828,18 @@ int cmd_sid_option_gml(const struct shell *shell, int32_t argc, const char **arg
return 0;
}

int cmd_sid_option_sid_id(const struct shell *shell, int32_t argc, const char **argv)
{
CHECK_ARGUMENT_COUNT(argc, 1, 0);

int err = cmd_sid_option_get(SID_OPTION_GET_SIDEWALK_ID);
if (err) {
shell_error(shell, "event err %d", err);
}

return 0;
}

int cmd_sid_option_st_get(const struct shell *shell, int32_t argc, const char **argv)
{
CHECK_ARGUMENT_COUNT(argc, 1, 0);
Expand Down

0 comments on commit 4093842

Please sign in to comment.