diff --git a/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp b/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp index dc6e751b0d5f4b..d3e6a86fdd281d 100644 --- a/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp +++ b/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp @@ -119,12 +119,12 @@ CHIP_ERROR WiFiDiagosticsAttrAccess::ReadSecurityType(AttributeValueEncoder & aE CHIP_ERROR WiFiDiagosticsAttrAccess::ReadWiFiVersion(AttributeValueEncoder & aEncoder) { Attributes::WiFiVersion::TypeInfo::Type version; - uint8_t value = 0; + WiFiVersionEnum value = WiFiVersionEnum::kUnknownEnumValue; if (DeviceLayer::GetDiagnosticDataProvider().GetWiFiVersion(value) == CHIP_NO_ERROR) { - version.SetNonNull(static_cast(value)); - ChipLogProgress(Zcl, "The current 802.11 standard version in use by the Node: %d", value); + version.SetNonNull(value); + ChipLogProgress(Zcl, "The current 802.11 standard version in use by the Node: %d", to_underlying(value)); } else { diff --git a/src/include/platform/DiagnosticDataProvider.h b/src/include/platform/DiagnosticDataProvider.h index 27a92eeeeb339f..5098c5a167e8f4 100644 --- a/src/include/platform/DiagnosticDataProvider.h +++ b/src/include/platform/DiagnosticDataProvider.h @@ -158,7 +158,7 @@ class DiagnosticDataProvider */ virtual CHIP_ERROR GetWiFiBssId(ByteSpan & value); virtual CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType); - virtual CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion); + virtual CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion); virtual CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber); virtual CHIP_ERROR GetWiFiRssi(int8_t & rssi); virtual CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount); @@ -339,7 +339,7 @@ DiagnosticDataProvider::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostic return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } -inline CHIP_ERROR DiagnosticDataProvider::GetWiFiVersion(uint8_t & wiFiVersion) +inline CHIP_ERROR DiagnosticDataProvider::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp index 5a272040fac48a..c869aee8d09f2d 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp @@ -270,10 +270,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) return CHIP_NO_ERROR; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) { // Support 802.11a/n Wi-Fi in AmebaD chipset - wifiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN); + // TODO: https://github.com/project-chip/connectedhomeip/issues/25542 + wifiVersion = app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN; return CHIP_NO_ERROR; } diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.h b/src/platform/Ameba/DiagnosticDataProviderImpl.h index 83484c1dfd5419..e4fedb659c9912 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.h +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.h @@ -56,7 +56,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #if CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/Beken/DiagnosticDataProviderImpl.cpp b/src/platform/Beken/DiagnosticDataProviderImpl.cpp index f8cb5c584800e8..2c08da4cbcd081 100644 --- a/src/platform/Beken/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Beken/DiagnosticDataProviderImpl.cpp @@ -170,10 +170,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) return CHIP_NO_ERROR; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) { // Support 802.11a/n Wi-Fi in Beken chipset - wiFiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN); + // TODO: https://github.com/project-chip/connectedhomeip/issues/25543 + wiFiVersion = app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN; return CHIP_NO_ERROR; } diff --git a/src/platform/Beken/DiagnosticDataProviderImpl.h b/src/platform/Beken/DiagnosticDataProviderImpl.h index ecae313ea1643e..5e47df4e04a8f0 100644 --- a/src/platform/Beken/DiagnosticDataProviderImpl.h +++ b/src/platform/Beken/DiagnosticDataProviderImpl.h @@ -52,7 +52,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #if CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index 4ac4bebca424ec..f811170d335894 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -82,16 +82,19 @@ app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum MapAuthModeToSecurityTyp } } -uint8_t GetWiFiVersionFromAPRecord(wifi_ap_record_t ap_info) +app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum GetWiFiVersionFromAPRecord(wifi_ap_record_t ap_info) { + using app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum; if (ap_info.phy_11n) - return 3; + return WiFiVersionEnum::kN; else if (ap_info.phy_11g) - return 2; + return WiFiVersionEnum::kG; else if (ap_info.phy_11b) - return 1; + return WiFiVersionEnum::kB; else - return 0; + // TODO: This is keeping the old behavior, it doesn't look right. + // https://github.com/project-chip/connectedhomeip/issues/25544 + return WiFiVersionEnum::kA; } #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI @@ -305,17 +308,18 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe return CHIP_NO_ERROR; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) { - wifiVersion = 0; wifi_ap_record_t ap_info; esp_err_t err; err = esp_wifi_sta_get_ap_info(&ap_info); if (err == ESP_OK) { wifiVersion = GetWiFiVersionFromAPRecord(ap_info); + return CHIP_NO_ERROR; } - return CHIP_NO_ERROR; + + return ESP32Utils::MapError(err); } CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) @@ -328,8 +332,10 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNu if (err == ESP_OK) { channelNumber = ap_info.primary; + return CHIP_NO_ERROR; } - return CHIP_NO_ERROR; + + return ESP32Utils::MapError(err); } CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) @@ -343,8 +349,10 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) if (err == ESP_OK) { rssi = ap_info.rssi; + return CHIP_NO_ERROR; } - return CHIP_NO_ERROR; + + return ESP32Utils::MapError(err); } CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount) diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.h b/src/platform/ESP32/DiagnosticDataProviderImpl.h index ff8f252a6844f1..d272386ad3ffe5 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.h +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.h @@ -54,7 +54,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #if CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp index 19bb5154ceed3c..076238a2f52899 100644 --- a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp @@ -245,9 +245,10 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe return err; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { - CHIP_ERROR err = CHIP_NO_ERROR; + using app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum; + wl_bss_info_t bss_info; whd_security_t security; cy_rslt_t result = CY_RSLT_SUCCESS; @@ -256,27 +257,26 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "whd_wifi_get_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + return CHIP_ERROR_INTERNAL; } /* VHT Capable */ if (bss_info.vht_cap) { - wiFiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kAc); + wiFiVersion = WiFiVersionEnum::kAc; } /* HT Capable */ else if (bss_info.n_cap) { - wiFiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN); + wiFiVersion = WiFiVersionEnum::kN; } /* 11g Capable */ else { - wiFiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kG); + wiFiVersion = WiFiVersionEnum::kG; } -exit: - return err; + return CHIP_NO_ERROR; } CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) diff --git a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.h b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.h index 80470d7996c22b..49756749c398da 100644 --- a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.h +++ b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.h @@ -77,7 +77,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconRxCount(uint32_t & beaconRxCount) override; diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index f3d3d2b138bd54..c04adfaf105780 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1239,10 +1239,10 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(SecurityTypeEnum & secur return CHIP_NO_ERROR; } -CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(WiFiVersionEnum & wiFiVersion) { // We don't have direct API to get the WiFi version yet, return 802.11n on Linux simulation. - wiFiVersion = to_underlying(WiFiVersionEnum::kN); + wiFiVersion = WiFiVersionEnum::kN; return CHIP_NO_ERROR; } diff --git a/src/platform/Linux/ConnectivityManagerImpl.h b/src/platform/Linux/ConnectivityManagerImpl.h index 1ddb171d405a3c..e3fac9628a2238 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.h +++ b/src/platform/Linux/ConnectivityManagerImpl.h @@ -137,7 +137,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, int32_t GetDisconnectReason(); CHIP_ERROR GetWiFiBssId(ByteSpan & value); CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType); - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion); + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion); CHIP_ERROR GetConfiguredNetwork(NetworkCommissioning::Network & network); CHIP_ERROR StartWiFiScan(ByteSpan ssid, NetworkCommissioning::WiFiDriver::ScanCallback * callback); #endif diff --git a/src/platform/Linux/DiagnosticDataProviderImpl.cpp b/src/platform/Linux/DiagnosticDataProviderImpl.cpp index 2444b359cd83e3..08a42a599da0f2 100644 --- a/src/platform/Linux/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Linux/DiagnosticDataProviderImpl.cpp @@ -813,7 +813,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI #if CHIP_DEVICE_CONFIG_ENABLE_WPA -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { return ConnectivityMgrImpl().GetWiFiVersion(wiFiVersion); } diff --git a/src/platform/Linux/DiagnosticDataProviderImpl.h b/src/platform/Linux/DiagnosticDataProviderImpl.h index 7dab9dafa68d84..f1320595624335 100644 --- a/src/platform/Linux/DiagnosticDataProviderImpl.h +++ b/src/platform/Linux/DiagnosticDataProviderImpl.h @@ -83,7 +83,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #endif #if CHIP_DEVICE_CONFIG_ENABLE_WPA - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) override; CHIP_ERROR GetWiFiBssId(ByteSpan & value) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; #endif diff --git a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp index 9b40585f108c4c..7c1d8fe9c28ff6 100644 --- a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp @@ -257,9 +257,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe return CHIP_NO_ERROR; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) { - wifiVersion = 0; + // TODO: Keeping existing behavior, but this looks broken. + // https://github.com/project-chip/connectedhomeip/issues/25546 + wifiVersion = app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kA; return CHIP_NO_ERROR; } diff --git a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.h b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.h index 357e3dbb9a3ef4..47aabacb85b9ff 100644 --- a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.h +++ b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.h @@ -52,7 +52,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp index 8a058207581143..9190e451b680e4 100644 --- a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp +++ b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.cpp @@ -61,7 +61,7 @@ DiagnosticDataProviderImplNrf::GetWiFiSecurityType(app::Clusters::WiFiNetworkDia return err; } -CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR DiagnosticDataProviderImplNrf::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { WiFiManager::WiFiInfo info; CHIP_ERROR err = WiFiManager::Instance().GetWiFiInfo(info); diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h index 1f6307726fc0ba..b3bc549c4aa0bb 100644 --- a/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h +++ b/src/platform/nrfconnect/DiagnosticDataProviderImplNrf.h @@ -34,7 +34,7 @@ class DiagnosticDataProviderImplNrf : public DiagnosticDataProviderImpl #ifdef CONFIG_WIFI_NRF700X CHIP_ERROR GetWiFiBssId(ByteSpan & value) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/nrfconnect/wifi/WiFiManager.cpp b/src/platform/nrfconnect/wifi/WiFiManager.cpp index 272dca72b20bb9..f8a8f63fdd166f 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.cpp +++ b/src/platform/nrfconnect/wifi/WiFiManager.cpp @@ -75,30 +75,30 @@ NetworkCommissioning::WiFiScanResponse ToScanResponse(const wifi_scan_result * r // Matter expectations towards Wi-Fi version codes are unaligned with // what wpa_supplicant provides. This function maps supplicant codes -// to the ones defined in the Matter spec (11.14.3.2. WiFiVersion enum) -uint8_t MapToMatterWiFiVersionCode(wifi_link_mode wifiVersion) +// to the ones defined in the Matter spec (11.14.5.2. WiFiVersionEnum) +app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum MapToMatterWiFiVersionCode(wifi_link_mode wifiVersion) { using app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum; if (wifiVersion < WIFI_1 || wifiVersion > WIFI_6E) { ChipLogError(DeviceLayer, "Unsupported Wi-Fi version detected"); - return static_cast(WiFiVersionEnum::kA); // let's return 'a' by default + return WiFiVersionEnum::kA; // let's return 'a' by default } switch (wifiVersion) { case WIFI_1: - return static_cast(WiFiVersionEnum::kB); + return WiFiVersionEnum::kB; case WIFI_2: - return static_cast(WiFiVersionEnum::kA); + return WiFiVersionEnum::kA; case WIFI_6E: - return static_cast(WiFiVersionEnum::kAx); // treat as 802.11ax + return WiFiVersionEnum::kAx; // treat as 802.11ax default: break; } - return (static_cast(wifiVersion) - 1); + return static_cast(wifiVersion - 1); } // Matter expectations towards Wi-Fi security type codes are unaligned with diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h index beed57575f3283..2e1b86e94b0a8e 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.h +++ b/src/platform/nrfconnect/wifi/WiFiManager.h @@ -129,7 +129,7 @@ class WiFiManager { ByteSpan mBssId{}; app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum mSecurityType{}; - uint8_t mWiFiVersion{}; + app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum mWiFiVersion{}; uint16_t mChannel{}; int8_t mRssi{}; uint8_t mSsid[DeviceLayer::Internal::kMaxWiFiSSIDLength]; diff --git a/src/platform/nxp/mw320/ConnectivityManagerImpl.cpp b/src/platform/nxp/mw320/ConnectivityManagerImpl.cpp index c5aa4adf1f9b69..bb8d3a39a7fa0c 100644 --- a/src/platform/nxp/mw320/ConnectivityManagerImpl.cpp +++ b/src/platform/nxp/mw320/ConnectivityManagerImpl.cpp @@ -209,10 +209,8 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiBssId(ByteSpan & value) return CHIP_NO_ERROR; } -CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) +CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(SecurityTypeEnum & securityType) { - using app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum; - int ret = wlan_get_current_network(&sta_network); if (ret != WM_SUCCESS) { @@ -244,10 +242,10 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(app::Clusters::WiFiNetwo return CHIP_NO_ERROR; } -CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(WiFiVersionEnum & wiFiVersion) { - wiFiVersion = to_underlying(WiFiVersionEnum::kN); - ChipLogProgress(DeviceLayer, "GetWiFiVersion: %u", wiFiVersion); + wiFiVersion = WiFiVersionEnum::kN; + ChipLogProgress(DeviceLayer, "GetWiFiVersion: %u", to_underlying(wiFiVersion)); return CHIP_NO_ERROR; } diff --git a/src/platform/nxp/mw320/ConnectivityManagerImpl.h b/src/platform/nxp/mw320/ConnectivityManagerImpl.h index 83360590706920..23677c82afd8de 100644 --- a/src/platform/nxp/mw320/ConnectivityManagerImpl.h +++ b/src/platform/nxp/mw320/ConnectivityManagerImpl.h @@ -86,7 +86,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void StartWiFiManagement(); CHIP_ERROR GetWiFiBssId(ByteSpan & value); CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType); - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion); + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion); #endif CHIP_ERROR GetConfiguredNetwork(NetworkCommissioning::Network & network); CHIP_ERROR StartWiFiScan(ByteSpan ssid, NetworkCommissioning::WiFiDriver::ScanCallback * callback); diff --git a/src/platform/nxp/mw320/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/mw320/DiagnosticDataProviderImpl.cpp index 4c6e7df903c8d6..07fff9135836a6 100644 --- a/src/platform/nxp/mw320/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/mw320/DiagnosticDataProviderImpl.cpp @@ -289,7 +289,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() return CHIP_NO_ERROR; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { return ConnectivityMgrImpl().GetWiFiVersion(wiFiVersion); } diff --git a/src/platform/nxp/mw320/DiagnosticDataProviderImpl.h b/src/platform/nxp/mw320/DiagnosticDataProviderImpl.h index 1314aaa5a64883..72501a4d944de5 100644 --- a/src/platform/nxp/mw320/DiagnosticDataProviderImpl.h +++ b/src/platform/nxp/mw320/DiagnosticDataProviderImpl.h @@ -69,7 +69,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) override; CHIP_ERROR GetWiFiBssId(ByteSpan & value) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; }; diff --git a/src/platform/silabs/DiagnosticDataProviderImpl.cpp b/src/platform/silabs/DiagnosticDataProviderImpl.cpp index 64451504c038f2..9662668c39c16d 100644 --- a/src/platform/silabs/DiagnosticDataProviderImpl.cpp +++ b/src/platform/silabs/DiagnosticDataProviderImpl.cpp @@ -376,9 +376,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) { - wifiVersion = to_underlying(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN); + wifiVersion = app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum::kN; return CHIP_NO_ERROR; } diff --git a/src/platform/silabs/DiagnosticDataProviderImpl.h b/src/platform/silabs/DiagnosticDataProviderImpl.h index bbaa8bff7dd26d..7d62cc8f84adc4 100644 --- a/src/platform/silabs/DiagnosticDataProviderImpl.h +++ b/src/platform/silabs/DiagnosticDataProviderImpl.h @@ -59,7 +59,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #if SL_WIFI CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wifiVersion) override; CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; diff --git a/src/platform/webos/ConnectivityManagerImpl.cpp b/src/platform/webos/ConnectivityManagerImpl.cpp index 32870b75c180aa..6cbefb8751eeae 100644 --- a/src/platform/webos/ConnectivityManagerImpl.cpp +++ b/src/platform/webos/ConnectivityManagerImpl.cpp @@ -1150,7 +1150,7 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiBssId(ByteSpan & value) return err; } -CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) +CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(SecurityTypeEnum & securityType) { const gchar * mode = nullptr; @@ -1201,10 +1201,11 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(app::Clusters::WiFiNetwo return CHIP_NO_ERROR; } -CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(WiFiVersionEnum & wiFiVersion) { // We don't have direct API to get the WiFi version yet, return 802.11n on Linux simulation. - wiFiVersion = to_underlying(WiFiVersionEnum::kN); + // TODO: This is not "Linux simulation". + wiFiVersion = WiFiVersionEnum::kN; return CHIP_NO_ERROR; } diff --git a/src/platform/webos/ConnectivityManagerImpl.h b/src/platform/webos/ConnectivityManagerImpl.h index 2d3b08c647282e..6d23f83d8683f0 100644 --- a/src/platform/webos/ConnectivityManagerImpl.h +++ b/src/platform/webos/ConnectivityManagerImpl.h @@ -137,7 +137,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, int32_t GetDisconnectReason(); CHIP_ERROR GetWiFiBssId(ByteSpan & value); CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType); - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion); + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion); CHIP_ERROR GetConfiguredNetwork(NetworkCommissioning::Network & network); CHIP_ERROR StartWiFiScan(ByteSpan ssid, NetworkCommissioning::WiFiDriver::ScanCallback * callback); #endif diff --git a/src/platform/webos/DiagnosticDataProviderImpl.cpp b/src/platform/webos/DiagnosticDataProviderImpl.cpp index 22790a4705849c..dc4e534f40e18c 100644 --- a/src/platform/webos/DiagnosticDataProviderImpl.cpp +++ b/src/platform/webos/DiagnosticDataProviderImpl.cpp @@ -782,7 +782,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI #if CHIP_DEVICE_CONFIG_ENABLE_WPA -CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wiFiVersion) +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) { return ConnectivityMgrImpl().GetWiFiVersion(wiFiVersion); } diff --git a/src/platform/webos/DiagnosticDataProviderImpl.h b/src/platform/webos/DiagnosticDataProviderImpl.h index ba933b8743dfbf..87a7eb6f9c1982 100644 --- a/src/platform/webos/DiagnosticDataProviderImpl.h +++ b/src/platform/webos/DiagnosticDataProviderImpl.h @@ -81,7 +81,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider #endif #if CHIP_DEVICE_CONFIG_ENABLE_WPA - CHIP_ERROR GetWiFiVersion(uint8_t & wiFiVersion) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) override; CHIP_ERROR GetWiFiBssId(ByteSpan & value) override; CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; #endif