From ab83b22902c1c8ef296e8a421db9f81220f59b58 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 13:06:21 +0000 Subject: [PATCH 01/12] fabric-bridge: Add ECOINFO to dynamic bridged endpoints --- .../fabric-bridge-common/BUILD.gn | 16 +++++++++++++++- .../src/BridgedDeviceManager.cpp | 8 ++++++++ examples/fabric-bridge-app/linux/RpcServer.cpp | 4 ++++ examples/fabric-bridge-app/linux/main.cpp | 5 ++++- .../ecosystem-information-server.cpp | 11 +++++++++++ .../ecosystem-information-server.h | 18 ++++++++++++++++++ 6 files changed, 60 insertions(+), 2 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn index 10cb48c31c584e..c05f1771a8f89a 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn +++ b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn @@ -19,12 +19,26 @@ config("config") { include_dirs = [ "include" ] } -chip_data_model("fabric-bridge-common") { +chip_data_model("fabric-bridge-common-zap") { zap_file = "fabric-bridge-app.zap" is_server = true cflags = [ "-DDYNAMIC_ENDPOINT_COUNT=16" ] } +# This is includes all the clusters that only exist on the dynamic endpoint. +source_set("fabric-bridge-common") { + public_configs = [ ":config" ] + + sources = [ + "${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp", + "${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h", + ] + + public_deps = [ + ":fabric-bridge-common-zap", + ] +} + source_set("fabric-bridge-lib") { public_configs = [ ":config" ] diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index 170b39cd2c94e2..dfd72dc0084c8d 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -91,6 +91,13 @@ DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel:: DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* feature map */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +// Declare Ecosystem Information cluster attributes +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, ATTRIBUTE_MASK_NULLABLE), /* */ + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */ + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); + // Declare Administrator Commissioning cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(AdministratorCommissioningAttrs) DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::WindowStatus::Id, ENUM8, 1, 0), /* NodeLabel */ @@ -109,6 +116,7 @@ constexpr CommandId administratorCommissioningCommands[] = { DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters) DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER), administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index 76fe8f84653d39..cc1f7945ea767a 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -20,6 +20,7 @@ #include "pw_rpc_system_server/rpc_server.h" #include "pw_rpc_system_server/socket.h" +#include #include #include @@ -62,6 +63,9 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice return pw::Status::Unknown(); } + // Ignoring the error returned. + EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId()); + return pw::OkStatus(); } diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index c708b256727520..6239d0660fe733 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -24,6 +24,7 @@ #include #include +#include #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE #include "RpcClient.h" @@ -34,8 +35,9 @@ #include #include -using namespace chip; +void MatterEcosystemInformationPluginServerInitCallback(); +using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::AdministratorCommissioning; @@ -174,6 +176,7 @@ void ApplicationInit() { ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationInit()"); + MatterEcosystemInformationPluginServerInitCallback(); CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gAdministratorCommissioningCommandHandler); #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp index 4d7f7b8ddf754e..03a7961947844d 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp @@ -251,6 +251,17 @@ EcosystemInformationServer & EcosystemInformationServer::Instance() return mInstance; } +CHIP_ERROR EcosystemInformationServer::AddEcosystemInformationClusterToEndpoint(EndpointId aEndpoint) +{ + VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT); + auto it = mDevicesMap.find(aEndpoint); + // We expect that the device has not been previously added. + VerifyOrReturnError((it == mDevicesMap.end()), CHIP_ERROR_INCORRECT_STATE); + // This create an empty DeviceInfo in mDevicesMap. + mDevicesMap[aEndpoint]; + return CHIP_NO_ERROR; +} + CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std::unique_ptr aDevice) { VerifyOrReturnError(aDevice, CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h index 58c64262166403..7f965dfb2c3ca6 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h @@ -150,6 +150,24 @@ class EcosystemInformationServer public: static EcosystemInformationServer & Instance(); + /** + * @brief Add EcosystemInformation Cluster to endpoint so we respond appropritely on endpoint + * + * EcosystemInformation cluster is only ever on dynamic bridge endpoint. If cluster is added + * to a new endpoint, but does not contain any ecosystem information information presently, + * this is called to let ECOINFO cluster code know it is supposed to provide blank attribute + * information on this endpoint. + * + * This approach was intentionally taken instead of relying on emberAfDeviceTypeListFromEndpoint + * to keep this cluster more unit testable. This does add burden to application but is worth + * the trade-off. + * + * @param[in] aEndpoint Which endpoint is the device being added to the device directory. + * @return #CHIP_NO_ERROR on success. + * @return Other CHIP_ERROR associated with issue. + */ + CHIP_ERROR AddEcosystemInformationClusterToEndpoint(EndpointId aEndpoint); + /** * @brief Adds device as entry to DeviceDirectory list Attribute. * From 76614d4d94920ded16bf7e61adfd7ff098b1a43a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 14:31:01 +0000 Subject: [PATCH 02/12] Restyled by whitespace --- .../ecosystem-information-server.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h index 7f965dfb2c3ca6..12dca9a9388211 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h @@ -152,12 +152,12 @@ class EcosystemInformationServer /** * @brief Add EcosystemInformation Cluster to endpoint so we respond appropritely on endpoint - * + * * EcosystemInformation cluster is only ever on dynamic bridge endpoint. If cluster is added * to a new endpoint, but does not contain any ecosystem information information presently, * this is called to let ECOINFO cluster code know it is supposed to provide blank attribute * information on this endpoint. - * + * * This approach was intentionally taken instead of relying on emberAfDeviceTypeListFromEndpoint * to keep this cluster more unit testable. This does add burden to application but is worth * the trade-off. From 2862392e52802673c1add691922cd1822bad4e9f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 14:31:01 +0000 Subject: [PATCH 03/12] Restyled by clang-format --- .../fabric-bridge-common/src/BridgedDeviceManager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index dfd72dc0084c8d..1392e0d9a6bf2c 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -93,9 +93,12 @@ DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel:: // Declare Ecosystem Information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, ATTRIBUTE_MASK_NULLABLE), /* */ - DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */ - DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */ +DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, + ATTRIBUTE_MASK_NULLABLE), /* */ + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* */ + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Administrator Commissioning cluster attributes From 8892df1985afad11f69d88ed640d870a3e3b89d0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 14:31:02 +0000 Subject: [PATCH 04/12] Restyled by gn --- examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn index c05f1771a8f89a..2a94bc02b2489b 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn +++ b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn @@ -34,9 +34,7 @@ source_set("fabric-bridge-common") { "${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h", ] - public_deps = [ - ":fabric-bridge-common-zap", - ] + public_deps = [ ":fabric-bridge-common-zap" ] } source_set("fabric-bridge-lib") { From 3248e23dc4ca567d20eed3be0b60838ddedfb8c1 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 11:06:43 -0400 Subject: [PATCH 05/12] Update examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn Co-authored-by: saurabhst --- examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn index 2a94bc02b2489b..40e9bec73b7e97 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn +++ b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn @@ -25,7 +25,7 @@ chip_data_model("fabric-bridge-common-zap") { cflags = [ "-DDYNAMIC_ENDPOINT_COUNT=16" ] } -# This is includes all the clusters that only exist on the dynamic endpoint. +# This includes all the clusters that only exist on the dynamic endpoint. source_set("fabric-bridge-common") { public_configs = [ ":config" ] From e062ec4dd0f32f5ea254a1ac3cd0db8bf9b4bc54 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 15:19:07 +0000 Subject: [PATCH 06/12] Remove blank comments --- .../fabric-bridge-common/src/BridgedDeviceManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index 1392e0d9a6bf2c..cc07e531cb1f9b 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -94,11 +94,11 @@ DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel:: // Declare Ecosystem Information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs) DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, - ATTRIBUTE_MASK_NULLABLE), /* */ + ATTRIBUTE_MASK_NULLABLE), DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, - 0), /* */ + 0), DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, - 0), /* */ + 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Administrator Commissioning cluster attributes From cddfbf568f11ae279c45acefd39db893b95a7dc8 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 15:20:31 +0000 Subject: [PATCH 07/12] Address PR comments --- .../ecosystem-information-server.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h index 12dca9a9388211..22916df672e256 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h @@ -151,10 +151,10 @@ class EcosystemInformationServer static EcosystemInformationServer & Instance(); /** - * @brief Add EcosystemInformation Cluster to endpoint so we respond appropritely on endpoint + * @brief Add EcosystemInformation Cluster to endpoint so we respond appropriately on endpoint * * EcosystemInformation cluster is only ever on dynamic bridge endpoint. If cluster is added - * to a new endpoint, but does not contain any ecosystem information information presently, + * to a new endpoint, but does not contain any ecosystem information presently, * this is called to let ECOINFO cluster code know it is supposed to provide blank attribute * information on this endpoint. * From 694b38cfc64aa0ab0f785f3dff7adde17e6a06b3 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 15:20:57 +0000 Subject: [PATCH 08/12] Restyled by clang-format --- .../fabric-bridge-common/src/BridgedDeviceManager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index cc07e531cb1f9b..4c55da82fa4c78 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -93,12 +93,9 @@ DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel:: // Declare Ecosystem Information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, - ATTRIBUTE_MASK_NULLABLE), - DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, - 0), - DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, - 0), +DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, ATTRIBUTE_MASK_NULLABLE), + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), + DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Administrator Commissioning cluster attributes From 1e60feed6fd43ab1ed2afccf656934952e266652 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 21:02:28 +0000 Subject: [PATCH 09/12] AddressPR comments --- examples/fabric-bridge-app/linux/RpcServer.cpp | 4 ++-- .../ecosystem-information-server.cpp | 2 +- .../ecosystem-information-server.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index cc1f7945ea767a..af5a8713311259 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -63,8 +63,8 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice return pw::Status::Unknown(); } - // Ignoring the error returned. - EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId()); + CHIP_ERROR err = EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId()); + VerifyOrDie(err == CHIP_NO_ERROR); return pw::OkStatus(); } diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp index 03a7961947844d..db528a3c115907 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp @@ -267,7 +267,7 @@ CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std:: VerifyOrReturnError(aDevice, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT); - auto & deviceInfo = mDevicesMap[aEndpoint]; + auto & deviceInfo = mDevicesMap[aEndpoint] = DeviceInfo(); VerifyOrReturnError((deviceInfo.mDeviceDirectory.size() < kDeviceDirectoryMaxSize), CHIP_ERROR_NO_MEMORY); deviceInfo.mDeviceDirectory.push_back(std::move(aDevice)); return CHIP_NO_ERROR; diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h index 22916df672e256..14f5513d5d3d8c 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h @@ -207,7 +207,7 @@ class EcosystemInformationServer private: struct DeviceInfo { - Optional mRemovedOn; + Optional mRemovedOn = NullOptional; std::vector> mDeviceDirectory; // Map key is using the UniqueLocationId std::map> mLocationDirectory; From bc7d850c3ba9ea2beaa91b86b817cdbc357e0582 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 6 Aug 2024 21:11:38 +0000 Subject: [PATCH 10/12] Fix mistake made when addressing PR comment --- .../ecosystem-information-server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp index db528a3c115907..2b78b4f54e6fae 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp @@ -258,7 +258,7 @@ CHIP_ERROR EcosystemInformationServer::AddEcosystemInformationClusterToEndpoint( // We expect that the device has not been previously added. VerifyOrReturnError((it == mDevicesMap.end()), CHIP_ERROR_INCORRECT_STATE); // This create an empty DeviceInfo in mDevicesMap. - mDevicesMap[aEndpoint]; + mDevicesMap[aEndpoint] = DeviceInfo(); return CHIP_NO_ERROR; } @@ -267,7 +267,7 @@ CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std:: VerifyOrReturnError(aDevice, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT); - auto & deviceInfo = mDevicesMap[aEndpoint] = DeviceInfo(); + auto & deviceInfo = mDevicesMap[aEndpoint]; VerifyOrReturnError((deviceInfo.mDeviceDirectory.size() < kDeviceDirectoryMaxSize), CHIP_ERROR_NO_MEMORY); deviceInfo.mDeviceDirectory.push_back(std::move(aDevice)); return CHIP_NO_ERROR; From 537df99b76142bf3403d80f117092e1ea64a8cd7 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 6 Aug 2024 21:13:45 +0000 Subject: [PATCH 11/12] Restyled by clang-format --- examples/fabric-bridge-app/linux/RpcServer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index af5a8713311259..a4053bea9f6a56 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -63,7 +63,8 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice return pw::Status::Unknown(); } - CHIP_ERROR err = EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId()); + CHIP_ERROR err = EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint( + device->GetEndpointId()); VerifyOrDie(err == CHIP_NO_ERROR); return pw::OkStatus(); From 17e2c84b7fd2f274abe68a1389317bac0fddec32 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 13:47:43 +0000 Subject: [PATCH 12/12] Added comment to describe why something was done the way it was --- examples/fabric-bridge-app/linux/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index 6239d0660fe733..8d8df3b96a4ed9 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -35,6 +35,12 @@ #include #include +// This is declared here and not in a header because zap/embr assumes all clusters +// are defined in a static endpoint in the .zap file. From there, the codegen will +// automatically use PluginApplicationCallbacksHeader.jinja to declare and call +// the respective Init callbacks. However, because EcosystemInformation cluster is only +// ever on a dynamic endpoint, this doesn't get declared and called for us, so we +// need to declare and call it ourselves where the application is initialized. void MatterEcosystemInformationPluginServerInitCallback(); using namespace chip;