From 180be1d6ee6f33c9aaee9a0f36154afb87e9867c Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 14 Apr 2022 08:39:28 +0200 Subject: [PATCH] sys/sc_suit: add seq_no command --- sys/shell/commands/sc_suit.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/shell/commands/sc_suit.c b/sys/shell/commands/sc_suit.c index 0539ba5e77..60ce075b3f 100644 --- a/sys/shell/commands/sc_suit.c +++ b/sys/shell/commands/sc_suit.c @@ -23,15 +23,33 @@ #include #include "suit/transport/coap.h" +#include "suit/storage.h" + +static void _print_usage(char **argv) +{ + printf("Usage: %s fetch \n", argv[0]); + printf(" %s seq_no\n", argv[0]); +} int _suit_handler(int argc, char **argv) { - if (argc != 2) { - printf("Usage: %s \n", argv[0]); + if (argc < 2) { + _print_usage(argv); return 1; } - suit_coap_trigger((uint8_t *)argv[1], strlen(argv[1])); + if (strcmp(argv[1], "fetch") == 0) { + suit_coap_trigger((uint8_t *)argv[2], strlen(argv[2])); + } + else if (strcmp(argv[1], "seq_no") == 0) { + uint32_t seq_no = 0; + suit_storage_get_highest_seq_no(&seq_no); + printf("seq_no: %" PRIu32 "\n", seq_no); + } + else { + _print_usage(argv); + return -1; + } return 0; }