From 7b1fd43491e89b0ab1f7a7e23091e5d73a1db064 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 16 Sep 2023 15:41:39 +1000 Subject: [PATCH 01/15] [nrf fromtree] net: wifi_mgmt: change type of `wifi_scan_params->chan` All WiFi channel numbers fit within a 8 bit number, as the maximum allocated channel is 233. This halves the memory requirement. Signed-off-by: Jordan Yates (cherry picked from commit dd090f06b7ed45bdc88335082a10bbe0db2ce439) --- include/zephyr/net/wifi_mgmt.h | 2 +- include/zephyr/net/wifi_utils.h | 2 +- subsys/net/l2/wifi/wifi_utils.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 1be98b927cb..67a603aea95 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -252,7 +252,7 @@ struct wifi_scan_params { * not conforming to regulatory restrictions etc. The invoker of the API should * ensure that the channels specified follow regulatory rules. */ - uint16_t chan[WIFI_FREQ_BAND_MAX + 1][WIFI_CHANNEL_MAX]; + uint8_t chan[WIFI_FREQ_BAND_MAX + 1][WIFI_CHANNEL_MAX]; }; /** Wi-Fi scan result, each result is provided to the net_mgmt_event_callback diff --git a/include/zephyr/net/wifi_utils.h b/include/zephyr/net/wifi_utils.h index 86b39ff4660..b005d075847 100644 --- a/include/zephyr/net/wifi_utils.h +++ b/include/zephyr/net/wifi_utils.h @@ -100,7 +100,7 @@ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, * @retval -errno value in case of failure. */ int wifi_utils_parse_scan_chan(char *scan_chan_str, - uint16_t chan[][WIFI_CHANNEL_MAX]); + uint8_t chan[][WIFI_CHANNEL_MAX]); /** * @} diff --git a/subsys/net/l2/wifi/wifi_utils.c b/subsys/net/l2/wifi/wifi_utils.c index ea0e42def47..a77e225bfbf 100644 --- a/subsys/net/l2/wifi/wifi_utils.c +++ b/subsys/net/l2/wifi/wifi_utils.c @@ -103,13 +103,13 @@ static bool wifi_utils_validate_chan(uint8_t band, } -static int wifi_utils_get_all_chans_in_range(uint16_t chan_start, - uint16_t chan_end, - uint16_t chan[][WIFI_CHANNEL_MAX], +static int wifi_utils_get_all_chans_in_range(uint8_t chan_start, + uint8_t chan_end, + uint8_t chan[][WIFI_CHANNEL_MAX], uint8_t band_idx, uint8_t *chan_idx) { - uint16_t i; + uint8_t i; bool start = false; bool end = false; uint8_t idx; @@ -310,7 +310,7 @@ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, int wifi_utils_parse_scan_chan(char *scan_chan_str, - uint16_t chan[][WIFI_CHANNEL_MAX]) + uint8_t chan[][WIFI_CHANNEL_MAX]) { char band_str[WIFI_UTILS_MAX_BAND_STR_LEN] = {0}; char chan_str[WIFI_UTILS_MAX_CHAN_STR_LEN] = {0}; @@ -318,8 +318,8 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str, uint16_t band_str_start_idx = 0; uint16_t chan_str_start_idx = 0; uint8_t chan_idx = 0; - uint16_t chan_start = 0; - uint16_t chan_val = 0; + uint8_t chan_start = 0; + uint8_t chan_val = 0; uint16_t i = 0; bool valid_band = false; bool valid_chan = false; From ffcdd8c869cae37673d00eea43fd883e437f6514 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sun, 17 Sep 2023 21:16:00 +1000 Subject: [PATCH 02/15] [nrf fromtree] net: l2: wifi_mgmt: remove scan kconfig defaults Remove the wifi_mgmt interface overriding default values with values from kconfig. The defaults were only applied when a `params` struct was provided by the application. This is the case when the application is explicitly setting the options it wants, why is the mgmt API changing these. When `params` is NULL and thus modem defaults are requested, these defaults aren't applied. This is the opposite behaviour from what seems reasonable. In addition, these options are: * Undocumented * Using non-trivial string parsing functions (strtok) * Adding complexity to the API implementation by forcing support for ROM versions of command line arguments. Signed-off-by: Jordan Yates (cherry picked from commit 5452665beb98acba74dbf8ecf07e1deb97b2a7e0) --- subsys/net/l2/wifi/Kconfig | 67 ---------------------------------- subsys/net/l2/wifi/wifi_mgmt.c | 55 ---------------------------- 2 files changed, 122 deletions(-) diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index 6623456d84b..ccf5ce31ca6 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -39,40 +39,6 @@ config WIFI_MGMT_TWT_CHECK_IP even when it is awake intervals. Rejecting TWT setup till Wi-Fi interface has a valid IP address might be desirable in most scenarios. -config WIFI_MGMT_FORCED_PASSIVE_SCAN - bool "Force Passive scan" - help - Force passive scan (typically used to reduce power consumption), - the scan type is always sent as passive. - This doesn't guarantee that passive scan will be used, it depends - on the underlying chip implementation to support and honour scan type. - -config WIFI_MGMT_SCAN_BANDS - string "Frequency bands to scan" - default "" - help - Specifies the frequency bands to scan, as follows: - 2 - 2.4 GHz - 5 - 5 GHz - 6 - 6 GHz - "" - All bands allowed by the regulatory domain. - Multiple bands can be specified as comma separated band values. - Only regulatory domain permitted values are allowed. - -config WIFI_MGMT_SCAN_DWELL_TIME_ACTIVE - int "Active scan dwell time" - default 50 - range 5 1000 - help - Active scan dwell time (in ms) per channel. - -config WIFI_MGMT_SCAN_DWELL_TIME_PASSIVE - int "Passive scan dwell time" - default 130 - range 10 1000 - help - Passive scan dwell time (in ms) per channel. - config WIFI_MGMT_SCAN_SSID_FILT_MAX int "Maximum number of SSIDs that can be specified for SSID filtering" default 1 @@ -81,39 +47,6 @@ config WIFI_MGMT_SCAN_SSID_FILT_MAX Maximum number of SSIDs that can be specified for SSID filtering. This can be set based on the underlying chipsets limitations. -config WIFI_MGMT_SCAN_SSID_FILT - string "Scan for specific SSIDs" - default "" - help - String of comma separated SSID values to scan for. The number of SSID’s - that can be specified depends on WIFI_MGMT_SCAN_MAX_SSIDS. - Use "" to disable SSID filtering. - -config WIFI_MGMT_SCAN_MAX_BSS_CNT - int "Maximum number of scan results to return." - default 0 - range 0 65535 - help - Maximum number of scan results to return. 0 represents unlimited number of BSSes. - -config WIFI_MGMT_SCAN_CHAN - string "Scan on specific channels" - default "" - help - Formatted string which specifies channels to be scanned. The channel string has to be formatted - using the colon (:), comma(,), hyphen (-) and space ( ) delimiters as follows: - - A colon identifies the value preceding it as a band. A band value - (2: 2.4 GHz, 5: 5 GHz 6: 6 GHz) has to precede the channels in that band (e.g. 2: etc) - - Hyphens are used to identify channel ranges (e.g. 2-7, 32-48 etc) - - Commas are used to separate channel values within a band. Channels can be specified - as individual values (2,6,48 etc) or channel ranges using hyphens (1-14, 32-48 etc) - - Spaces are used to specify multiple band-channel sets (e.g. 2:1,2 5:36,40 etc) - - No spaces should be used anywhere else, i.e. before/after commas, - before/after hyphens. - An example channel specification specifying channels in the 2.4 GHz and 5 GHz bands is - as below: - 2:1,5,7,9-11_5:36-48,100,163-167 - config WIFI_NM bool "Wi-Fi Network manager support" help diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 0751f5d2b8c..58e14ff02ff 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -13,7 +13,6 @@ LOG_MODULE_REGISTER(net_wifi_mgmt, CONFIG_NET_L2_WIFI_MGMT_LOG_LEVEL); #include #include #include -#include #ifdef CONFIG_WIFI_NM #include #endif /* CONFIG_WIFI_NM */ @@ -323,65 +322,11 @@ static int wifi_scan(uint32_t mgmt_request, struct net_if *iface, const struct device *dev = net_if_get_device(iface); struct wifi_scan_params *params = data; const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface); - bool chan_specified = false; - uint8_t i = 0; if (wifi_mgmt_api == NULL || wifi_mgmt_api->scan == NULL) { return -ENOTSUP; } - if (data && (len == sizeof(*params))) { -#ifdef CONFIG_WIFI_MGMT_FORCED_PASSIVE_SCAN - params->scan_type = WIFI_SCAN_TYPE_PASSIVE; -#endif /* CONFIG_WIFI_MGMT_FORCED_PASSIVE_SCAN */ - - if (!params->bands) { - if (wifi_utils_parse_scan_bands(CONFIG_WIFI_MGMT_SCAN_BANDS, - ¶ms->bands)) { - NET_ERR("Incorrect value(s) in CONFIG_WIFI_MGMT_SCAN_BANDS: %s", - CONFIG_WIFI_MGMT_SCAN_BANDS); - return -EINVAL; - } - } - - if (!params->dwell_time_active) { - params->dwell_time_active = CONFIG_WIFI_MGMT_SCAN_DWELL_TIME_ACTIVE; - } - - if (!params->dwell_time_passive) { - params->dwell_time_passive = CONFIG_WIFI_MGMT_SCAN_DWELL_TIME_PASSIVE; - } - - if (!strlen(params->ssids[0])) { - if (wifi_utils_parse_scan_ssids(CONFIG_WIFI_MGMT_SCAN_SSID_FILT, - params->ssids)) { - NET_ERR("Incorrect value(s) in CONFIG_WIFI_MGMT_SCAN_SSID_FILT: %s", - CONFIG_WIFI_MGMT_SCAN_SSID_FILT); - return -EINVAL; - } - } - - if (!params->max_bss_cnt) { - params->max_bss_cnt = CONFIG_WIFI_MGMT_SCAN_MAX_BSS_CNT; - } - - for (i = 0; i <= WIFI_FREQ_BAND_MAX; i++) { - if (params->chan[i][0]) { - chan_specified = true; - break; - } - } - - if ((!chan_specified) && strlen(CONFIG_WIFI_MGMT_SCAN_CHAN)) { - if (wifi_utils_parse_scan_chan(CONFIG_WIFI_MGMT_SCAN_CHAN, - params->chan)) { - NET_ERR("Incorrect value(s) in CONFIG_WIFI_MGMT_SCAN_CHAN: %s", - CONFIG_WIFI_MGMT_SCAN_CHAN); - return -EINVAL; - } - } - } - return wifi_mgmt_api->scan(dev, params, scan_result_cb); } From baab0454a0b4d4152c96e09a64e7de31b364bacd Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 16 Sep 2023 15:47:17 +1000 Subject: [PATCH 03/15] [nrf fromtree] net: wifi_mgmt: make number of scan channels configurable Make the maximum number of channels that can be manually scanned configurable by the application. The previous value of 233 was vastly overallocating memory as the largest band only contains 60 allocated channels. Signed-off-by: Jordan Yates (cherry picked from commit 6a428f19b66b9603205b29b300557c14f77a0bc0) --- include/zephyr/net/wifi_mgmt.h | 8 +++++++- subsys/net/l2/wifi/Kconfig | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 67a603aea95..81634a7fc62 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -41,6 +41,12 @@ extern "C" { #define WIFI_MGMT_SCAN_SSID_FILT_MAX 0 #endif /* CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX */ +#ifdef CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL +#define WIFI_MGMT_SCAN_CHAN_MAX_MANUAL CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL +#else +#define WIFI_MGMT_SCAN_CHAN_MAX_MANUAL 1 +#endif /* CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL */ + #define WIFI_MGMT_BAND_STR_SIZE_MAX 8 /** Wi-Fi management commands */ @@ -252,7 +258,7 @@ struct wifi_scan_params { * not conforming to regulatory restrictions etc. The invoker of the API should * ensure that the channels specified follow regulatory rules. */ - uint8_t chan[WIFI_FREQ_BAND_MAX + 1][WIFI_CHANNEL_MAX]; + uint8_t chan[WIFI_FREQ_BAND_MAX + 1][WIFI_MGMT_SCAN_CHAN_MAX_MANUAL]; }; /** Wi-Fi scan result, each result is provided to the net_mgmt_event_callback diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index ccf5ce31ca6..5644852c2a0 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -47,6 +47,14 @@ config WIFI_MGMT_SCAN_SSID_FILT_MAX Maximum number of SSIDs that can be specified for SSID filtering. This can be set based on the underlying chipsets limitations. +config WIFI_MGMT_SCAN_CHAN_MAX_MANUAL + int "Maximum number of channels that can be manually specified per-band" + range 1 70 + default 3 + help + There are currently 60 channels allocated in the largest band (6GHz). + The default of 3 allows the 3 most common channels (2.4GHz: 1, 6, 11) to be specified. + config WIFI_NM bool "Wi-Fi Network manager support" help From 130532ed7162229ed96308df7838619f924ea249 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 16 Sep 2023 15:54:28 +1000 Subject: [PATCH 04/15] [nrf fromtree] net: wifi_mgmt: linearise `scan_params->chan` arrays Turn the nested arrays of `scan_params->chan` into a single array. This adds the requirement to specify the band for each channel, but eliminates the large amount of dead memory for unused bands. Overall, this saves 50% of the RAM space for this variable. Signed-off-by: Jordan Yates (cherry picked from commit b54951b86e440e92dcdd41598d38f67987ce3cf2) --- include/zephyr/net/wifi_mgmt.h | 18 ++++++++++++++---- include/zephyr/net/wifi_utils.h | 4 +++- subsys/net/l2/wifi/Kconfig | 6 +++--- subsys/net/l2/wifi/wifi_shell.c | 4 +++- subsys/net/l2/wifi/wifi_utils.c | 32 ++++++++++++++++++++++++-------- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 81634a7fc62..ab37bd4d878 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -209,6 +209,16 @@ enum net_event_wifi_cmd { #define NET_EVENT_WIFI_DISCONNECT_COMPLETE \ (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE) +/** + * @brief Wi-Fi structure to uniquely identify a band-channel pair + */ +struct wifi_band_channel { + /** Frequency band */ + uint8_t band; + /** Channel */ + uint8_t channel; +}; + /** * @brief Wi-Fi scan parameters structure. * Used to specify parameters which can control how the Wi-Fi scan @@ -248,9 +258,9 @@ struct wifi_scan_params { * band. * E.g. to scan channel 6 and 11 on the 2.4 GHz band, channel 36 on the 5 GHz band: * @code{.c} - * chan[WIFI_FREQ_BAND_2_4_GHZ][0] = 6; - * chan[WIFI_FREQ_BAND_2_4_GHZ][1] = 11; - * chan[WIFI_FREQ_BAND_5_GHZ][0] = 36; + * chan[0] = {WIFI_FREQ_BAND_2_4_GHZ, 6}; + * chan[1] = {WIFI_FREQ_BAND_2_4_GHZ, 11}; + * chan[2] = {WIFI_FREQ_BAND_5_GHZ, 36}; * @endcode * * This list specifies the channels to be __considered for scan__. The underlying @@ -258,7 +268,7 @@ struct wifi_scan_params { * not conforming to regulatory restrictions etc. The invoker of the API should * ensure that the channels specified follow regulatory rules. */ - uint8_t chan[WIFI_FREQ_BAND_MAX + 1][WIFI_MGMT_SCAN_CHAN_MAX_MANUAL]; + struct wifi_band_channel band_chan[WIFI_MGMT_SCAN_CHAN_MAX_MANUAL]; }; /** Wi-Fi scan result, each result is provided to the net_mgmt_event_callback diff --git a/include/zephyr/net/wifi_utils.h b/include/zephyr/net/wifi_utils.h index b005d075847..4284138b6f3 100644 --- a/include/zephyr/net/wifi_utils.h +++ b/include/zephyr/net/wifi_utils.h @@ -95,12 +95,14 @@ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, * * @param scan_chan_str List of channels expressed in the format described above. * @param chan Pointer to an array where the parsed channels are to be stored. + * @param max_channels Maximum number of channels to store * * @retval 0 on success. * @retval -errno value in case of failure. */ int wifi_utils_parse_scan_chan(char *scan_chan_str, - uint8_t chan[][WIFI_CHANNEL_MAX]); + struct wifi_band_channel *chan, + uint8_t max_channels); /** * @} diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index 5644852c2a0..8fbd6aff4d6 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -48,11 +48,11 @@ config WIFI_MGMT_SCAN_SSID_FILT_MAX This can be set based on the underlying chipsets limitations. config WIFI_MGMT_SCAN_CHAN_MAX_MANUAL - int "Maximum number of channels that can be manually specified per-band" - range 1 70 + int "Maximum number of channels that can be manually specified" + range 1 110 default 3 help - There are currently 60 channels allocated in the largest band (6GHz). + There are approximately 100 channels allocated across the three supported bands. The default of 3 allows the 3 most common channels (2.4GHz: 1, 6, 11) to be specified. config WIFI_NM diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 6893e20353e..65e99204aa7 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -557,7 +557,9 @@ static int wifi_scan_args_to_params(const struct shell *sh, opt_num++; break; case 'c': - if (wifi_utils_parse_scan_chan(optarg, params->chan)) { + if (wifi_utils_parse_scan_chan(optarg, + params->band_chan, + ARRAY_SIZE(params->band_chan))) { shell_fprintf(sh, SHELL_ERROR, "Invalid band or channel value(s)\n"); diff --git a/subsys/net/l2/wifi/wifi_utils.c b/subsys/net/l2/wifi/wifi_utils.c index a77e225bfbf..4c50b817d26 100644 --- a/subsys/net/l2/wifi/wifi_utils.c +++ b/subsys/net/l2/wifi/wifi_utils.c @@ -105,7 +105,7 @@ static bool wifi_utils_validate_chan(uint8_t band, static int wifi_utils_get_all_chans_in_range(uint8_t chan_start, uint8_t chan_end, - uint8_t chan[][WIFI_CHANNEL_MAX], + struct wifi_band_channel *band_chan, uint8_t band_idx, uint8_t *chan_idx) { @@ -136,7 +136,9 @@ static int wifi_utils_get_all_chans_in_range(uint8_t chan_start, idx = *chan_idx; for (i = chan_start; i <= chan_end; i++) { - chan[band_idx][idx++] = i; + band_chan[idx].band = band_idx; + band_chan[idx].channel = i; + idx++; } *chan_idx = idx; @@ -155,7 +157,9 @@ static int wifi_utils_get_all_chans_in_range(uint8_t chan_start, } if (start) { - chan[band_idx][idx++] = valid_5g_chans_20mhz[i]; + band_chan[idx].band = band_idx; + band_chan[idx].channel = valid_5g_chans_20mhz[i]; + idx++; } if (end) { @@ -171,7 +175,9 @@ static int wifi_utils_get_all_chans_in_range(uint8_t chan_start, i = chan_start; while (i <= chan_end) { - chan[band_idx][idx++] = i; + band_chan[idx].band = band_idx; + band_chan[idx].channel = i; + idx++; if (i == 1) { i++; @@ -310,7 +316,8 @@ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, int wifi_utils_parse_scan_chan(char *scan_chan_str, - uint8_t chan[][WIFI_CHANNEL_MAX]) + struct wifi_band_channel *band_chan, + uint8_t max_channels) { char band_str[WIFI_UTILS_MAX_BAND_STR_LEN] = {0}; char chan_str[WIFI_UTILS_MAX_CHAN_STR_LEN] = {0}; @@ -349,7 +356,6 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str, } i++; - chan_idx = 0; chan_str_start_idx = i; valid_band = true; @@ -383,9 +389,13 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str, memset(chan_str, 0, sizeof(chan_str)); if (chan_start) { + if ((chan_idx + (chan_val - chan_start)) >= max_channels) { + NET_ERR("Too many channels specified (%d)", max_channels); + return -EINVAL; + } if (wifi_utils_get_all_chans_in_range(chan_start, chan_val, - chan, + band_chan, band, &chan_idx)) { NET_ERR("Channel range invalid"); @@ -399,8 +409,14 @@ int wifi_utils_parse_scan_chan(char *scan_chan_str, NET_ERR("Invalid channel %d", chan_val); return -EINVAL; } + if (chan_idx == max_channels) { + NET_ERR("Too many channels specified (%d)", max_channels); + return -EINVAL; + } - chan[band][chan_idx++] = chan_val; + band_chan[chan_idx].band = band; + band_chan[chan_idx].channel = chan_val; + chan_idx++; } valid_chan = true; From 35341d4ca1250df0816fe5e77ac055e8af4b5700 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 23 Sep 2023 17:47:30 +1000 Subject: [PATCH 05/15] [nrf fromtree] net: wifi: shell: update SSID argument format Instead of providing a comma seperated list of SSIDs, provide the SSIDs individually. This substantially simplifies the implementation. Signed-off-by: Jordan Yates (cherry picked from commit 3b7237e6cd9592abba074822690c49bb774634e8) --- include/zephyr/net/wifi_utils.h | 6 +++-- subsys/net/l2/wifi/wifi_shell.c | 8 ++++--- subsys/net/l2/wifi/wifi_utils.c | 41 ++++++++------------------------- 3 files changed, 19 insertions(+), 36 deletions(-) diff --git a/include/zephyr/net/wifi_utils.h b/include/zephyr/net/wifi_utils.h index 4284138b6f3..c9ef9979f91 100644 --- a/include/zephyr/net/wifi_utils.h +++ b/include/zephyr/net/wifi_utils.h @@ -63,13 +63,15 @@ int wifi_utils_parse_scan_bands(char *scan_bands_str, uint8_t *band_map); * as a comma separated string and convert it to an array. * * @param scan_ssids_str List of SSIDs expressed as a comma separated list. - * @param ssids Pointer to an array where the parsed SSIDs are to be stored. + * @param ssids Pointer to an array where the SSIDs pointers are to be stored. + * @param num_ssids Maximum number of SSIDs that can be stored. * * @retval 0 on success. * @retval -errno value in case of failure. */ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, - char ssids[][WIFI_SSID_MAX_LEN + 1]); + const char *ssids[], + uint8_t num_ssids); /** diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 65e99204aa7..3aa674e73b7 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -481,7 +481,7 @@ static int wifi_scan_args_to_params(const struct shell *sh, {"bands", required_argument, 0, 'b'}, {"dwell_time_active", required_argument, 0, 'a'}, {"dwell_time_passive", required_argument, 0, 'p'}, - {"ssids", required_argument, 0, 's'}, + {"ssid", required_argument, 0, 's'}, {"max_bss", required_argument, 0, 'm'}, {"chans", required_argument, 0, 'c'}, {"help", no_argument, 0, 'h'}, @@ -538,7 +538,9 @@ static int wifi_scan_args_to_params(const struct shell *sh, opt_num++; break; case 's': - if (wifi_utils_parse_scan_ssids(optarg, params->ssids)) { + if (wifi_utils_parse_scan_ssids(optarg, + params->ssids, + ARRAY_SIZE(params->ssids))) { shell_fprintf(sh, SHELL_ERROR, "Invalid SSID(s)\n"); return -ENOEXEC; } @@ -1671,7 +1673,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "[-b, --bands ] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz.\n" "[-a, --dwell_time_active ] : Active scan dwell time (in ms) on a channel. Range 5 ms to 1000 ms.\n" "[-p, --dwell_time_passive ] : Passive scan dwell time (in ms) on a channel. Range 10 ms to 1000 ms.\n" - "[-s, --ssids ] : SSID list to scan for.\n" + "[-s, --ssid : SSID to scan for. Can be provided multiple times.\n" "[-m, --max_bss ] : Maximum BSSes to scan for. Range 1 - 65535.\n" "[-c, --chans ] : Channels to be scanned. The channels must be specified in the form band1:chan1,chan2_band2:chan3,..etc. band1, band2 must be valid band values and chan1, chan2, chan3 must be specified as a list of comma separated values where each value is either a single channel or a channel range specified as chan_start-chan_end. Each band channel set has to be separated by a _. For example, a valid channel specification can be 2:1,6-11,14_5:36,149-165,44\n" "[-h, --help] : Print out the help for the scan command.", diff --git a/subsys/net/l2/wifi/wifi_utils.c b/subsys/net/l2/wifi/wifi_utils.c index 4c50b817d26..52d25d90566 100644 --- a/subsys/net/l2/wifi/wifi_utils.c +++ b/subsys/net/l2/wifi/wifi_utils.c @@ -263,12 +263,9 @@ int wifi_utils_parse_scan_bands(char *scan_bands_str, uint8_t *band_map) } int wifi_utils_parse_scan_ssids(char *scan_ssids_str, - char ssids[][WIFI_SSID_MAX_LEN + 1]) + const char *ssids[], + uint8_t num_ssids) { - char parse_str[(WIFI_MGMT_SCAN_SSID_FILT_MAX * (WIFI_SSID_MAX_LEN + 1)) + 1]; - char *ssid = NULL; - char *ctx = NULL; - uint8_t i = 0; int len; if (!scan_ssids_str) { @@ -276,41 +273,23 @@ int wifi_utils_parse_scan_ssids(char *scan_ssids_str, } len = strlen(scan_ssids_str); - - if (len > (WIFI_MGMT_SCAN_SSID_FILT_MAX * (WIFI_SSID_MAX_LEN + 1))) { + if (len > WIFI_SSID_MAX_LEN) { NET_ERR("SSID string (%s) size (%d) exceeds maximum allowed value (%d)", scan_ssids_str, len, - (WIFI_MGMT_SCAN_SSID_FILT_MAX * (WIFI_SSID_MAX_LEN + 1))); + WIFI_SSID_MAX_LEN); return -EINVAL; } - strncpy(parse_str, scan_ssids_str, len); - parse_str[len] = '\0'; - - ssid = strtok_r(parse_str, ",", &ctx); - - while (ssid) { - if (strlen(ssid) > WIFI_SSID_MAX_LEN) { - NET_ERR("SSID length (%zu) exceeds maximum value (%d) for SSID %s", - strlen(ssid), - WIFI_SSID_MAX_LEN, - ssid); - return -EINVAL; - } - - if (i >= WIFI_MGMT_SCAN_SSID_FILT_MAX) { - NET_WARN("Exceeded maximum allowed (%d) SSIDs. Ignoring SSIDs %s onwards", - WIFI_MGMT_SCAN_SSID_FILT_MAX, - ssid); - break; + for (int i = 0; i < num_ssids; i++) { + if (ssids[i] != NULL) { + continue; } - - strcpy(&ssids[i++][0], ssid); - - ssid = strtok_r(NULL, ",", &ctx); + ssids[i] = scan_ssids_str; + return 0; } + NET_WARN("Exceeded maximum allowed SSIDs (%d)", num_ssids); return 0; } From 2395cebe107194b97bcf1d7ab80d0dcdab16ed2c Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 23 Sep 2023 17:59:34 +1000 Subject: [PATCH 06/15] [nrf fromtree] net: wifi: re-add `WIFI_MGMT_FORCED_PASSIVE_SCAN` Re-add the `WIFI_MGMT_FORCED_PASSIVE_SCAN` option removed in #62751. Now that `struct wifi_scan_params` is a reasonable size, we can enforce the passive scan request even when no parameter struct is supplied by the user. Signed-off-by: Jordan Yates (cherry picked from commit 2b92598df12ce66d6fc42327636c72c25fe6222b) --- subsys/net/l2/wifi/Kconfig | 9 +++++++++ subsys/net/l2/wifi/wifi_mgmt.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index 8fbd6aff4d6..134448aa57f 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -39,6 +39,15 @@ config WIFI_MGMT_TWT_CHECK_IP even when it is awake intervals. Rejecting TWT setup till Wi-Fi interface has a valid IP address might be desirable in most scenarios. +config WIFI_MGMT_FORCED_PASSIVE_SCAN + bool "Force passive Wi-Fi scanning" + help + Always request a passive scan, regardless of the user supplied parameters. + This is typically used when the underlying hardware is not certified for + RF transmissions. This doesn't guarantee that passive scan will be used, + it depends on the underlying chip implementation to support and honour + scan type. + config WIFI_MGMT_SCAN_SSID_FILT_MAX int "Maximum number of SSIDs that can be specified for SSID filtering" default 1 diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 58e14ff02ff..cdad7646e02 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -327,6 +327,15 @@ static int wifi_scan(uint32_t mgmt_request, struct net_if *iface, return -ENOTSUP; } +#ifdef CONFIG_WIFI_MGMT_FORCED_PASSIVE_SCAN + struct wifi_scan_params default_params = {0}; + + if (params == NULL) { + params = &default_params; + } + params->scan_type = WIFI_SCAN_TYPE_PASSIVE; +#endif /* CONFIG_WIFI_MGMT_FORCED_PASSIVE_SCAN */ + return wifi_mgmt_api->scan(dev, params, scan_result_cb); } From 0871917ae1c1cb509d99fccf36e6e3f512aedb0e Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 23 Sep 2023 17:41:46 +1000 Subject: [PATCH 07/15] [nrf fromtree] net: wifi_mgmt: update SSID storage type Update the storage type of the SSID strings to pointers to the strings, instead of needing to copy the strings into the struct. This substantially reduces the parameter struct size. Signed-off-by: Jordan Yates (cherry picked from commit a32e7aaa102d87aa06bb2105e3678844956d2b71) --- include/zephyr/net/wifi_mgmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index ab37bd4d878..d1bf5d43bfd 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -245,7 +245,7 @@ struct wifi_scan_params { uint16_t dwell_time_passive; /** Array of SSID strings to scan. */ - char ssids[WIFI_MGMT_SCAN_SSID_FILT_MAX][WIFI_SSID_MAX_LEN + 1]; + const char *ssids[WIFI_MGMT_SCAN_SSID_FILT_MAX]; /** Specifies the maximum number of scan results to return. These results would be the * BSSIDS with the best RSSI values, in all the scanned channels. This should only be * used to limit the number of returned scan results, and cannot be counted upon to limit From 3a89ca3f0542d04990799beb55da304d49eb3e12 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 13:55:12 +0530 Subject: [PATCH 08/15] [nrf fromlist] wifi: shell: Fix the arg count for reg domain Missed accounting for "-f" option. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 3aa674e73b7..c3100c9ad2c 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1688,7 +1688,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "[-f]: Force to use this regulatory hint over any other regulatory hints\n" "Note: This may cause regulatory compliance issues, use it at your own risk.", cmd_wifi_reg_domain, - 1, 1), + 1, 2), SHELL_CMD_ARG(mode, NULL, "mode operational setting\n" "This command may be used to set the Wi-Fi device into a specific mode of operation\n" "parameters:" From deb93546f7206052e1ac8fde82fa19197454a817 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 13:57:20 +0530 Subject: [PATCH 09/15] [nrf fromlist] wifi: shell: Fix optional arg count for connect Fix an extra optional arg. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index c3100c9ad2c..dbec138fea0 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1653,7 +1653,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "[MFP (optional: needs security type to be specified)]\n" ": 0:Disable, 1:Optional, 2:Required", cmd_wifi_connect, - 2, 5), + 2, 4), SHELL_CMD_ARG(disconnect, NULL, "Disconnect from the Wi-Fi AP", cmd_wifi_disconnect, 1, 0), From 7eb07b24cdfa7e3b71aab35dea27f9b79e831314 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 13:59:52 +0530 Subject: [PATCH 10/15] [nrf fromlist] wifi: shell: Fix help for PS command Clearly mark the args as optional. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index dbec138fea0..6ef745670ab 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1657,7 +1657,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, SHELL_CMD_ARG(disconnect, NULL, "Disconnect from the Wi-Fi AP", cmd_wifi_disconnect, 1, 0), - SHELL_CMD_ARG(ps, NULL, "Configure Wi-F PS on/off, no arguments will dump config", + SHELL_CMD_ARG(ps, NULL, "Configure or display Wi-Fi power save state\n" + "[on/off]\n", cmd_wifi_ps, 1, 1), SHELL_CMD_ARG(ps_mode, From 18383702c4061df5ab99f0d9174e7f2aaf85af3e Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 14:00:50 +0530 Subject: [PATCH 11/15] [nrf fromlist] wifi: shell: Remove the unnecessary text in scan We are using standard notation to differentiate optional and mandatory, so, no need for a heading. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 1 - 1 file changed, 1 deletion(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 6ef745670ab..d6d14c86bf1 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1669,7 +1669,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, 0), SHELL_CMD_ARG(scan, NULL, "Scan for Wi-Fi APs\n" - "OPTIONAL PARAMETERS:\n" "[-t, --type ] : Preferred mode of scan. The actual mode of scan can depend on factors such as the Wi-Fi chip implementation, regulatory domain restrictions. Default type is active.\n" "[-b, --bands ] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz.\n" "[-a, --dwell_time_active ] : Active scan dwell time (in ms) on a channel. Range 5 ms to 1000 ms.\n" From 7ed0aadf7b667a8b6d4b4305af87bacd07987e0a Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 14:02:42 +0530 Subject: [PATCH 12/15] [nrf fromlist] wifi: shell: Fix the help for reg domain Separate the two optional parameters and add help. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index d6d14c86bf1..890bb8f121e 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1684,7 +1684,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, SHELL_CMD(twt, &wifi_twt_ops, "Manage TWT flows", NULL), SHELL_CMD_ARG(reg_domain, NULL, "Set or Get Wi-Fi regulatory domain\n" - "Usage: wifi reg_domain [ISO/IEC 3166-1 alpha2] [-f]\n" + "[ISO/IEC 3166-1 alpha2]: Regulatory domain\n" "[-f]: Force to use this regulatory hint over any other regulatory hints\n" "Note: This may cause regulatory compliance issues, use it at your own risk.", cmd_wifi_reg_domain, From c52819bb7b44d77f7d286cbee2beb0411869c03b Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 14:07:36 +0530 Subject: [PATCH 13/15] [nrf fromlist] wifi: shell: Remove the unnecessary text The parameters heading is implied and doesn't have the newline, so, just remove it. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 890bb8f121e..a983e5c18f5 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1691,7 +1691,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, 1, 2), SHELL_CMD_ARG(mode, NULL, "mode operational setting\n" "This command may be used to set the Wi-Fi device into a specific mode of operation\n" - "parameters:" "[-i, --if-index ] : Interface index.\n" "[-s, --sta] : Station mode.\n" "[-m, --monitor] : Monitor mode.\n" @@ -1711,7 +1710,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "This command is used to set packet filter setting when\n" "monitor, TX-Injection and promiscuous mode is enabled.\n" "The different packet filter modes are control, management, data and enable all filters\n" - "parameters:" "[-i, --if-index ] : Interface index.\n" "[-a, --all] : Enable all packet filter modes\n" "[-m, --mgmt] : Enable management packets to allowed up the stack.\n" @@ -1730,7 +1728,6 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "This command is used to set the channel when\n" "monitor or TX-Injection mode is enabled.\n" "Currently 20 MHz is only supported and no BW parameter is provided\n" - "parameters:" "[-i, --if-index ] : Interface index.\n" "[-c, --channel ] : Set a specific channel number to the lower layer.\n" "[-g, --get] : Get current set channel number from the lower layer.\n" From 002c4074c1fb8ebcb544eceb4785c3aeaba33a8b Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 14:15:11 +0530 Subject: [PATCH 14/15] [nrf fromlist] wifi: shell: Fix the inconsistency in commands separation For better readability, below rules will help: * Each command should be separated by a newline * Each command should end with a full stop (intermediate statements shouldn't have full stops) Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/net/l2/wifi/wifi_shell.c | 98 ++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index a983e5c18f5..9bf33e827ec 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1601,7 +1601,7 @@ static int cmd_wifi_packet_filter(const struct shell *sh, size_t argc, char *arg SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap, SHELL_CMD_ARG(disable, NULL, - "Disable Access Point mode", + "Disable Access Point mode.\n", cmd_wifi_ap_disable, 1, 0), SHELL_CMD_ARG(enable, NULL, @@ -1611,7 +1611,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap, "[Security type: valid only for secure SSIDs]\n" "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n" "[MFP (optional: needs security type to be specified)]\n" - ": 0:Disable, 1:Optional, 2:Required", + ": 0:Disable, 1:Optional, 2:Required.\n", cmd_wifi_ap_enable, 2, 4), SHELL_SUBCMD_SET_END @@ -1619,30 +1619,30 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap, SHELL_STATIC_SUBCMD_SET_CREATE(wifi_twt_ops, SHELL_CMD_ARG(quick_setup, NULL, " Start a TWT flow with defaults:\n" - " \n", + " .\n", cmd_wifi_twt_setup_quick, 3, 0), SHELL_CMD_ARG(setup, NULL, " Start a TWT flow:\n" "\n" "\n" " " - " \n", + " .\n", cmd_wifi_twt_setup, 11, 0), SHELL_CMD_ARG(teardown, NULL, " Teardown a TWT flow:\n" "\n" "\n" - " \n", + " .\n", cmd_wifi_twt_teardown, 5, 0), - SHELL_CMD_ARG(teardown_all, NULL, " Teardown all TWT flows\n", + SHELL_CMD_ARG(teardown_all, NULL, " Teardown all TWT flows.\n", cmd_wifi_twt_teardown_all, 1, 0), SHELL_SUBCMD_SET_END ); SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, - SHELL_CMD(ap, &wifi_cmd_ap, "Access Point mode commands", NULL), + SHELL_CMD(ap, &wifi_cmd_ap, "Access Point mode commands.\n", NULL), SHELL_CMD_ARG(connect, NULL, "Connect to a Wi-Fi AP\n" "\"\"\n" @@ -1651,108 +1651,108 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "[Security type: valid only for secure SSIDs]\n" "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n" "[MFP (optional: needs security type to be specified)]\n" - ": 0:Disable, 1:Optional, 2:Required", + ": 0:Disable, 1:Optional, 2:Required.\n", cmd_wifi_connect, 2, 4), - SHELL_CMD_ARG(disconnect, NULL, "Disconnect from the Wi-Fi AP", + SHELL_CMD_ARG(disconnect, NULL, "Disconnect from the Wi-Fi AP.\n", cmd_wifi_disconnect, 1, 0), SHELL_CMD_ARG(ps, NULL, "Configure or display Wi-Fi power save state\n" - "[on/off]\n", + "[on/off].\n", cmd_wifi_ps, 1, 1), SHELL_CMD_ARG(ps_mode, NULL, - "\n", + ".\n", cmd_wifi_ps_mode, 2, 0), SHELL_CMD_ARG(scan, NULL, "Scan for Wi-Fi APs\n" - "[-t, --type ] : Preferred mode of scan. The actual mode of scan can depend on factors such as the Wi-Fi chip implementation, regulatory domain restrictions. Default type is active.\n" - "[-b, --bands ] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz.\n" - "[-a, --dwell_time_active ] : Active scan dwell time (in ms) on a channel. Range 5 ms to 1000 ms.\n" - "[-p, --dwell_time_passive ] : Passive scan dwell time (in ms) on a channel. Range 10 ms to 1000 ms.\n" - "[-s, --ssid : SSID to scan for. Can be provided multiple times.\n" - "[-m, --max_bss ] : Maximum BSSes to scan for. Range 1 - 65535.\n" + "[-t, --type ] : Preferred mode of scan. The actual mode of scan can depend on factors such as the Wi-Fi chip implementation, regulatory domain restrictions. Default type is active\n" + "[-b, --bands ] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz\n" + "[-a, --dwell_time_active ] : Active scan dwell time (in ms) on a channel. Range 5 ms to 1000 ms\n" + "[-p, --dwell_time_passive ] : Passive scan dwell time (in ms) on a channel. Range 10 ms to 1000 ms\n" + "[-s, --ssid : SSID to scan for. Can be provided multiple times\n" + "[-m, --max_bss ] : Maximum BSSes to scan for. Range 1 - 65535\n" "[-c, --chans ] : Channels to be scanned. The channels must be specified in the form band1:chan1,chan2_band2:chan3,..etc. band1, band2 must be valid band values and chan1, chan2, chan3 must be specified as a list of comma separated values where each value is either a single channel or a channel range specified as chan_start-chan_end. Each band channel set has to be separated by a _. For example, a valid channel specification can be 2:1,6-11,14_5:36,149-165,44\n" - "[-h, --help] : Print out the help for the scan command.", + "[-h, --help] : Print out the help for the scan command.\n", cmd_wifi_scan, 1, 8), - SHELL_CMD_ARG(statistics, NULL, "Wi-Fi interface statistics", cmd_wifi_stats, 1, 0), - SHELL_CMD_ARG(status, NULL, "Status of the Wi-Fi interface", cmd_wifi_status, 1, 0), - SHELL_CMD(twt, &wifi_twt_ops, "Manage TWT flows", NULL), + SHELL_CMD_ARG(statistics, NULL, "Wi-Fi interface statistics.\n", cmd_wifi_stats, 1, 0), + SHELL_CMD_ARG(status, NULL, "Status of the Wi-Fi interface.\n", cmd_wifi_status, 1, 0), + SHELL_CMD(twt, &wifi_twt_ops, "Manage TWT flows.\n", NULL), SHELL_CMD_ARG(reg_domain, NULL, "Set or Get Wi-Fi regulatory domain\n" "[ISO/IEC 3166-1 alpha2]: Regulatory domain\n" "[-f]: Force to use this regulatory hint over any other regulatory hints\n" - "Note: This may cause regulatory compliance issues, use it at your own risk.", + "Note: This may cause regulatory compliance issues, use it at your own risk.\n", cmd_wifi_reg_domain, 1, 2), SHELL_CMD_ARG(mode, NULL, "mode operational setting\n" "This command may be used to set the Wi-Fi device into a specific mode of operation\n" - "[-i, --if-index ] : Interface index.\n" - "[-s, --sta] : Station mode.\n" - "[-m, --monitor] : Monitor mode.\n" - "[-p, --promiscuous] : Promiscuous mode.\n" - "[-t, --tx-injection] : TX-Injection mode.\n" - "[-a, --ap] : AP mode.\n" - "[-k, --softap] : Softap mode.\n" - "[-h, --help] : Help.\n" - "[-g, --get] : Get current mode for a specific interface index.\n" + "[-i, --if-index ] : Interface index\n" + "[-s, --sta] : Station mode\n" + "[-m, --monitor] : Monitor mode\n" + "[-p, --promiscuous] : Promiscuous mode\n" + "[-t, --tx-injection] : TX-Injection mode\n" + "[-a, --ap] : AP mode\n" + "[-k, --softap] : Softap mode\n" + "[-h, --help] : Help\n" + "[-g, --get] : Get current mode for a specific interface index\n" "Usage: Get operation example for interface index 1\n" "wifi mode -g -i1\n" "Set operation example for interface index 1 - set station+promiscuous\n" - "wifi mode -i1 -sp\n", + "wifi mode -i1 -sp.\n", cmd_wifi_mode, 1, 9), SHELL_CMD_ARG(packet_filter, NULL, "mode filter setting\n" "This command is used to set packet filter setting when\n" - "monitor, TX-Injection and promiscuous mode is enabled.\n" + "monitor, TX-Injection and promiscuous mode is enabled\n" "The different packet filter modes are control, management, data and enable all filters\n" - "[-i, --if-index ] : Interface index.\n" + "[-i, --if-index ] : Interface index\n" "[-a, --all] : Enable all packet filter modes\n" - "[-m, --mgmt] : Enable management packets to allowed up the stack.\n" - "[-c, --ctrl] : Enable control packets to be allowed up the stack.\n" - "[-d, --data] : Enable Data packets to be allowed up the stack.\n" - "[-g, --get] : Get current filter settings for a specific interface index.\n" + "[-m, --mgmt] : Enable management packets to allowed up the stack\n" + "[-c, --ctrl] : Enable control packets to be allowed up the stack\n" + "[-d, --data] : Enable Data packets to be allowed up the stack\n" + "[-g, --get] : Get current filter settings for a specific interface index\n" "[-b, --capture-len ] : Capture length buffer size for each packet to be captured\n" - "[-h, --help] : Help.\n" + "[-h, --help] : Help\n" "Usage: Get operation example for interface index 1\n" "wifi packet_filter -g -i1\n" "Set operation example for interface index 1 - set data+management frame filter\n" - "wifi packet_filter -i1 -md\n", + "wifi packet_filter -i1 -md.\n", cmd_wifi_packet_filter, 1, 8), SHELL_CMD_ARG(channel, NULL, "wifi channel setting\n" "This command is used to set the channel when\n" - "monitor or TX-Injection mode is enabled.\n" + "monitor or TX-Injection mode is enabled\n" "Currently 20 MHz is only supported and no BW parameter is provided\n" - "[-i, --if-index ] : Interface index.\n" - "[-c, --channel ] : Set a specific channel number to the lower layer.\n" - "[-g, --get] : Get current set channel number from the lower layer.\n" - "[-h, --help] : Help.\n" + "[-i, --if-index ] : Interface index\n" + "[-c, --channel ] : Set a specific channel number to the lower layer\n" + "[-g, --get] : Get current set channel number from the lower layer\n" + "[-h, --help] : Help\n" "Usage: Get operation example for interface index 1\n" "wifi channel -g -i1\n" "Set operation example for interface index 1 (setting channel 5)\n" - "wifi -i1 -c5\n", + "wifi -i1 -c5.\n", cmd_wifi_channel, 1, 4), SHELL_CMD_ARG(ps_timeout, NULL, - " - PS inactivity timer(in ms)", + " - PS inactivity timer(in ms).\n", cmd_wifi_ps_timeout, 2, 0), SHELL_CMD_ARG(ps_listen_interval, NULL, - " - Listen interval in the range of <0-65535>", + " - Listen interval in the range of <0-65535>.\n", cmd_wifi_listen_interval, 2, 0), SHELL_CMD_ARG(ps_wakeup_mode, NULL, - "\n", + ".\n", cmd_wifi_ps_wakeup_mode, 2, 0), From 42fe4d06095e0ec1c52b99fd9006776c7bd0eacc Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Fri, 22 Dec 2023 14:20:22 +0530 Subject: [PATCH 15/15] [nrf fromlist] shell: Add a space after colon Just a cosmetic change, but IMHO the help looks much better now :). Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/66876 Signed-off-by: Chaitanya Tata --- subsys/shell/shell_help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/shell/shell_help.c b/subsys/shell/shell_help.c index 53bf00953c1..235e2111032 100644 --- a/subsys/shell/shell_help.c +++ b/subsys/shell/shell_help.c @@ -139,7 +139,7 @@ static void help_item_print(const struct shell *sh, const char *item_name, z_cursor_next_line_move(sh); return; } else { - z_shell_fprintf(sh, SHELL_NORMAL, "%s:", tabulator); + z_shell_fprintf(sh, SHELL_NORMAL, "%s: ", tabulator); } /* print option help */ formatted_text_print(sh, item_help, offset, false);