From c482ef1c5bc4e820557b8da2e9f9ca2ab8e2096b Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:10:22 +0800 Subject: [PATCH 1/3] [DGSW] Add SupportsWatermarks method that returns true - Also fixes feature-map, kWaterMarks bit will be set --- src/platform/Ameba/DiagnosticDataProviderImpl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.h b/src/platform/Ameba/DiagnosticDataProviderImpl.h index ae060e037c15b9..d6c062fdbf0812 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.h +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.h @@ -37,6 +37,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider // ===== Methods that implement the PlatformManager abstract interface. + bool SupportsWatermarks() override { return true; } CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; From 0de30141462260b83670d07044740b02240dc19c Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Sat, 23 Apr 2022 12:10:12 +0800 Subject: [PATCH 2/3] [DGWiFi] Handle WiFi-Diagnostics events - After receiving WiFi-Diagnostic events, call WiFiDiagnosticsDelegate functions --- .../Ameba/ConnectivityManagerImpl.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/platform/Ameba/ConnectivityManagerImpl.cpp b/src/platform/Ameba/ConnectivityManagerImpl.cpp index ce2ff544c66d34..6b28a01f0b37ec 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.cpp +++ b/src/platform/Ameba/ConnectivityManagerImpl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -584,6 +585,12 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; PlatformMgr().PostEventOrDie(&event); + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + + if (delegate) + { + delegate->OnConnectionStatusChanged(chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kConnected)); + } UpdateInternetConnectivityState(); } @@ -595,6 +602,42 @@ void ConnectivityManagerImpl::OnStationDisconnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; PlatformMgr().PostEventOrDie(&event); + WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); + uint16_t reason = NetworkCommissioning::AmebaWiFiDriver::GetInstance().GetLastDisconnectReason(); + uint8_t associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kUnknown); + + if (delegate) + { + switch (reason) + { + case RTW_NO_ERROR: + case RTW_NONE_NETWORK: + associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kSsidNotFound); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; + case RTW_CONNECT_FAIL: + associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAssociationFailed); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; + case RTW_WRONG_PASSWORD: + associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAuthenticationFailed); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; +#if defined(CONFIG_PLATFORM_8710C) + case RTW_4WAY_HANDSHAKE_TIMEOUT: +#endif + case RTW_DHCP_FAIL: + case RTW_UNKNOWN: + break; + + default: + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; + } + delegate->OnDisconnectionDetected(reason); + delegate->OnConnectionStatusChanged(chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kNotConnected)); + } + UpdateInternetConnectivityState(); } From 6fa071d63543c48dc8ac949c6b02369098f8a4f0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 21 Jun 2022 08:51:10 +0000 Subject: [PATCH 3/3] Restyled by clang-format --- .../Ameba/ConnectivityManagerImpl.cpp | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/src/platform/Ameba/ConnectivityManagerImpl.cpp b/src/platform/Ameba/ConnectivityManagerImpl.cpp index 6b28a01f0b37ec..8c4ede5aaa05b9 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.cpp +++ b/src/platform/Ameba/ConnectivityManagerImpl.cpp @@ -34,8 +34,8 @@ #include #include -#include #include +#include #include #include @@ -589,7 +589,8 @@ void ConnectivityManagerImpl::OnStationConnected() if (delegate) { - delegate->OnConnectionStatusChanged(chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kConnected)); + delegate->OnConnectionStatusChanged( + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kConnected)); } UpdateInternetConnectivityState(); @@ -603,42 +604,46 @@ void ConnectivityManagerImpl::OnStationDisconnected() event.WiFiConnectivityChange.Result = kConnectivity_Lost; PlatformMgr().PostEventOrDie(&event); WiFiDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetWiFiDiagnosticsDelegate(); - uint16_t reason = NetworkCommissioning::AmebaWiFiDriver::GetInstance().GetLastDisconnectReason(); - uint8_t associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kUnknown); + uint16_t reason = NetworkCommissioning::AmebaWiFiDriver::GetInstance().GetLastDisconnectReason(); + uint8_t associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kUnknown); if (delegate) { switch (reason) { - case RTW_NO_ERROR: - case RTW_NONE_NETWORK: - associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kSsidNotFound); - delegate->OnAssociationFailureDetected(associationFailureCause, reason); - break; - case RTW_CONNECT_FAIL: - associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAssociationFailed); - delegate->OnAssociationFailureDetected(associationFailureCause, reason); - break; - case RTW_WRONG_PASSWORD: - associationFailureCause = chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAuthenticationFailed); - delegate->OnAssociationFailureDetected(associationFailureCause, reason); - break; + case RTW_NO_ERROR: + case RTW_NONE_NETWORK: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kSsidNotFound); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; + case RTW_CONNECT_FAIL: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAssociationFailed); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; + case RTW_WRONG_PASSWORD: + associationFailureCause = + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::AssociationFailureCause::kAuthenticationFailed); + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; #if defined(CONFIG_PLATFORM_8710C) - case RTW_4WAY_HANDSHAKE_TIMEOUT: + case RTW_4WAY_HANDSHAKE_TIMEOUT: #endif - case RTW_DHCP_FAIL: - case RTW_UNKNOWN: - break; + case RTW_DHCP_FAIL: + case RTW_UNKNOWN: + break; - default: - delegate->OnAssociationFailureDetected(associationFailureCause, reason); - break; + default: + delegate->OnAssociationFailureDetected(associationFailureCause, reason); + break; } delegate->OnDisconnectionDetected(reason); - delegate->OnConnectionStatusChanged(chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kNotConnected)); + delegate->OnConnectionStatusChanged( + chip::to_underlying(chip::app::Clusters::WiFiNetworkDiagnostics::WiFiConnectionStatus::kNotConnected)); } - UpdateInternetConnectivityState(); }