net: wifi: Add scan extension for active channel dwell times

Add scan extension to control time spent on active scan channels.

Signed-off-by: Sachin D Kulkarni <sachin.kulkarni@nordicsemi.no>
This commit is contained in:
Sachin D Kulkarni 2023-07-19 20:11:08 +05:30 committed by Fabio Baltieri
parent ee6c81896d
commit 3c130b138f
4 changed files with 29 additions and 2 deletions

View File

@ -192,6 +192,9 @@ struct wifi_scan_params {
* Refer to ::wifi_frequency_bands for bit position of each band.
*/
uint8_t bands;
/** Active scan dwell time (in ms) on a channel.
*/
uint16_t dwell_time_active;
};
/** Wi-Fi scan result, each result is provided to the net_mgmt_event_callback

View File

@ -59,6 +59,13 @@ config WIFI_MGMT_SCAN_BANDS
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_NM
bool "Wi-Fi Network manager support"
help

View File

@ -121,6 +121,10 @@ static int wifi_scan(uint32_t mgmt_request, struct net_if *iface,
return -EINVAL;
}
}
if (!params->dwell_time_active) {
params->dwell_time_active = CONFIG_WIFI_MGMT_SCAN_DWELL_TIME_ACTIVE;
}
}
return wifi_mgmt_api->scan(dev, params, scan_result_cb);

View File

@ -469,10 +469,12 @@ static int wifi_scan_args_to_params(const struct shell *sh,
int opt;
static struct option long_options[] = {{"type", required_argument, 0, 't'},
{"bands", required_argument, 0, 'b'},
{"dwell_time_active", required_argument, 0, 'a'},
{0, 0, 0, 0}};
int opt_index = 0;
int val;
while ((opt = getopt_long(argc, argv, "t:b:", long_options, &opt_index)) != -1) {
while ((opt = getopt_long(argc, argv, "t:b:a:", long_options, &opt_index)) != -1) {
state = getopt_state_get();
switch (opt) {
case 't':
@ -491,6 +493,16 @@ static int wifi_scan_args_to_params(const struct shell *sh,
return -ENOEXEC;
}
break;
case 'a':
val = atoi(optarg);
if ((val < 5) || (val > 1000)) {
shell_fprintf(sh, SHELL_ERROR, "Invalid dwell_time_active val\n");
return -ENOEXEC;
}
params->dwell_time_active = val;
break;
case '?':
shell_fprintf(sh, SHELL_ERROR, "Invalid option or option usage: %s\n",
argv[opt_index + 1]);
@ -1224,7 +1236,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands,
"Scan for Wi-Fi APs\n"
"OPTIONS:\n"
"[-t, --type <active/passive>] : 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 <Comma separated list of band values (2/5/6)>] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz.",
"[-b, --bands <Comma separated list of band values (2/5/6)>] : Bands to be scanned where 2: 2.4 GHz, 5: 5 GHz, 6: 6 GHz.\n"
"[-a, --dwell_time_active <val_in_ms>] : Active scan dwell time (in ms) on a channel. Range 5 ms to 1000 ms.",
cmd_wifi_scan),
SHELL_CMD(statistics, NULL, "Wi-Fi interface statistics", cmd_wifi_stats),
SHELL_CMD(status, NULL, "Status of the Wi-Fi interface", cmd_wifi_status),