Skip to content

Commit

Permalink
[Ameba] Handle WiFi-Diagnostic events and add SupportsWatermarks (#19795
Browse files Browse the repository at this point in the history
)

* [DGSW] Add SupportsWatermarks method that returns true
- Also fixes feature-map, kWaterMarks bit  will be set

* [DGWiFi] Handle WiFi-Diagnostics events
- After receiving WiFi-Diagnostic events, call WiFiDiagnosticsDelegate functions

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jul 2, 2022
1 parent 9d672b2 commit a0ea238
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
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

0 comments on commit a0ea238

Please sign in to comment.