From a6648a2c7fef332ad10bc21d84de0d3bc4299e49 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Wed, 14 Sep 2022 16:57:25 +0200 Subject: [PATCH] sys/shell/commands/sc_opendsme: add gts commands --- makefiles/pseudomodules.inc.mk | 1 + sys/shell/Makefile.dep | 3 ++ sys/shell/cmds/opendsme.c | 72 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 sys/shell/cmds/opendsme.c diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 9364ccce7d..3b74e58969 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -474,6 +474,7 @@ PSEUDOMODULES += shell_cmd_netstats_neighbor PSEUDOMODULES += shell_cmd_nice PSEUDOMODULES += shell_cmd_nimble_netif PSEUDOMODULES += shell_cmd_nimble_statconn +PSEUDOMODULES += shell_cmd_opendsme PSEUDOMODULES += shell_cmd_openwsn PSEUDOMODULES += shell_cmd_pm PSEUDOMODULES += shell_cmd_ps diff --git a/sys/shell/Makefile.dep b/sys/shell/Makefile.dep index eb2360479c..3206f0850e 100644 --- a/sys/shell/Makefile.dep +++ b/sys/shell/Makefile.dep @@ -105,6 +105,9 @@ ifneq (,$(filter shell_cmds_default,$(USEMODULE))) ifneq (,$(filter nimble_statconn,$(USEMODULE))) USEMODULE += shell_cmd_nimble_statconn endif + ifneq (,$(filter opendsme,$(USEPKG))) + USEMODULE += shell_cmd_opendsme + endif ifneq (,$(filter openwsn,$(USEPKG))) USEMODULE += shell_cmd_openwsn endif diff --git a/sys/shell/cmds/opendsme.c b/sys/shell/cmds/opendsme.c new file mode 100644 index 0000000000..4c20b462fd --- /dev/null +++ b/sys/shell/cmds/opendsme.c @@ -0,0 +1,72 @@ +/* + * Copyright 2022 HAW Hamburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup sys_shell_commands + * @{ + * + * @file + * @brief Shell command implementation for openDSME + * + * @author José I. Álamos + * + * @} + */ + +#include +#include +#include + +#include "opendsme/opendsme.h" + +#include "net/gnrc.h" +#include "net/gnrc/pktdump.h" +#include "net/gnrc/netreg.h" + +#include "fmt.h" +#include "shell.h" + +#if IS_ACTIVE(CONFIG_IEEE802154_DSME_STATIC_GTS) +static int _opendsme_gts_cmd(int argc, char **argv) +{ + (void) argc; + ieee802154_dsme_alloc_t alloc; + if (argc < 7) { + printf("Usage: %s \n",argv[0]); + return 1; + } + memset(&alloc, 0, sizeof(alloc)); + kernel_pid_t iface = scn_u32_dec(argv[1],1); + l2util_addr_from_str(argv[2], (uint8_t*) &alloc.addr); + + /* Whether slot is TX or RX */ + alloc.tx = scn_u32_dec(argv[3],1); + + /* Set the superframe ID of the current slot. Valid superframe IDs are + * ({0..n-1}, with `n` the number of superframes per multisuperframe) */ + alloc.superframe_id = scn_u32_dec(argv[4],1); + + /* Set the slot ID. Valid slot IDs are: + * {0..7} if superframe_id == 0, + * {8..14} if (superframe_id != 0 && CONFIG_IEEE802154_DSME_CAP_REDUCTION=1) + * {0..14} otherwise + */ + alloc.slot_id = scn_u32_dec(argv[5],1); + + /* Set the channel offset. Valid values for O-QPSK are {0..15} */ + alloc.channel_id = scn_u32_dec(argv[6], 1); + + gnrc_netapi_set(iface, NETOPT_GTS_ALLOC, 0, &alloc, sizeof(alloc)); + + return 0; +} + +SHELL_COMMAND(gts, "Allocate a static GTS with a neighbour device", _opendsme_gts_cmd); +#else +typedef int dont_be_pedantic; +#endif