Skip to content

Commit

Permalink
dut: add DFU service to dut sample
Browse files Browse the repository at this point in the history
add command to dut shell to enter into DFU

Signed-off-by: Robert Gałat <[email protected]>
  • Loading branch information
RobertGalatNordic committed Sep 4, 2024
1 parent 5fcb94a commit 17d09db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions samples/sid_end_device/include/cli/app_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <zephyr/shell/shell.h>
#include <sid_api.h>

#define CMD_NORDIC_DFU_DESCRIPTION \
"Start BLE SMP service for DFU\n" \
"Make sure that sidewalk is deinitialized before use, or the DFU may fail during transfer!"

#define CMD_SID_INIT_DESCRIPTION \
"<1,2,3,4,5,6,7,8>\n" \
"initialize the sidewalk stack, 1 is SID_LINK_TYPE_1 (BLE)\n" \
Expand Down Expand Up @@ -182,6 +186,9 @@

#define CMD_SID_SDK_CONFIG_DESCRIPTION "Print sid sdk config"

#define CMD_NORDIC_DFU_ARG_REQUIRED 1
#define CMD_NORDIC_DFU_ARG_OPTIONAL 0

#define CMD_SID_INIT_ARG_REQUIRED 2
#define CMD_SID_INIT_ARG_OPTIONAL 0
#define CMD_SID_DEINIT_ARG_REQUIRED 1
Expand Down Expand Up @@ -229,6 +236,8 @@
#define CMD_SID_SDK_CONFIG_DESCRIPTION_ARG_REQUIRED 1
#define CMD_SID_SDK_CONFIG_DESCRIPTION_ARG_OPTIONAL 0

int cmd_nordic_dfu(const struct shell *shell, int32_t argc, const char **argv);

int cmd_sid_init(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_deinit(const struct shell *shell, int32_t argc, const char **argv);
int cmd_sid_start(const struct shell *shell, int32_t argc, const char **argv);
Expand Down
21 changes: 21 additions & 0 deletions samples/sid_end_device/src/cli/app_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <sid_sdk_version.h>
#include <sidewalk_version.h>
#include <sidewalk.h>
#if defined(CONFIG_SIDEWALK_DFU_SERVICE_BLE)
#include <sidewalk_dfu/nordic_dfu.h>
#endif

#define CLI_CMD_OPT_LINK_BLE 1
#define CLI_CMD_OPT_LINK_FSK 2
Expand Down Expand Up @@ -77,6 +80,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(

SHELL_STATIC_SUBCMD_SET_CREATE(
sub_services,
SHELL_CMD_ARG(nordic_dfu, NULL, CMD_NORDIC_DFU_DESCRIPTION, cmd_nordic_dfu,
CMD_NORDIC_DFU_ARG_REQUIRED, CMD_NORDIC_DFU_ARG_OPTIONAL),
SHELL_CMD_ARG(init, NULL, CMD_SID_INIT_DESCRIPTION, cmd_sid_init, CMD_SID_INIT_ARG_REQUIRED,
CMD_SID_INIT_ARG_OPTIONAL),
SHELL_CMD_ARG(deinit, NULL, CMD_SID_DEINIT_DESCRIPTION, cmd_sid_deinit,
Expand Down Expand Up @@ -282,7 +287,23 @@ static int cmd_sid_simple_param(event_handler_t event, uint32_t *data)
}
return 0;
}
static void app_event_enter_dfu_mode(sidewalk_ctx_t *sid, void *ctx)
{
int err = -ENOTSUP;
shell_info((const struct shell *)ctx, "Entering into DFU mode");
#if defined(CONFIG_SIDEWALK_DFU_SERVICE_BLE)
err = nordic_dfu_ble_start();
#endif
if (err) {
shell_error((const struct shell *)ctx, "dfu start err %d", err);
}
}
// shell handlers
int cmd_nordic_dfu(const struct shell *shell, int32_t argc, const char **argv)
{
sidewalk_event_send(app_event_enter_dfu_mode, (void *)shell, NULL);
return 0;
}

int cmd_sid_init(const struct shell *shell, int32_t argc, const char **argv)
{
Expand Down

0 comments on commit 17d09db

Please sign in to comment.