Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle [Ameba] Handle WiFi-Diagnostic events and add SupportsWatermarks #19796

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/platform/Ameba/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <platform/Ameba/AmebaUtils.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/DiagnosticDataProvider.h>
#include <platform/internal/BLEManager.h>
#include <support/CodeUtils.h>
#include <support/logging/CHIPLogging.h>
Expand Down Expand Up @@ -584,6 +585,13 @@ 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();
}
Expand All @@ -595,6 +603,46 @@ 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();
}
Expand Down
1 change: 1 addition & 0 deletions src/platform/Ameba/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down