diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 4ab94d730ad..41da2747298 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -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 diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index 53ec5db3b81..dbee3d7045f 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -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 diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index bcd502df4a2..7e0fb189da6 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -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); diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 42d4f2f48a6..89eb2fd7584 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -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 ] : 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.", + "[-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.", 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),