|
19 | 19 | #include "chef-concentration-measurement.h"
|
20 | 20 | #endif
|
21 | 21 |
|
22 |
| -#include "stubs.h" |
23 |
| -#include <map> |
24 |
| - |
25 | 22 | using chip::app::DataModel::Nullable;
|
26 | 23 |
|
27 | 24 | using namespace chip;
|
28 | 25 | using namespace chip::app;
|
29 | 26 | using namespace chip::app::Clusters;
|
30 | 27 |
|
31 |
| -static std::map<ClusterId, AttributeDelegate * > gApplicationAttributeDelegates{}; |
32 |
| - |
33 |
| -void chip::app::RegisterApplicationAttributeDelegate(ClusterId clusterId, AttributeDelegate * delegate) |
34 |
| -{ |
35 |
| - // TODO assert (gApplicationAttributeDelegates.find(clusterId) == gApplicationAttributeDelegates.end() ) |
36 |
| - |
37 |
| - gApplicationAttributeDelegates[clusterId] = delegate; |
38 |
| - |
39 |
| -} |
40 |
| - |
41 |
| - |
42 |
| -AttributeDelegate * GetApplicationAttributeDelegate(ClusterId clusterId) |
43 |
| -{ |
44 |
| - if (gApplicationAttributeDelegates.find(clusterId) == gApplicationAttributeDelegates.end()) { |
45 |
| - return nullptr; |
46 |
| - } |
47 |
| - |
48 |
| - return gApplicationAttributeDelegates[clusterId]; |
49 |
| -} |
50 |
| - |
51 |
| - |
52 | 28 | Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
|
53 | 29 | const EmberAfAttributeMetadata * attributeMetadata,
|
54 | 30 | uint8_t * buffer, uint16_t maxReadLength)
|
@@ -137,54 +113,25 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
|
137 | 113 |
|
138 | 114 | void emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) {}
|
139 | 115 |
|
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 |
| - |
158 | 116 | void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size,
|
159 | 117 | uint8_t * value)
|
160 | 118 | {
|
161 |
| -// AttributeId attributeId = attributePath.mAttributeId; |
162 |
| - ChipLogProgress(Zcl, "MatterPostAttributeChangeCallback Endpoint: %d, Cluster: " ChipLogFormatMEI ", Type: %u, length %u", attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), type, size); |
163 |
| -printf("\033[41m %s, %d \033[0m \n", __func__, __LINE__); |
| 119 | + ClusterId clusterId = attributePath.mClusterId; |
| 120 | + AttributeId attributeId = attributePath.mAttributeId; |
| 121 | + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); |
164 | 122 |
|
165 |
| - AttributeDelegate * delegate = GetApplicationAttributeDelegate(attributePath.mClusterId); |
166 |
| - if (delegate) { |
167 |
| - delegate->PostAttributeChangeCallback(attributePath, type, size, value); |
168 |
| - } |
169 |
| - |
170 |
| -#if 0 |
171 |
| - switch (clusterId) { |
172 |
| - case OnOff::Id: |
173 |
| - ChipLogProgress(Zcl, "OnOff Cluster attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), |
| 123 | + if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) |
| 124 | + { |
| 125 | + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", ChipLogValueMEI(attributeId), |
174 | 126 | type, *value, size);
|
175 |
| - break; |
176 |
| - case LevelControl::Id: |
177 |
| - ChipLogProgress(Zcl, "Level Control Cluster attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", |
178 |
| - ChipLogValueMEI(attributeId), type, *value, size); |
179 |
| - break; |
180 |
| - case Switch::Id: |
181 |
| - ChipLogProgress(Zcl, "Switch Cluster attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", |
| 127 | + } |
| 128 | + else if (clusterId == LevelControl::Id) |
| 129 | + { |
| 130 | + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", |
182 | 131 | ChipLogValueMEI(attributeId), type, *value, size);
|
183 |
| - break; |
184 |
| - default: |
185 |
| - break; |
| 132 | + |
| 133 | + // WIP Apply attribute change to Light |
186 | 134 | }
|
187 |
| -#endif |
188 | 135 | }
|
189 | 136 |
|
190 | 137 | /** @brief OnOff Cluster Init
|
|
0 commit comments