Skip to content

Commit ab83b22

Browse files
committed
fabric-bridge: Add ECOINFO to dynamic bridged endpoints
1 parent 7d9a332 commit ab83b22

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-2
lines changed

examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,26 @@ config("config") {
1919
include_dirs = [ "include" ]
2020
}
2121

22-
chip_data_model("fabric-bridge-common") {
22+
chip_data_model("fabric-bridge-common-zap") {
2323
zap_file = "fabric-bridge-app.zap"
2424
is_server = true
2525
cflags = [ "-DDYNAMIC_ENDPOINT_COUNT=16" ]
2626
}
2727

28+
# This is includes all the clusters that only exist on the dynamic endpoint.
29+
source_set("fabric-bridge-common") {
30+
public_configs = [ ":config" ]
31+
32+
sources = [
33+
"${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp",
34+
"${chip_root}/src/app/clusters/ecosystem-information-server/ecosystem-information-server.h",
35+
]
36+
37+
public_deps = [
38+
":fabric-bridge-common-zap",
39+
]
40+
}
41+
2842
source_set("fabric-bridge-lib") {
2943
public_configs = [ ":config" ]
3044

examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel::
9191
DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* feature map */
9292
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
9393

94+
// Declare Ecosystem Information cluster attributes
95+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(ecosystemInformationBasicAttrs)
96+
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::RemovedOn::Id, EPOCH_US, kNodeLabelSize, ATTRIBUTE_MASK_NULLABLE), /* */
97+
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::DeviceDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */
98+
DECLARE_DYNAMIC_ATTRIBUTE(EcosystemInformation::Attributes::LocationDirectory::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* */
99+
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
100+
94101
// Declare Administrator Commissioning cluster attributes
95102
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(AdministratorCommissioningAttrs)
96103
DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::WindowStatus::Id, ENUM8, 1, 0), /* NodeLabel */
@@ -109,6 +116,7 @@ constexpr CommandId administratorCommissioningCommands[] = {
109116
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters)
110117
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
111118
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
119+
DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
112120
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
113121
administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;
114122

examples/fabric-bridge-app/linux/RpcServer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "pw_rpc_system_server/rpc_server.h"
2121
#include "pw_rpc_system_server/socket.h"
2222

23+
#include <app/clusters/ecosystem-information-server/ecosystem-information-server.h>
2324
#include <lib/core/CHIPError.h>
2425

2526
#include <string>
@@ -62,6 +63,9 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice
6263
return pw::Status::Unknown();
6364
}
6465

66+
// Ignoring the error returned.
67+
EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId());
68+
6569
return pw::OkStatus();
6670
}
6771

examples/fabric-bridge-app/linux/main.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <app/AttributeAccessInterfaceRegistry.h>
2626
#include <app/CommandHandlerInterfaceRegistry.h>
27+
#include <app/clusters/ecosystem-information-server/ecosystem-information-server.h>
2728

2829
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
2930
#include "RpcClient.h"
@@ -34,8 +35,9 @@
3435
#include <sys/ioctl.h>
3536
#include <thread>
3637

37-
using namespace chip;
38+
void MatterEcosystemInformationPluginServerInitCallback();
3839

40+
using namespace chip;
3941
using namespace chip::app;
4042
using namespace chip::app::Clusters;
4143
using namespace chip::app::Clusters::AdministratorCommissioning;
@@ -174,6 +176,7 @@ void ApplicationInit()
174176
{
175177
ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationInit()");
176178

179+
MatterEcosystemInformationPluginServerInitCallback();
177180
CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gAdministratorCommissioningCommandHandler);
178181

179182
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE

src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ EcosystemInformationServer & EcosystemInformationServer::Instance()
251251
return mInstance;
252252
}
253253

254+
CHIP_ERROR EcosystemInformationServer::AddEcosystemInformationClusterToEndpoint(EndpointId aEndpoint)
255+
{
256+
VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT);
257+
auto it = mDevicesMap.find(aEndpoint);
258+
// We expect that the device has not been previously added.
259+
VerifyOrReturnError((it == mDevicesMap.end()), CHIP_ERROR_INCORRECT_STATE);
260+
// This create an empty DeviceInfo in mDevicesMap.
261+
mDevicesMap[aEndpoint];
262+
return CHIP_NO_ERROR;
263+
}
264+
254265
CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std::unique_ptr<EcosystemDeviceStruct> aDevice)
255266
{
256267
VerifyOrReturnError(aDevice, CHIP_ERROR_INVALID_ARGUMENT);

src/app/clusters/ecosystem-information-server/ecosystem-information-server.h

+18
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@ class EcosystemInformationServer
150150
public:
151151
static EcosystemInformationServer & Instance();
152152

153+
/**
154+
* @brief Add EcosystemInformation Cluster to endpoint so we respond appropritely on endpoint
155+
*
156+
* EcosystemInformation cluster is only ever on dynamic bridge endpoint. If cluster is added
157+
* to a new endpoint, but does not contain any ecosystem information information presently,
158+
* this is called to let ECOINFO cluster code know it is supposed to provide blank attribute
159+
* information on this endpoint.
160+
*
161+
* This approach was intentionally taken instead of relying on emberAfDeviceTypeListFromEndpoint
162+
* to keep this cluster more unit testable. This does add burden to application but is worth
163+
* the trade-off.
164+
*
165+
* @param[in] aEndpoint Which endpoint is the device being added to the device directory.
166+
* @return #CHIP_NO_ERROR on success.
167+
* @return Other CHIP_ERROR associated with issue.
168+
*/
169+
CHIP_ERROR AddEcosystemInformationClusterToEndpoint(EndpointId aEndpoint);
170+
153171
/**
154172
* @brief Adds device as entry to DeviceDirectory list Attribute.
155173
*

0 commit comments

Comments
 (0)