Skip to content

Commit 4c5dd73

Browse files
nipandey-01kartben
authored andcommitted
driver: wifi: siwx91x: Add support for BG Scan
- Added support for background scan and configured the default values of BG scan configuration Signed-off-by: Nitin Pandey <[email protected]>
1 parent 8cec9f7 commit 4c5dd73

File tree

2 files changed

+85
-10
lines changed

2 files changed

+85
-10
lines changed

drivers/wifi/siwx91x/Kconfig.siwx91x

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,70 @@ config NET_MGMT_EVENT_STACK_SIZE
4545
config NET_MGMT_EVENT_QUEUE_SIZE
4646
default 10
4747

48+
49+
config WIFI_SILABS_SIWX91X_ADV_SCAN_THRESHOLD
50+
int "Advanced scan threshold (in dBm)"
51+
default -40
52+
help
53+
Configure the default advanced scan threshold for WiFi scanning.
54+
This value determines the signal strength (in dBm) below which
55+
the advanced scan mechanism will be triggered. Adjust this value
56+
to optimize scanning behavior based on your network environment.
57+
58+
config WIFI_SILABS_SIWX91X_ADV_RSSI_TOLERANCE_THRESHOLD
59+
int "Advanced RSSI tolerance threshold (in dBm)"
60+
default 5
61+
help
62+
Configure the default RSSI tolerance threshold for advanced WiFi scanning.
63+
This value determines the acceptable variation in signal strength (in dBm)
64+
during advanced scanning. Adjust this value to fine-tune the sensitivity
65+
of the scanning mechanism to signal fluctuations.
66+
67+
config WIFI_SILABS_SIWX91X_ADV_ACTIVE_SCAN_DURATION
68+
int "Advanced active scan duration (in ms)"
69+
default 15
70+
help
71+
Configure the default advanced active scan duration for WiFi scanning.
72+
This value determines the time (in milliseconds) spent on each
73+
channel during an advanced active scan. Adjust this value to optimize
74+
scanning speed and accuracy based on your network environment.
75+
76+
config WIFI_SILABS_SIWX91X_ADV_PASSIVE_SCAN_DURATION
77+
int "Advanced passive scan duration (in ms)"
78+
default 20
79+
help
80+
Configure the default advanced passive scan duration for WiFi scanning.
81+
This value determines the time (in milliseconds) spent on each
82+
channel during an advanced passive scan. Adjust this value to optimize
83+
scanning speed and accuracy based on your network environment.
84+
85+
config WIFI_SILABS_SIWX91X_ADV_MULTIPROBE
86+
int "Advanced multiprobe setting"
87+
default 0
88+
help
89+
Configure the advanced multiprobe setting for WiFi scanning.
90+
When set to 1, multiple probe requests will be sent to all access
91+
points in addition to the connected SSID during scanning. Adjust
92+
this value to fine-tune scanning behavior based on your network
93+
requirements.
94+
95+
config WIFI_SILABS_SIWX91X_ADV_SCAN_PERIODICITY
96+
int "Advanced scan periodicity (in ms)"
97+
default 10
98+
help
99+
Configure the default advanced scan periodicity for WiFi scanning.
100+
This value determines the interval (in milliseconds) between consecutive
101+
advanced scans. Adjust this value to balance scanning frequency
102+
and power consumption based on your network environment.
103+
104+
config WIFI_SILABS_SIWX91X_ENABLE_INSTANT_SCAN
105+
int "Instant scan support"
106+
default 1
107+
help
108+
Enable support to start an advanced scan immediately. When enabled, the device
109+
can perform an advanced scan without waiting for the periodic
110+
scan interval, enabling quicker detection of available networks.
111+
48112
# Override the WIFI_MGMT_SCAN_SSID_FILT_MAX parameter for the Wi-Fi subsystem.
49113
# This device supports filtering scan results for only one SSID.
50114
config WIFI_MGMT_SCAN_SSID_FILT_MAX

drivers/wifi/siwx91x/siwx91x_wifi.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
479479
scan_result_cb_t cb)
480480
{
481481
sl_wifi_scan_configuration_t sl_scan_config = { };
482+
sl_wifi_advanced_scan_configuration_t advanced_scan_config = {
483+
.trigger_level = CONFIG_WIFI_SILABS_SIWX91X_ADV_SCAN_THRESHOLD,
484+
.trigger_level_change = CONFIG_WIFI_SILABS_SIWX91X_ADV_RSSI_TOLERANCE_THRESHOLD,
485+
.enable_multi_probe = CONFIG_WIFI_SILABS_SIWX91X_ADV_MULTIPROBE,
486+
.enable_instant_scan = CONFIG_WIFI_SILABS_SIWX91X_ENABLE_INSTANT_SCAN,
487+
};
482488
struct siwx91x_dev *sidev = dev->data;
483489
sl_wifi_interface_t interface;
484490
sl_wifi_ssid_t ssid = { };
@@ -503,17 +509,22 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
503509
return -EINVAL;
504510
}
505511

506-
if (z_scan_config->scan_type == WIFI_SCAN_TYPE_ACTIVE) {
507-
sl_scan_config.type = SL_WIFI_SCAN_TYPE_ACTIVE;
508-
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT,
509-
z_scan_config->dwell_time_active);
512+
if (sidev->state == WIFI_STATE_COMPLETED) {
513+
ret = sl_wifi_set_advanced_scan_configuration(&advanced_scan_config);
514+
if (ret != SL_STATUS_OK) {
515+
LOG_ERR("advanced scan configuration failed with status %x", ret);
516+
return -EINVAL;
517+
}
518+
519+
sl_scan_config.type = SL_WIFI_SCAN_TYPE_ADV_SCAN;
520+
sl_scan_config.periodic_scan_interval =
521+
CONFIG_WIFI_SILABS_SIWX91X_ADV_SCAN_PERIODICITY;
510522
} else {
511-
sl_scan_config.type = SL_WIFI_SCAN_TYPE_PASSIVE;
512-
ret = sl_si91x_configure_timeout(SL_SI91X_CHANNEL_PASSIVE_SCAN_TIMEOUT,
513-
z_scan_config->dwell_time_passive);
514-
}
515-
if (ret) {
516-
return -EINVAL;
523+
if (z_scan_config->scan_type == WIFI_SCAN_TYPE_ACTIVE) {
524+
sl_scan_config.type = SL_WIFI_SCAN_TYPE_ACTIVE;
525+
} else {
526+
sl_scan_config.type = SL_WIFI_SCAN_TYPE_PASSIVE;
527+
}
517528
}
518529

519530
for (int i = 0; i < ARRAY_SIZE(z_scan_config->band_chan); i++) {

0 commit comments

Comments
 (0)