Skip to content

Commit

Permalink
Update api to check for featuremap bit of the ICD cluster. Check for …
Browse files Browse the repository at this point in the history
…LongIdleTimeSupport to advertise ICD common key
  • Loading branch information
jmartinez-silabs committed Oct 31, 2023
1 parent 42799f2 commit 49a444a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/app/icd/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ void ICDManager::Shutdown()
mFabricTable = nullptr;
}

bool ICDManager::SupportsCheckInProtocol()
bool ICDManager::SupportsFeature(Feature feature)
{
bool success = false;
uint32_t featureMap = 0;
// Can't use attribute accessors/Attributes::FeatureMap::Get in unit tests
#ifndef CONFIG_BUILD_FOR_HOST_UNIT_TEST
success = (Attributes::FeatureMap::Get(kRootEndpointId, &featureMap) == EMBER_ZCL_STATUS_SUCCESS);
#endif
return success ? ((featureMap & to_underlying(Feature::kCheckInProtocolSupport)) != 0) : false;
return success ? ((featureMap & to_underlying(feature)) != 0) : false;
}

void ICDManager::UpdateICDMode()
Expand All @@ -101,7 +101,8 @@ void ICDManager::UpdateICDMode()

// The Check In Protocol Feature is required and the slow polling interval shall also be greater than 15 seconds
// to run an ICD in LIT mode.
if (GetSlowPollingInterval() > GetSITPollingThreshold() && SupportsCheckInProtocol())
if (GetSlowPollingInterval() > GetSITPollingThreshold() && SupportsFeature(Feature::kCheckInProtocolSupport) &&
SupportsFeature(Feature::kLongIdleTimeSupport))
{
VerifyOrDie(mStorage != nullptr);
VerifyOrDie(mFabricTable != nullptr);
Expand Down
3 changes: 2 additions & 1 deletion src/app/icd/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
#pragma once

#include <app-common/zap-generated/cluster-enums.h>
#include <app/icd/ICDMonitoringTable.h>
#include <app/icd/ICDNotifier.h>
#include <app/icd/ICDStateObserver.h>
Expand Down Expand Up @@ -58,7 +59,7 @@ class ICDManager : public ICDListener
void UpdateOperationState(OperationalState state);
void SetKeepActiveModeRequirements(KeepActiveFlags flag, bool state);
bool IsKeepActive() { return mKeepActiveFlags.HasAny(); }
bool SupportsCheckInProtocol();
bool SupportsFeature(Clusters::IcdManagement::Feature feature);
ICDMode GetICDMode() { return mICDMode; }
OperationalState GetOperationalState() { return mOperationalState; }

Expand Down
6 changes: 3 additions & 3 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include <app/server/Dnssd.h>

#include <app-common/zap-generated/cluster-enums.h>
#include <inttypes.h>

#include <lib/core/Optional.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/dnssd/ServiceNaming.h>
Expand Down Expand Up @@ -176,7 +176,7 @@ CHIP_ERROR DnssdServer::AdvertiseOperational()

#if CHIP_CONFIG_ENABLE_ICD_SERVER
// Only advertise the ICD key if the device can be operate as LIT
if (Server::GetInstance().GetICDManager().SupportsCheckInProtocol())
if (Server::GetInstance().GetICDManager().SupportsFeature(Clusters::IcdManagement::Feature::kLongIdleTimeSupport))
{
advertiseParameters.SetICDOperatesAsLIT(
Optional<bool>(Server::GetInstance().GetICDManager().GetICDMode() == ICDManager::ICDMode::LIT));
Expand Down Expand Up @@ -254,7 +254,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi

#if CHIP_CONFIG_ENABLE_ICD_SERVER
// Only advertise the ICD key if the device can be operate as LIT
if (Server::GetInstance().GetICDManager().SupportsCheckInProtocol())
if (Server::GetInstance().GetICDManager().SupportsFeature(Clusters::IcdManagement::Feature::kLongIdleTimeSupport))
{
advertiseParameters.SetICDOperatesAsLIT(
Optional<bool>(Server::GetInstance().GetICDManager().GetICDMode() == ICDManager::ICDMode::LIT));
Expand Down

0 comments on commit 49a444a

Please sign in to comment.