Skip to content

Commit e1ea4c6

Browse files
[SILABS] Adds support for WiFi band details (#38051)
* Adds `GetSupportedWiFiBandsMask` API * Refactor WiFi band mask methods for consistency in naming * Fix WiFi band enum reference in GetSupportedWiFiBandsMask implementation * 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> --------- Co-authored-by: brosahay <3526930+brosahay@users.noreply.github.com>
1 parent 4a97585 commit e1ea4c6

7 files changed

+36
-3
lines changed

src/platform/silabs/NetworkCommissioningWiFiDriver.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ chip::BitFlags<WiFiSecurity> SlWiFiDriver::ConvertSecuritytype(wfx_sec_t securit
258258
return securityType;
259259
}
260260

261+
uint32_t SlWiFiDriver::GetSupportedWiFiBandsMask() const
262+
{
263+
return WifiInterface::GetInstance().GetSupportedWiFiBandsMask();
264+
}
265+
261266
bool SlWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)
262267
{
263268
ChipLogProgress(DeviceLayer, "Start Scan WiFi Networks");
@@ -305,6 +310,7 @@ void SlWiFiDriver::OnScanWiFiNetworkDone(wfx_wifi_scan_result_t * aScanResult)
305310
scanResponse.ssidLen = aScanResult->ssid_length;
306311
memcpy(scanResponse.ssid, aScanResult->ssid, scanResponse.ssidLen);
307312
memcpy(scanResponse.bssid, aScanResult->bssid, sizeof(scanResponse.bssid));
313+
scanResponse.wiFiBand = aScanResult->wiFiBand;
308314

309315
mScanResponseIter.Add(&scanResponse);
310316
}

src/platform/silabs/NetworkCommissioningWiFiDriver.h

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class SlWiFiDriver final : public WiFiDriver
123123
CHIP_ERROR ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen);
124124

125125
chip::BitFlags<WiFiSecurity> ConvertSecuritytype(wfx_sec_t security);
126+
uint32_t GetSupportedWiFiBandsMask() const override;
126127

127128
void OnConnectWiFiNetwork();
128129
void UpdateNetworkingStatus();

src/platform/silabs/wifi/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ source_set("wifi-platform") {
113113
"${chip_root}/src/app/icd/server:icd-server-config",
114114
"${chip_root}/src/inet",
115115
"${chip_root}/src/lib/support",
116+
"${chip_root}/src/platform:platform_base",
116117
]
117118

118119
if (use_rs9116) {

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.
@@ -201,9 +202,9 @@ sl_status_t BackgroundScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t
201202
{
202203
wfx_wifi_scan_result_t currentScanResult = { 0 };
203204

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

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

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

src/platform/silabs/wifi/WifiInterface.h

+16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
*/
1717
#pragma once
1818

19+
#include <app-common/zap-generated/cluster-enums.h>
1920
#include <app/icd/server/ICDServerConfig.h>
21+
2022
#include <array>
2123
#include <cmsis_os2.h>
2224
#include <lib/support/BitFlags.h>
@@ -71,6 +73,7 @@ typedef struct wfx_wifi_scan_result
7173
uint8_t bssid[kWifiMacAddressLength];
7274
uint8_t chan;
7375
int16_t rssi; /* I suspect this is in dBm - so signed */
76+
chip::app::Clusters::NetworkCommissioning::WiFiBandEnum wiFiBand;
7477
} wfx_wifi_scan_result_t;
7578
using ScanCallback = void (*)(wfx_wifi_scan_result_t *);
7679

@@ -410,6 +413,19 @@ class WifiInterface
410413
*/
411414
virtual void CancelScanNetworks() = 0;
412415

416+
/**
417+
* @brief Provide all the frequency bands supported by the Wi-Fi interface.
418+
*
419+
* The default implementation returns the 2.4 GHz band support.
420+
*
421+
* @return a bitmask of supported Wi-Fi bands where each bit is associated with a WiFiBandEnum value.
422+
*/
423+
virtual uint32_t GetSupportedWiFiBandsMask() const
424+
{
425+
// Default to 2.4G support only
426+
return static_cast<uint32_t>(1UL << chip::to_underlying(chip::app::Clusters::NetworkCommissioning::WiFiBandEnum::k2g4));
427+
}
428+
413429
protected:
414430
/**
415431
* @brief Function notifies the PlatformManager that an IPv6 event occured on the WiFi interface.

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

@@ -379,6 +380,8 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
379380
chip::MutableByteSpan bssidSpan(ap.bssid, kWifiMacAddressLength);
380381
chip::ByteSpan scanBssidSpan(scan.bssid, kWifiMacAddressLength);
381382
chip::CopySpanToMutableSpan(scanBssidSpan, bssidSpan);
383+
// TODO: change this when SDK provides values
384+
ap.wiFiBand = WiFiBandEnum::k2g4;
382385

383386
wfx_rsi.scan_cb(&ap);
384387

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)