9#include "app/server-cluster/ServerClusterInterfaceRegistry.h"
10#include "data-model-providers/codegen/CodegenDataModelProvider.h"
11#include <app-common/zap-generated/ids/Attributes.h>
12#include <app-common/zap-generated/ids/Clusters.h>
13#include <app/AttributeAccessInterfaceRegistry.h>
14#include <app/CommandHandlerInterfaceRegistry.h>
15#include <app/DefaultTimerDelegate.h>
16#include <app/clusters/identify-server/IdentifyCluster.h>
17#include <app/util/attribute-storage.h>
18#include <platform/ConfigurationManager.h>
26#define DESCRIPTOR_CLUSTER_ATTRIBUTES(descriptorAttrs) \
27 DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) \
28 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::DeviceTypeList::Id, ARRAY, \
29 Nrf::MatterBridgedDevice::kDescriptorAttributeArraySize, 0), \
30 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::ServerList::Id, ARRAY, \
31 Nrf::MatterBridgedDevice::kDescriptorAttributeArraySize, 0),
33 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::ClientList::Id, ARRAY, \
34 Nrf::MatterBridgedDevice::kDescriptorAttributeArraySize, 0),
36 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::PartsList::Id, ARRAY, \
37 Nrf::MatterBridgedDevice::kDescriptorAttributeArraySize, 0),
39 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::FeatureMap::Id, BITMAP32, 4, \
41 DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
44#define BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_ATTRIBUTES(bridgedDeviceBasicAttrs) \
45 DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs) \
46 DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::NodeLabel::Id, \
47 CHAR_STRING, Nrf::MatterBridgedDevice::kNodeLabelSize, \
48 ZAP_ATTRIBUTE_MASK(WRITABLE)), \
49 DECLARE_DYNAMIC_ATTRIBUTE( \
50 chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::Reachable::Id, BOOLEAN, 1, \
52 DECLARE_DYNAMIC_ATTRIBUTE( \
53 chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::UniqueID::Id, CHAR_STRING, 32, \
55 DECLARE_DYNAMIC_ATTRIBUTE( \
56 chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::FeatureMap::Id, BITMAP32, 4, \
58 DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();
63 void OnIdentifyStart(chip::app::Clusters::IdentifyCluster &cluster)
override
65 ChipLogError(DeviceLayer,
"Starting bridged device identify on endpoint %d",
66 cluster.GetPaths()[0].mEndpointId);
69 void OnIdentifyStop(chip::app::Clusters::IdentifyCluster &cluster)
override
71 ChipLogError(DeviceLayer,
"Stopping bridged device identify on endpoint %d",
72 cluster.GetPaths()[0].mEndpointId);
73 mIsTriggerEffectEnabled =
false;
76 void OnTriggerEffect(chip::app::Clusters::IdentifyCluster &cluster)
override
78 ChipLogError(DeviceLayer,
"Triggering effect on endpoint %d", cluster.GetPaths()[0].mEndpointId);
79 mIsTriggerEffectEnabled =
true;
85 bool mIsTriggerEffectEnabled =
false;
98 using IdentifyType = chip::app::Clusters::Identify::IdentifyTypeEnum;
101 static constexpr uint8_t
kUniqueIDSize = chip::DeviceLayer::ConfigurationManager::kMaxUniqueIDLength;
115 if (mIdentifyCluster.IsConstructed()) {
116 chip::app::CodegenDataModelProvider::Instance().Registry().Unregister(
117 &mIdentifyCluster.Cluster());
118 mIdentifyCluster.Destroy();
124 void Init(chip::EndpointId endpoint)
128 mIdentifyCluster.Create(
129 chip::app::Clusters::IdentifyCluster::Config(
mEndpointId, mTimerDelegate)
130 .WithIdentifyType(chip::app::Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator)
131 .WithDelegate(&mIdentifyDelegate));
133 CHIP_ERROR err = chip::app::CodegenDataModelProvider::Instance().Registry().Register(
134 mIdentifyCluster.Registration());
135 if (err != CHIP_NO_ERROR) {
136 ChipLogError(DeviceLayer,
"Failed to register Identify cluster: %s", ErrorStr(err));
143 virtual CHIP_ERROR
HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
144 uint16_t maxReadLength) = 0;
145 virtual CHIP_ERROR
HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
148 size_t dataSize) = 0;
150 CHIP_ERROR
CopyAttribute(
const void *attribute,
size_t attributeSize,
void *buffer, uint16_t maxBufferSize);
152 void *data,
size_t dataSize);
154 uint16_t maxReadLength);
156 CHIP_ERROR
HandleReadIdentify(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength);
180 bool mIsReachable =
true;
183 chip::app::LazyRegisteredServerCluster<chip::app::Clusters::IdentifyCluster> mIdentifyCluster;
184 chip::app::DefaultTimerDelegate mTimerDelegate;
185 IdentifyBridgedDeviceDelegateImpl mIdentifyDelegate;
void OnTriggerEffect(chip::app::Clusters::IdentifyCluster &cluster) override
Definition matter_bridged_device.h:73
void OnIdentifyStop(chip::app::Clusters::IdentifyCluster &cluster) override
Definition matter_bridged_device.h:66
void OnIdentifyStart(chip::app::Clusters::IdentifyCluster &cluster) override
Definition matter_bridged_device.h:60
bool IsTriggerEffectEnabled() const override
Definition matter_bridged_device.h:79
Definition matter_bridged_device.h:58
static constexpr uint16_t GetBridgedDeviceBasicInformationClusterRevision()
Definition matter_bridged_device.h:159
void Init(chip::EndpointId endpoint)
Definition matter_bridged_device.h:121
virtual uint16_t GetDeviceType() const =0
CHIP_ERROR HandleReadBridgedDeviceBasicInformation(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
virtual CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, size_t size)=0
static constexpr uint8_t kNodeLabelSize
Definition matter_bridged_device.h:97
bool GetIsReachable() const
Definition matter_bridged_device.h:156
static constexpr uint8_t kDefaultDynamicEndpointVersion
Definition matter_bridged_device.h:96
static constexpr uint32_t GetIdentifyClusterFeatureMap()
Definition matter_bridged_device.h:162
const char * GetNodeLabel() const
Definition matter_bridged_device.h:158
virtual CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)=0
size_t mDataVersionSize
Definition matter_bridged_device.h:168
chip::EndpointId GetEndpointId() const
Definition matter_bridged_device.h:137
CHIP_ERROR HandleWriteDeviceBasicInformation(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize)
const char * GetUniqueID() const
Definition matter_bridged_device.h:157
virtual CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data, size_t dataSize)=0
MatterBridgedDevice(const char *uniqueID, const char *nodeLabel)
Definition matter_bridged_device.h:101
chip::app::Clusters::Identify::IdentifyTypeEnum IdentifyType
Definition matter_bridged_device.h:95
virtual ~MatterBridgedDevice()
Definition matter_bridged_device.h:110
chip::EndpointId mEndpointId
Definition matter_bridged_device.h:174
EmberAfEndpointType * mEp
Definition matter_bridged_device.h:164
CHIP_ERROR HandleWriteIdentify(chip::AttributeId attributeId, void *data, size_t dataSize)
chip::DataVersion * mDataVersion
Definition matter_bridged_device.h:167
CHIP_ERROR HandleReadIdentify(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
static constexpr uint32_t GetBridgedDeviceBasicInformationFeatureMap()
Definition matter_bridged_device.h:160
const EmberAfDeviceType * mDeviceTypeList
Definition matter_bridged_device.h:165
static constexpr uint16_t GetIdentifyClusterRevision()
Definition matter_bridged_device.h:161
CHIP_ERROR CopyAttribute(const void *attribute, size_t attributeSize, void *buffer, uint16_t maxBufferSize)
DeviceType
Definition matter_bridged_device.h:87
@ TemperatureSensor
Definition matter_bridged_device.h:91
@ HumiditySensor
Definition matter_bridged_device.h:92
@ OnOffLightSwitch
Definition matter_bridged_device.h:90
@ GenericSwitch
Definition matter_bridged_device.h:93
@ BridgedNode
Definition matter_bridged_device.h:88
@ OnOffLight
Definition matter_bridged_device.h:89
void SetNodeLabel(void *data, size_t size)
void SetIsReachable(bool isReachable)
Definition matter_bridged_device.h:171
size_t mDeviceTypeListSize
Definition matter_bridged_device.h:166
static constexpr uint8_t kUniqueIDSize
Definition matter_bridged_device.h:98
static constexpr uint8_t kDescriptorAttributeArraySize
Definition matter_bridged_device.h:99
Definition matter_bridged_device.h:85
Definition ble_connectivity_manager.h:21