Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabric-bridge: Add ECOINFO to dynamic bridged endpoints #34811

Merged
14 changes: 13 additions & 1 deletion examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ 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 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" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ 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();

tehampson marked this conversation as resolved.
Show resolved Hide resolved
// Declare Administrator Commissioning cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(AdministratorCommissioningAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::WindowStatus::Id, ENUM8, 1, 0), /* NodeLabel */
Expand All @@ -109,6 +119,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;

Expand Down
4 changes: 4 additions & 0 deletions examples/fabric-bridge-app/linux/RpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "pw_rpc_system_server/rpc_server.h"
#include "pw_rpc_system_server/socket.h"

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

#include <string>
Expand Down Expand Up @@ -62,6 +63,9 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice
return pw::Status::Unknown();
}

// Ignoring the error returned.
tehampson marked this conversation as resolved.
Show resolved Hide resolved
EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(device->GetEndpointId());

return pw::OkStatus();
}

Expand Down
5 changes: 4 additions & 1 deletion examples/fabric-bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <app/AttributeAccessInterfaceRegistry.h>
#include <app/CommandHandlerInterfaceRegistry.h>
#include <app/clusters/ecosystem-information-server/ecosystem-information-server.h>

#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
#include "RpcClient.h"
Expand All @@ -34,8 +35,9 @@
#include <sys/ioctl.h>
#include <thread>

using namespace chip;
void MatterEcosystemInformationPluginServerInitCallback();
cecille marked this conversation as resolved.
Show resolved Hide resolved

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::AdministratorCommissioning;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
cecille marked this conversation as resolved.
Show resolved Hide resolved
return CHIP_NO_ERROR;
}

CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std::unique_ptr<EcosystemDeviceStruct> aDevice)
{
VerifyOrReturnError(aDevice, CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ class EcosystemInformationServer
public:
static EcosystemInformationServer & Instance();

/**
* @brief Add EcosystemInformation Cluster to endpoint so we respond appropritely on endpoint
tehampson marked this conversation as resolved.
Show resolved Hide resolved
*
* 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,
tehampson marked this conversation as resolved.
Show resolved Hide resolved
* 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
cecille marked this conversation as resolved.
Show resolved Hide resolved
* 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.
*
Expand Down
Loading