Skip to content

Commit

Permalink
driver: wifi: siwx917: Add single and multi-channel scan support
Browse files Browse the repository at this point in the history
This commit introduces support for single and multi-channel
Wi-Fi scans. The device can now scan one specific channel or
multiple specified channels.

Signed-off-by: Arunmani Alagarsamy <[email protected]>
  • Loading branch information
ArunmaniAlagarsamy2710 authored and jerome-pouiller committed Feb 5, 2025
1 parent 25849c1 commit 91d9a74
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions drivers/wifi/siwx917/siwx917_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,36 @@ static void siwx917_report_scan_res(struct siwx917_dev *sidev, sl_wifi_scan_resu
{ SL_WIFI_WPA_ENTERPRISE, WIFI_SECURITY_TYPE_EAP },
{ SL_WIFI_WPA2_ENTERPRISE, WIFI_SECURITY_TYPE_EAP },
};

struct wifi_scan_result tmp = {
.channel = result->scan_info[item].rf_channel,
.rssi = result->scan_info[item].rssi_val,
.ssid_length = strlen(result->scan_info[item].ssid),
.mac_length = sizeof(result->scan_info[item].bssid),
.security = WIFI_SECURITY_TYPE_UNKNOWN,
.mfp = WIFI_MFP_UNKNOWN,
/* FIXME: fill .mfp, .band and .channel */
.band = WIFI_FREQ_BAND_2_4_GHZ,
};
int i;

if (result->scan_count == 0) {
return;
}

if (result->scan_info[item].rf_channel <= 0 || result->scan_info[item].rf_channel > 14) {
LOG_WRN("Unexpected scan result");
tmp.band = WIFI_FREQ_BAND_UNKNOWN;
}

memcpy(tmp.ssid, result->scan_info[item].ssid, tmp.ssid_length);
memcpy(tmp.mac, result->scan_info[item].bssid, tmp.mac_length);

for (i = 0; i < ARRAY_SIZE(security_convert); i++) {
if (security_convert[i].sl_val == result->scan_info[item].security_mode) {
tmp.security = security_convert[i].z_val;
}
}

sidev->scan_res_cb(sidev->iface, 0, &tmp);
}

Expand All @@ -186,6 +198,10 @@ static unsigned int siwx917_on_scan(sl_wifi_event_t event, sl_wifi_scan_result_t
return -EFAULT;
}

if (event & SL_WIFI_EVENT_FAIL_INDICATION) {
memset(result, 0, sizeof(*result));
}

if (sidev->scan_max_bss_cnt) {
scan_count = MIN(result->scan_count, sidev->scan_max_bss_cnt);
} else {
Expand All @@ -195,8 +211,10 @@ static unsigned int siwx917_on_scan(sl_wifi_event_t event, sl_wifi_scan_result_t
for (i = 0; i < scan_count; i++) {
siwx917_report_scan_res(sidev, result, i);
}

sidev->scan_res_cb(sidev->iface, 0, NULL);
sidev->state = WIFI_STATE_INACTIVE;

return 0;
}

Expand All @@ -217,7 +235,10 @@ static int siwx917_scan(const struct device *dev, struct wifi_scan_params *z_sca
/* The enum values are same, no conversion needed */
sl_scan_config.type = z_scan_config->scan_type;

sl_scan_config.channel_bitmap_2g4 = 0xFFFF;
for (int i = 0; i < WIFI_MGMT_SCAN_CHAN_MAX_MANUAL; i++) {
sl_scan_config.channel_bitmap_2g4 |= BIT(z_scan_config->band_chan[i].channel - 1);
}

memset(sl_scan_config.channel_bitmap_5g, 0xFF, sizeof(sl_scan_config.channel_bitmap_5g));
if (IS_ENABLED(CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX)) {
if (z_scan_config->ssids[0]) {
Expand Down

0 comments on commit 91d9a74

Please sign in to comment.