Skip to content

Commit 09c4e9a

Browse files
committed
Add PreAttributeChangeCallback
1 parent 33e93f2 commit 09c4e9a

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

examples/chef/common/clusters/switch/SwitchDelegate.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ class SwitchAttributeDelegate : public AttributeDelegate
141141
public:
142142
SwitchAttributeDelegate (ClusterId clusterId) : AttributeDelegate(clusterId) {}
143143

144-
void PostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) override;
144+
chip::Protocols::InteractionModel::Status PreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) override;
145145

146+
void PostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) override;
147+
146148
private:
147149
};
148150

@@ -156,6 +158,16 @@ SwitchEventHandler * GetSwitchEventHandler(EndpointId endpointId)
156158
return gSwitchEventHandlers[endpointId];
157159
}
158160

161+
chip::Protocols::InteractionModel::Status SwitchAttributeDelegate::PreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value)
162+
{
163+
chip::Protocols::InteractionModel::Status ret = chip::Protocols::InteractionModel::Status::Success;
164+
printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__);
165+
ChipLogProgress(Zcl, "SwitchAttributeDelegate::PostAttributeChangeCallback Endpoint: %d, Cluster: " ChipLogFormatMEI ", Type: %u, length %u", attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), type, size);
166+
167+
168+
return ret;
169+
}
170+
159171
void SwitchAttributeDelegate::PostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value)
160172
{
161173
printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__);

examples/chef/common/stubs.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
137137

138138
void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) {}
139139

140+
141+
chip::Protocols::InteractionModel::Status
142+
MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
143+
uint8_t * value)
144+
{
145+
chip::Protocols::InteractionModel::Status ret = chip::Protocols::InteractionModel::Status::Success;
146+
147+
ChipLogProgress(Zcl, "MatterPostAttributeChangeCallback Endpoint: %d, Cluster: " ChipLogFormatMEI ", Type: %u, length %u", attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), type, size);
148+
printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__);
149+
150+
AttributeDelegate * delegate = GetApplicationAttributeDelegate(attributePath.mClusterId);
151+
if (delegate) {
152+
ret = delegate->PreAttributeChangeCallback(attributePath, type, size, value);
153+
}
154+
155+
return ret;
156+
}
157+
140158
void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
141159
uint8_t * value)
142160
{

examples/chef/common/stubs.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class AttributeDelegate
2828
{
2929
public:
3030
AttributeDelegate (ClusterId clusterId) : mClusterId(clusterId) {}
31+
32+
virtual ~AttributeDelegate() {}
33+
/**
34+
* xxxx
35+
*/
36+
virtual chip::Protocols::InteractionModel::Status PreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { return chip::Protocols::InteractionModel::Status::Success; }
3137
/**
3238
* xxxx
3339
*/
@@ -41,8 +47,6 @@ class AttributeDelegate
4147
*/
4248
virtual Protocols::InteractionModel::Status ExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, uint16_t maxReadLength) {return Protocols::InteractionModel::Status::Success;}
4349

44-
virtual ~AttributeDelegate() {}
45-
4650
private:
4751
ClusterId mClusterId;
4852
};

0 commit comments

Comments
 (0)