Skip to content

Commit 73964a2

Browse files
Adds support for WiFi band scan results (#326)
* Add `WiFiBandEnum` to scan callback struct * Fix typo in variable name for scanned SSID length in BackgroundScanCallback * Add WiFiBandEnum usage to WiFi interface implementations * Add WiFi band information to scan response in SlWiFiDriver * Refactor WiFiBandEnum usage to fully qualify the namespace in WifiInterface.h --------- Co-authored-by: brosahay <3526930+brosahay@users.noreply.github.com>
1 parent bc16787 commit 73964a2

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

src/platform/silabs/NetworkCommissioningWiFiDriver.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ void SlWiFiDriver::OnScanWiFiNetworkDone(wfx_wifi_scan_result_t * aScanResult)
310310
scanResponse.ssidLen = aScanResult->ssid_length;
311311
memcpy(scanResponse.ssid, aScanResult->ssid, scanResponse.ssidLen);
312312
memcpy(scanResponse.bssid, aScanResult->bssid, sizeof(scanResponse.bssid));
313+
scanResponse.wiFiBand = aScanResult->wiFiBand;
313314

314315
mScanResponseIter.Add(&scanResponse);
315316
}

src/platform/silabs/wifi/SiWx/WifiInterfaceImpl.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ extern "C" {
6868
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
6969

7070
using namespace chip::DeviceLayer::Silabs;
71+
using WiFiBandEnum = chip::app::Clusters::NetworkCommissioning::WiFiBandEnum;
7172

7273
// TODO : Temporary work-around for wifi-init failure in 917NCP ACX module boards.
7374
// Can be removed after Wiseconnect fixes region code for all ACX module boards.
@@ -200,9 +201,9 @@ sl_status_t BackgroundScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t
200201
{
201202
wfx_wifi_scan_result_t currentScanResult = { 0 };
202203

203-
// Lenght excludes null-character
204-
size_t scannedSsidLenght = strnlen(reinterpret_cast<char *>(result->scan_info[i].ssid), WFX_MAX_SSID_LENGTH);
205-
chip::ByteSpan scannedSsidSpan(result->scan_info[i].ssid, scannedSsidLenght);
204+
// Length excludes null-character
205+
size_t scannedSsidLength = strnlen(reinterpret_cast<char *>(result->scan_info[i].ssid), WFX_MAX_SSID_LENGTH);
206+
chip::ByteSpan scannedSsidSpan(result->scan_info[i].ssid, scannedSsidLength);
206207

207208
// Copy the scanned SSID to the current scan ssid buffer that will be forwarded to the callback
208209
chip::MutableByteSpan currentScanSsid(currentScanResult.ssid, WFX_MAX_SSID_LENGTH);
@@ -217,6 +218,8 @@ sl_status_t BackgroundScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t
217218
currentScanResult.security = static_cast<wfx_sec_t>(result->scan_info[i].security_mode);
218219
currentScanResult.rssi = (-1) * result->scan_info[i].rssi_val; // The returned value is positive - we need to flip it
219220
currentScanResult.chan = result->scan_info[i].rf_channel;
221+
// TODO: change this when SDK provides values
222+
currentScanResult.wiFiBand = WiFiBandEnum::k2g4;
220223

221224
// if user has provided ssid, check if the current scan result ssid matches the user provided ssid
222225
if (!requestedSsidSpan.empty())

src/platform/silabs/wifi/WifiInterface.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ typedef struct wfx_wifi_scan_result
7373
uint8_t bssid[kWifiMacAddressLength];
7474
uint8_t chan;
7575
int16_t rssi; /* I suspect this is in dBm - so signed */
76+
chip::app::Clusters::NetworkCommissioning::WiFiBandEnum wiFiBand;
7677
} wfx_wifi_scan_result_t;
7778
using ScanCallback = void (*)(wfx_wifi_scan_result_t *);
7879

@@ -422,7 +423,7 @@ class WifiInterface
422423
virtual uint32_t GetSupportedWiFiBandsMask() const
423424
{
424425
// Default to 2.4G support only
425-
return static_cast<uint32_t>(1UL << chip::to_underlying(app::Clusters::NetworkCommissioning::WiFiBandEnum::k2g4));
426+
return static_cast<uint32_t>(1UL << chip::to_underlying(chip::app::Clusters::NetworkCommissioning::WiFiBandEnum::k2g4));
426427
}
427428

428429
protected:

src/platform/silabs/wifi/rs911x/WifiInterfaceImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ extern "C" {
5555
WfxRsi_t wfx_rsi;
5656

5757
using namespace chip::DeviceLayer::Silabs;
58+
using WiFiBandEnum = chip::app::Clusters::NetworkCommissioning::WiFiBandEnum;
5859

5960
namespace {
6061

@@ -376,6 +377,8 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
376377
chip::MutableByteSpan bssidSpan(ap.bssid, kWifiMacAddressLength);
377378
chip::ByteSpan scanBssidSpan(scan.bssid, kWifiMacAddressLength);
378379
chip::CopySpanToMutableSpan(scanBssidSpan, bssidSpan);
380+
// TODO: change this when SDK provides values
381+
ap.wiFiBand = WiFiBandEnum::k2g4;
379382

380383
wfx_rsi.scan_cb(&ap);
381384

src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
using namespace ::chip;
4343
using namespace ::chip::DeviceLayer;
4444
using namespace ::chip::DeviceLayer::Silabs;
45+
using WiFiBandEnum = chip::app::Clusters::NetworkCommissioning::WiFiBandEnum;
4546

4647
// TODO: This is a workaround because we depend on the platform lib which depends on the platform implementation.
4748
// As such we can't depend on the platform here as well
@@ -483,6 +484,8 @@ static void sl_wfx_scan_result_callback(sl_wfx_scan_result_ind_body_t * scan_res
483484

484485
ap->scan.chan = scan_result->channel;
485486
ap->scan.rssi = ConvertRcpiToRssi(scan_result->rcpi);
487+
// WF200 only supports 2.4GHz band
488+
ap->scan.wiFiBand = WiFiBandEnum::k2g4;
486489

487490
chip::ByteSpan scannedBssid(scan_result->mac, kWifiMacAddressLength);
488491
chip::MutableByteSpan outputBssid(ap->scan.bssid, kWifiMacAddressLength);

0 commit comments

Comments
 (0)