Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/shell/cmds: fix shell_cmd_netif LoRaWAN integration #18649

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion makefiles/deprecated_modules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Keep this list ALPHABETICALLY SORTED!!!!111elven
DEPRECATED_MODULES += event_thread_lowest
DEPRECATED_MODULES += gnrc_netdev_default
DEPRECATED_MODULES += gnrc_netif_cmd_lora # use shell_cmd_gnrc_netif_lorawan instead
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c31e373 introduced a catch-all (gnrc_netif_cmd_%). I think that catch-all should be used here for deprecation as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c31e373 introduced a catch-all (gnrc_netif_cmd_%). I think that catch-all should be used here for deprecation as well.

Ping?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But after all this PR deprecates gnrc_netif_cmd_lora by renaming it. If there are no other modules matching gnrc_netif_cmd_%, maybe we should instead change pseudomodules.mk to no longer match with wildcards.

There is a check for typos in module names. But that check is not as effective as it could be due to all the wildcards. IMO we should get rid of all wildcards in pseudomodules.mk.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a check for typos in module names. But that check is not as effective as it could be due to all the wildcards. IMO we should get rid of all wildcards in pseudomodules.mk.

You won't get resistance on that from me :-). Then for this PR, should we just replace the gnrc_netif_cmd_% wildcard with gnrc_netif_cmd_lora to get this along? The actual removal of wildcards should be done in a separate PR IMHO.

DEPRECATED_MODULES += gnrc_pktbuf_cmd # use shell_cmd_gnrc_pktbuf instead
DEPRECATED_MODULES += gnrc_udp_cmd # use shell_cmd_grnc_udp instead
DEPRECATED_MODULES += heap_cmd # use shell_cmd_heap instead
Expand All @@ -10,7 +11,7 @@ DEPRECATED_MODULES += md5sum # use shell_cmd_md5sum instead
DEPRECATED_MODULES += nice # use shell_cmd_nice instead
DEPRECATED_MODULES += random_cmd # use shell_cmd_random instead
DEPRECATED_MODULES += sema_deprecated
DEPRECATED_MODULES += shell_commands # use shell_cmds_default instead
DEPRECATED_MODULES += sha1sum # use shell_cmd_sha1sum instead
DEPRECATED_MODULES += sha256sum # use shell_cmd_sha256sum instead
DEPRECATED_MODULES += shell_commands # use shell_cmds_default instead
DEPRECATED_MODULES += ztimer_now64
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,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_lorawan
PSEUDOMODULES += shell_cmd_gnrc_pktbuf
PSEUDOMODULES += shell_cmd_gnrc_rpl
PSEUDOMODULES += shell_cmd_gnrc_sixlowpan_ctx
Expand Down
4 changes: 4 additions & 0 deletions sys/net/gnrc/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ ifneq (,$(filter gnrc_dhcpv6_client_simple_pd,$(USEMODULE)))
USEMODULE += dhcpv6_client_ia_pd
endif

ifneq (,$(filter gnrc_netif_cmd_lora,$(USEMODULE)))
USEMODULE += shell_cmd_gnrc_netif_lorawan
endif

ifneq (,$(filter gnrc_uhcpc,$(USEMODULE)))
DEFAULT_MODULE += auto_init_gnrc_uhcpc
USEMODULE += uhcpc
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 @@ -214,7 +214,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
#if IS_USED(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 @@ -390,7 +390,7 @@ static void _print_netopt(netopt_t opt)
printf("encryption key");
break;

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN)
case NETOPT_BANDWIDTH:
printf("bandwidth");
break;
Expand All @@ -402,7 +402,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 @@ -503,7 +503,7 @@ static const char *_netopt_state_str[] = {
[NETOPT_STATE_STANDBY] = "STANDBY"
};

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(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 @@ -675,7 +675,7 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
printf(" RSSI: %d ", i16);
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(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 @@ -688,7 +688,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 @@ -808,7 +808,7 @@ static void _netif_list(netif_t *iface)
}
line_thresh++;
}
#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(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 @@ -998,7 +998,7 @@ static int _netif_set_u32(netif_t *iface, netopt_t opt, uint32_t context,
return 0;
}

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(MODULE_SHELL_CMD_GNRC_NETIF_LORAWAN)
static int _netif_set_bandwidth(netif_t *iface, char *value)
{
uint8_t bw;
Expand Down Expand Up @@ -1059,7 +1059,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 @@ -1251,7 +1251,7 @@ static int _netif_set_flag(netif_t *iface, netopt_t opt, netopt_enable_t set)
return 0;
}

#ifdef MODULE_GNRC_NETIF_CMD_LORA
#if IS_USED(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 @@ -1503,7 +1503,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
#if IS_USED(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 @@ -1553,7 +1553,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