Skip to content

Commit 94c3562

Browse files
Rebase
1 parent d275210 commit 94c3562

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

src/app/clusters/icd-management-server/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ source_set("icd-management-server") {
2424
public_deps = [
2525
"${chip_root}/src/app/icd/server:configuration-data",
2626
"${chip_root}/src/app/icd/server:icd-server-config",
27+
"${chip_root}/src/app/icd/server:observer",
2728
"${chip_root}/src/app/server-cluster",
2829
]
2930
if (chip_enable_icd_server) {

src/app/clusters/icd-management-server/ICDManagementCluster.cpp

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#if CHIP_CONFIG_ENABLE_ICD_SERVER
2727
#include <app/server/Server.h> // nogncheck
2828
#endif
29-
#include <app/reporting/reporting.h>
3029

3130
using namespace chip;
3231
using namespace chip::app;
@@ -108,6 +107,30 @@ ICDManagementCluster::ICDManagementCluster(EndpointId endpointId, Crypto::Symmet
108107
mUserActiveModeTriggerInstructionLength = static_cast<uint8_t>(buffer.size());
109108
}
110109

110+
CHIP_ERROR ICDManagementCluster::Startup(ServerClusterContext & context)
111+
{
112+
ReturnErrorOnFailure(DefaultServerCluster::Startup(context));
113+
// TODO(#32321): Remove #if after issue is resolved
114+
// Note: We only need this #if statement for platform examples that enable the ICD management server without building the sample
115+
// as an ICD. Since this is not spec compliant, we should remove this #if statement once we stop compiling the ICD management
116+
// server in those examples.
117+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
118+
Server::GetInstance().GetICDManager().RegisterObserver(this);
119+
#endif
120+
return CHIP_NO_ERROR;
121+
}
122+
123+
void ICDManagementCluster::Shutdown()
124+
{
125+
// TODO(#32321): Remove #if after issue is resolved
126+
// Note: We only need this #if statement for platform examples that enable the ICD management server without building the sample
127+
// as an ICD. Since this is not spec compliant, we should remove this #if statement once we stop compiling the ICD management
128+
// server in those examples.
129+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
130+
Server::GetInstance().GetICDManager().ReleaseObserver(this);
131+
#endif
132+
}
133+
111134
DataModel::ActionReturnStatus ICDManagementCluster::ReadAttribute(const DataModel::ReadAttributeRequest & request,
112135
AttributeValueEncoder & aEncoder)
113136
{
@@ -216,6 +239,12 @@ CHIP_ERROR ICDManagementCluster::GeneratedCommands(const ConcreteClusterPath & p
216239
return CHIP_NO_ERROR;
217240
}
218241

242+
void ICDManagementCluster::OnICDModeChange()
243+
{
244+
// Notify attribute change for OperatingMode attribute
245+
NotifyAttributeChanged(IcdManagement::Attributes::OperatingMode::Id);
246+
}
247+
219248
#if CHIP_CONFIG_ENABLE_ICD_LIT
220249
CHIP_ERROR ICDManagementCluster::ReadOperatingMode(AttributeValueEncoder & encoder)
221250
{
@@ -224,8 +253,8 @@ CHIP_ERROR ICDManagementCluster::ReadOperatingMode(AttributeValueEncoder & encod
224253
: encoder.Encode(IcdManagement::OperatingModeEnum::kLit);
225254
}
226255
#endif // CHIP_CONFIG_ENABLE_ICD_LIT
227-
#if CHIP_CONFIG_ENABLE_ICD_CIP
228256

257+
#if CHIP_CONFIG_ENABLE_ICD_CIP
229258
ICDManagementClusterWithCIP::ICDManagementClusterWithCIP(
230259
EndpointId endpointId, Crypto::SymmetricKeystore & symmetricKeystore, FabricTable & fabricTable,
231260
ICDConfigurationData & icdConfigurationData, OptionalAttributeSet optionalAttributeSet,
@@ -488,8 +517,8 @@ Status ICDManagementClusterWithCIP::RegisterClient(CommandHandler * commandObj,
488517
// Notify subscribers that the first entry for the fabric was successfully added
489518
TriggerICDMTableUpdatedEvent();
490519
}
491-
MatterReportingAttributeChangeCallback(kRootEndpointId, IcdManagement::Id, IcdManagement::Attributes::RegisteredClients::Id);
492-
icdCounter = mICDConfigurationData->GetICDCounter().GetValue();
520+
MarkRegisteredClientsListChanged();
521+
icdCounter = mICDConfigurationData.GetICDCounter().GetValue();
493522

494523
return Status::Success;
495524
}
@@ -529,16 +558,14 @@ Status ICDManagementClusterWithCIP::UnregisterClient(CommandHandler * commandObj
529558
TriggerICDMTableUpdatedEvent();
530559
}
531560

532-
MatterReportingAttributeChangeCallback(kRootEndpointId, IcdManagement::Id, IcdManagement::Attributes::RegisteredClients::Id);
561+
MarkRegisteredClientsListChanged();
533562
return Status::Success;
534563
}
535564

536-
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
537-
538-
void ICDManagementServer::OnICDModeChange()
565+
void ICDManagementClusterWithCIP::MarkRegisteredClientsListChanged()
539566
{
540-
// Notify attribute change for OperatingMode attribute
541-
MatterReportingAttributeChangeCallback(kRootEndpointId, IcdManagement::Id, IcdManagement::Attributes::OperatingMode::Id);
567+
NotifyAttributeChanged(IcdManagement::Attributes::RegisteredClients::Id);
542568
}
569+
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
543570

544571
} // namespace chip::app::Clusters

src/app/clusters/icd-management-server/ICDManagementCluster.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ class ICDManagementCluster : public DefaultServerCluster, public chip::app::ICDS
8585
BitMask<IcdManagement::UserActiveModeTriggerBitmap> userActiveModeTriggerBitmap,
8686
CharSpan userActiveModeTriggerInstruction);
8787

88+
CHIP_ERROR Startup(ServerClusterContext & context) override;
89+
void Shutdown() override;
90+
8891
DataModel::ActionReturnStatus ReadAttribute(const DataModel::ReadAttributeRequest & request,
8992
AttributeValueEncoder & aEncoder) override;
9093
CHIP_ERROR Attributes(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<DataModel::AttributeEntry> & builder) override;
@@ -174,6 +177,8 @@ class ICDManagementClusterWithCIP : public ICDManagementCluster
174177
CHIP_ERROR GeneratedCommands(const ConcreteClusterPath & path, ReadOnlyBufferBuilder<CommandId> & builder) override;
175178

176179
private:
180+
void MarkRegisteredClientsListChanged();
181+
177182
CHIP_ERROR ReadRegisteredClients(AttributeValueEncoder & encoder);
178183

179184
/**

src/app/clusters/icd-management-server/tests/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ chip_test_suite("tests") {
2828
"${chip_root}/src/app/clusters/icd-management-server",
2929
"${chip_root}/src/app/clusters/testing",
3030
"${chip_root}/src/app/icd/server:configuration-data",
31+
"${chip_root}/src/app/icd/server:observer",
3132
"${chip_root}/src/credentials",
3233
"${chip_root}/src/crypto",
3334
"${chip_root}/src/lib/core:string-builder-adapters",

0 commit comments

Comments
 (0)