From ade05f92f4a0e0a34bfa2f500ed6745d9f6a24b0 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie <alexandre.abadie@inria.fr> Date: Mon, 9 Jul 2018 16:39:47 +0200 Subject: [PATCH] tests/pkg_semtech-loramac: add save/erase subcommands --- tests/pkg_semtech-loramac/Makefile | 2 ++ tests/pkg_semtech-loramac/main.c | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/pkg_semtech-loramac/Makefile b/tests/pkg_semtech-loramac/Makefile index 47081377ea..0f8d63794e 100644 --- a/tests/pkg_semtech-loramac/Makefile +++ b/tests/pkg_semtech-loramac/Makefile @@ -18,6 +18,8 @@ USEMODULE += shell USEMODULE += shell_commands USEMODULE += fmt +FEATURES_OPTIONAL += periph_eeprom + CFLAGS += -DREGION_$(LORA_REGION) CFLAGS += -DLORAMAC_ACTIVE_REGION=LORAMAC_REGION_$(LORA_REGION) diff --git a/tests/pkg_semtech-loramac/main.c b/tests/pkg_semtech-loramac/main.c index e0e7ba42e4..56d97d6a76 100644 --- a/tests/pkg_semtech-loramac/main.c +++ b/tests/pkg_semtech-loramac/main.c @@ -35,7 +35,11 @@ static char print_buf[LORAMAC_APPKEY_LEN * 2 + 1]; static void _loramac_usage(void) { - puts("Usage: loramac <get|set|join|tx|link_check>"); + puts("Usage: loramac <get|set|join|tx|link_check" +#ifdef MODULE_PERIPH_EEPROM + "|save|erase" +#endif + ">"); } static void _loramac_join_usage(void) @@ -462,6 +466,24 @@ static int _cmd_loramac(int argc, char **argv) semtech_loramac_request_link_check(&loramac); puts("Link check request scheduled"); } +#ifdef MODULE_PERIPH_EEPROM + else if (strcmp(argv[1], "save") == 0) { + if (argc > 2) { + _loramac_usage(); + return 1; + } + + semtech_loramac_save_config(&loramac); + } + else if (strcmp(argv[1], "erase") == 0) { + if (argc > 2) { + _loramac_usage(); + return 1; + } + + semtech_loramac_erase_config(); + } +#endif else { _loramac_usage(); return 1; -- GitLab