Skip to content

Commit

Permalink
sys/shell/cmds: fix shell_cmd_netif LoRaWAN integration
Browse files Browse the repository at this point in the history
Model the LoRaWAN integration to GNRC's netif command (ifconfig) as
submodule of it, namely `shell_cmd_gnrc_netif_lorawan`.

This should fix a regression introduced by
RIOT-OS#18355
  • Loading branch information
Marian Buschsieweke committed Sep 26, 2022
1 parent 6988db6 commit 39a1745
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ PSEUDOMODULES += shell_cmd_gnrc_ipv6_frag_stats
PSEUDOMODULES += shell_cmd_gnrc_ipv6_nib
PSEUDOMODULES += shell_cmd_gnrc_ipv6_whitelist
PSEUDOMODULES += shell_cmd_gnrc_netif
PSEUDOMODULES += shell_cmd_gnrc_netif_lora
PSEUDOMODULES += shell_cmd_gnrc_pktbuf
PSEUDOMODULES += shell_cmd_gnrc_rpl
PSEUDOMODULES += shell_cmd_gnrc_sixlowpan_ctx
Expand Down
7 changes: 7 additions & 0 deletions sys/shell/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ ifneq (,$(filter shell_cmds_default,$(USEMODULE)))
ifneq (,$(filter gnrc_netif,$(USEMODULE)))
USEMODULE += shell_cmd_gnrc_netif
endif
ifneq (,$(filter gnrc_netif_lorawan,$(USEMODULE)))
USEMODULE += shell_cmd_gnrc_netif_lorawan
endif
ifneq (,$(filter gnrc_pktbuf_cmd,$(USEMODULE)))
USEMODULE += shell_cmd_gnrc_pktbuf
endif
Expand Down Expand Up @@ -185,6 +188,10 @@ endif
ifneq (,$(filter shell_cmd_gnrc_netif,$(USEMODULE)))
USEMODULE += gnrc_netif
endif
ifneq (,$(filter shell_cmd_gnrc_netif_lorawan,$(USEMODULE)))
USEMODULE += gnrc_netif_lorawan
USEMODULE += shell_cmd_gnrc_netif
endif
ifneq (,$(filter shell_cmd_gnrc_pktbuf,$(USEMODULE)))
USEMODULE += gnrc_pktbuf
endif
Expand Down
8 changes: 8 additions & 0 deletions sys/shell/cmds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ config MODULE_SHELL_CMD_GNRC_NETIF
depends on MODULE_SHELL_CMDS
depends on MODULE_GNRC_NETIF

config MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
bool "LoRa integration to the GNRC network interface command (ifconfig)"
default y if MODULE_SHELL_CMD_GNRC_NETIF && MODULE_GNRC_NETIF_LORAWAN
depends on MODULE_GNRC_NETIF
depends on MODULE_GNRC_NETIF_LORAWAN
depends on MODULE_SHELL_CMDS
depends on MODULE_SHELL_CMD_GNRC_NETIF

config MODULE_SHELL_CMD_GNRC_PKTBUF
bool "Command to print stats of the GNRC packet buffer"
default y if MODULE_SHELL_CMDS_DEFAULT
Expand Down
24 changes: 12 additions & 12 deletions sys/shell/cmds/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ static void _set_usage(char *cmd_name)
" * \"pan\" - alias for \"nid\"\n"
" * \"pan_id\" - alias for \"nid\"\n"
" * \"phy_busy\" - set busy mode on-off\n"
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
" * \"bw\" - alias for channel bandwidth\n"
" * \"sf\" - alias for spreading factor\n"
" * \"cr\" - alias for coding rate\n"
Expand Down Expand Up @@ -360,7 +360,7 @@ static void _print_netopt(netopt_t opt)
printf("encryption key");
break;

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
case NETOPT_BANDWIDTH:
printf("bandwidth");
break;
Expand All @@ -372,7 +372,7 @@ static void _print_netopt(netopt_t opt)
case NETOPT_CODING_RATE:
printf("coding rate");
break;
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#endif /* MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN */
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE

case NETOPT_IEEE802154_PHY:
Expand Down Expand Up @@ -473,7 +473,7 @@ static const char *_netopt_state_str[] = {
[NETOPT_STATE_STANDBY] = "STANDBY"
};

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
static const char *_netopt_bandwidth_str[] = {
[LORA_BW_125_KHZ] = "125",
[LORA_BW_250_KHZ] = "250",
Expand Down Expand Up @@ -645,7 +645,7 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" RSSI: %d ", i16);
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
res = netif_get_opt(iface, NETOPT_BANDWIDTH, 0, &u8, sizeof(u8));
if (res >= 0) {
printf(" BW: %skHz ", _netopt_bandwidth_str[u8]);
Expand All @@ -658,7 +658,7 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" CR: %s ", _netopt_coding_rate_str[u8]);
}
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#endif /* MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN */
#ifdef MODULE_NETDEV_IEEE802154
res = netif_get_opt(iface, NETOPT_IEEE802154_PHY, 0, &u8, sizeof(u8));
if (res >= 0) {
Expand Down Expand Up @@ -777,7 +777,7 @@ static void _netif_list(netif_t *iface)
}
line_thresh++;
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
res = netif_get_opt(iface, NETOPT_DEMOD_MARGIN, 0, &u8, sizeof(u8));
if (res >= 0) {
printf(" Demod margin.: %u ", (unsigned) u8);
Expand Down Expand Up @@ -967,7 +967,7 @@ static int _netif_set_u32(netif_t *iface, netopt_t opt, uint32_t context,
return 0;
}

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
static int _netif_set_bandwidth(netif_t *iface, char *value)
{
uint8_t bw;
Expand Down Expand Up @@ -1028,7 +1028,7 @@ static int _netif_set_coding_rate(netif_t *iface, char *value)

return 0;
}
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#endif /* MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN */

#ifdef MODULE_NETDEV_IEEE802154_MR_FSK
static int _netif_set_fsk_fec(netif_t *iface, char *value)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ static int _netif_set_flag(netif_t *iface, netopt_t opt, netopt_enable_t set)
return 0;
}

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
static int _netif_set_lw_key(netif_t *iface, netopt_t opt, char *key_str)
{
/* This is the longest key */
Expand Down Expand Up @@ -1462,7 +1462,7 @@ static int _netif_set(char *cmd_name, netif_t *iface, char *key, char *value)
else if ((strcmp("frequency", key) == 0) || (strcmp("freq", key) == 0)) {
return _netif_set_u32(iface, NETOPT_CHANNEL_FREQUENCY, 0, value);
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#ifdef MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN
else if ((strcmp("bandwidth", key) == 0) || (strcmp("bw", key) == 0)) {
return _netif_set_bandwidth(iface, value);
}
Expand Down Expand Up @@ -1493,7 +1493,7 @@ static int _netif_set(char *cmd_name, netif_t *iface, char *key, char *value)
else if (strcmp("rx2_dr", key) == 0) {
return _netif_set_u8(iface, NETOPT_LORAWAN_RX2_DR, 0, value);
}
#endif /* MODULE_GNRC_NETIF_CMD_LORA */
#endif /* MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN */
#ifdef MODULE_NETDEV_IEEE802154_MULTIMODE
else if ((strcmp("phy_mode", key) == 0) || (strcmp("phy", key) == 0)) {
return _netif_set_ieee802154_phy_mode(iface, value);
Expand Down

0 comments on commit 39a1745

Please sign in to comment.