2626#if CHIP_CONFIG_ENABLE_ICD_SERVER
2727#include < app/server/Server.h> // nogncheck
2828#endif
29- #include < app/reporting/reporting.h>
3029
3130using namespace chip ;
3231using 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+
111134DataModel::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
220249CHIP_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
229258ICDManagementClusterWithCIP::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
0 commit comments