From dc22e579a26b7d16f8c38d1c93717c245077bd01 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 30 Jun 2022 00:27:16 +0530 Subject: [PATCH 1/4] added wifinetworkdiagnostics implementation for rs911x --- .../EFR32/DiagnosticDataProviderImpl.cpp | 129 ++++++++++++++++++ .../EFR32/DiagnosticDataProviderImpl.h | 16 +++ third_party/silabs/matter_support | 2 +- third_party/silabs/wiseconnect-wifi-bt-sdk | 2 +- 4 files changed, 147 insertions(+), 2 deletions(-) diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index 98602518c8195a..3fefc2488d6401 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -341,5 +341,134 @@ void DiagnosticDataProviderImpl::ReleaseNetworkInterfaces(NetworkInterface * net } } +#if SL_WIFI +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) +{ + wfx_wifi_scan_result_t ap; + int32_t err = wfx_get_ap_info(&ap); + if(err == 0){ + BssId = ByteSpan(ap.bssid,6); + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityType) +{ + wfx_wifi_scan_result_t ap; + int32_t err = wfx_get_ap_info(&ap); + if(err == 0){ + securityType = ap.security; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(uint8_t & wifiVersion) +{ + wifiVersion = EMBER_ZCL_WI_FI_VERSION_TYPE_802__11N; + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) +{ + wfx_wifi_scan_result_t ap; + int32_t err = wfx_get_ap_info(&ap); + if(err == 0){ + channelNumber = ap.chan; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) +{ + wfx_wifi_scan_result_t ap; + int32_t err = wfx_get_ap_info(&ap); + if(err == 0){ + rssi = ap.rssi; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + beaconLostCount = extra_info.beacon_lost_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + packetMulticastRxCount = extra_info.mcast_rx_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + packetMulticastTxCount = extra_info.mcast_tx_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + packetUnicastRxCount = extra_info.ucast_rx_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + packetUnicastTxCount = extra_info.ucast_tx_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCount) +{ + wfx_wifi_scan_ext_t extra_info; + int32_t err = wfx_get_ap_ext(&extra_info); + if(err ==0){ + overrunCount = extra_info.overrun_count; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() +{ + return CHIP_NO_ERROR; +} +#endif // SL_WIFI + + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.h b/src/platform/EFR32/DiagnosticDataProviderImpl.h index f0cee8888f44bc..b2ca59f257231e 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.h +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.h @@ -55,6 +55,22 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetActiveNetworkFaults(GeneralFaults & networkFaults) override; CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; + + #if SL_WIFI + CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; + CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType) override; + CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; + CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; + CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; + CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; + CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; + CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; + #endif // SL_WIFI }; } // namespace DeviceLayer diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index ff9000cd65c5eb..29cf6063c1aaa6 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit ff9000cd65c5ebc04818e513cb3f803d3536a718 +Subproject commit 29cf6063c1aaa64994d08e94a49a0eef40c2c703 diff --git a/third_party/silabs/wiseconnect-wifi-bt-sdk b/third_party/silabs/wiseconnect-wifi-bt-sdk index 4491826e48bfaa..d0b93569fab142 160000 --- a/third_party/silabs/wiseconnect-wifi-bt-sdk +++ b/third_party/silabs/wiseconnect-wifi-bt-sdk @@ -1 +1 @@ -Subproject commit 4491826e48bfaaa6ce4d42ad5769d7f6447b8cbb +Subproject commit d0b93569fab1420e1d26d418f30564c198571abc From 9e881a64568073cb3cd51573403ca2797fb15f2a Mon Sep 17 00:00:00 2001 From: rosahay-silabs Date: Thu, 30 Jun 2022 03:16:26 +0530 Subject: [PATCH 2/4] Restyled files --- .../EFR32/DiagnosticDataProviderImpl.cpp | 39 ++++++++++++------- .../EFR32/DiagnosticDataProviderImpl.h | 30 +++++++------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index 3fefc2488d6401..9c2aa73c91ffe3 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -346,8 +346,9 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) { wfx_wifi_scan_result_t ap; int32_t err = wfx_get_ap_info(&ap); - if(err == 0){ - BssId = ByteSpan(ap.bssid,6); + if (err == 0) + { + BssId = ByteSpan(ap.bssid, 6); return CHIP_NO_ERROR; } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; @@ -357,7 +358,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityTyp { wfx_wifi_scan_result_t ap; int32_t err = wfx_get_ap_info(&ap); - if(err == 0){ + if (err == 0) + { securityType = ap.security; return CHIP_NO_ERROR; } @@ -374,7 +376,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNu { wfx_wifi_scan_result_t ap; int32_t err = wfx_get_ap_info(&ap); - if(err == 0){ + if (err == 0) + { channelNumber = ap.chan; return CHIP_NO_ERROR; } @@ -385,7 +388,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) { wfx_wifi_scan_result_t ap; int32_t err = wfx_get_ap_info(&ap); - if(err == 0){ + if (err == 0) + { rssi = ap.rssi; return CHIP_NO_ERROR; } @@ -396,7 +400,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconL { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { beaconLostCount = extra_info.beacon_lost_count; return CHIP_NO_ERROR; } @@ -412,7 +417,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { packetMulticastRxCount = extra_info.mcast_rx_count; return CHIP_NO_ERROR; } @@ -423,7 +429,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { packetMulticastTxCount = extra_info.mcast_tx_count; return CHIP_NO_ERROR; } @@ -434,10 +441,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & pa { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { packetUnicastRxCount = extra_info.ucast_rx_count; return CHIP_NO_ERROR; - } + } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } @@ -445,10 +453,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & pa { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { packetUnicastTxCount = extra_info.ucast_tx_count; return CHIP_NO_ERROR; - } + } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } @@ -456,10 +465,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCou { wfx_wifi_scan_ext_t extra_info; int32_t err = wfx_get_ap_ext(&extra_info); - if(err ==0){ + if (err == 0) + { overrunCount = extra_info.overrun_count; return CHIP_NO_ERROR; - } + } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } @@ -469,6 +479,5 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() } #endif // SL_WIFI - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.h b/src/platform/EFR32/DiagnosticDataProviderImpl.h index b2ca59f257231e..7a9ce7c95577dd 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.h +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.h @@ -56,21 +56,21 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; - #if SL_WIFI - CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; - CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType) override; - CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; - CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; - CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; - CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; - CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; - CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; - CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; - CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; - CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; - CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; - CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; - #endif // SL_WIFI +#if SL_WIFI + CHIP_ERROR GetWiFiBssId(ByteSpan & BssId) override; + CHIP_ERROR GetWiFiSecurityType(uint8_t & securityType) override; + CHIP_ERROR GetWiFiVersion(uint8_t & wifiVersion) override; + CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; + CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; + CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; + CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; + CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; + CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; +#endif // SL_WIFI }; } // namespace DeviceLayer From d9893c8c6291edbe4e7e304779a70316efbe0388 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Fri, 1 Jul 2022 04:39:46 +0530 Subject: [PATCH 3/4] resolving comments, issue with handing out the pointer(ap.bssid) and using an array --- src/platform/EFR32/DiagnosticDataProviderImpl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index 9c2aa73c91ffe3..bee1951f916b7c 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -346,9 +346,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) { wfx_wifi_scan_result_t ap; int32_t err = wfx_get_ap_info(&ap); + static uint8_t bssid[6]; if (err == 0) { - BssId = ByteSpan(ap.bssid, 6); + memcpy(bssid,ap.bssid,6); + BssId = ByteSpan(bssid, 6); return CHIP_NO_ERROR; } return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; From 9e4389f48307a286fa3a0875995bf26334c4061c Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Fri, 1 Jul 2022 04:52:44 +0530 Subject: [PATCH 4/4] Restyled files --- src/platform/EFR32/DiagnosticDataProviderImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp index bee1951f916b7c..598e2ca1255662 100644 --- a/src/platform/EFR32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/EFR32/DiagnosticDataProviderImpl.cpp @@ -349,7 +349,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId) static uint8_t bssid[6]; if (err == 0) { - memcpy(bssid,ap.bssid,6); + memcpy(bssid, ap.bssid, 6); BssId = ByteSpan(bssid, 6); return CHIP_NO_ERROR; }