|
14 | 14 | * See the License for the specific language governing permissions and
|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
| 17 | +#include "app/util/af-types.h" |
17 | 18 | #include <app/util/attribute-table.h>
|
18 | 19 |
|
19 | 20 | #include <app/util/attribute-table-detail.h>
|
@@ -167,27 +168,34 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t
|
167 | 168 | * - Status::Success: if the attribute was found and successfully written
|
168 | 169 | */
|
169 | 170 | Status emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * data,
|
170 |
| - EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, MarkAttributeDirty markDirty); |
| 171 | + EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, MarkAttributeDirty markDirty, |
| 172 | + AttributeChanged * wasDirty); |
171 | 173 | } // anonymous namespace
|
172 | 174 |
|
173 | 175 | Status emAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr,
|
174 |
| - EmberAfAttributeType dataType) |
| 176 | + EmberAfAttributeType dataType, MarkAttributeDirty markDirty, AttributeChanged * changed) |
175 | 177 | {
|
176 |
| - return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, false /* override read-only */, |
177 |
| - MarkAttributeDirty::kIfChanged); |
| 178 | + return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, false /* override read-only */, markDirty, |
| 179 | + changed); |
178 | 180 | }
|
179 | 181 |
|
180 | 182 | Status emberAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr,
|
181 | 183 | EmberAfAttributeType dataType)
|
182 | 184 | {
|
183 | 185 | return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, true /* override read-only */,
|
184 |
| - MarkAttributeDirty::kIfChanged); |
| 186 | + MarkAttributeDirty::kIfChanged, nullptr); |
185 | 187 | }
|
186 | 188 |
|
187 | 189 | Status emberAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr,
|
188 | 190 | EmberAfAttributeType dataType, MarkAttributeDirty markDirty)
|
189 | 191 | {
|
190 |
| - return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, true /* override read-only */, markDirty); |
| 192 | + return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, true /* override read-only */, markDirty, nullptr); |
| 193 | +} |
| 194 | + |
| 195 | +Status emberAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, |
| 196 | + EmberAfAttributeType dataType, MarkAttributeDirty markDirty, AttributeChanged * changed) |
| 197 | +{ |
| 198 | + return emAfWriteAttribute(endpoint, cluster, attributeID, dataPtr, dataType, true /* override read-only */, markDirty, changed); |
191 | 199 | }
|
192 | 200 |
|
193 | 201 | //------------------------------------------------------------------------------
|
@@ -320,8 +328,14 @@ Status AttributeValueIsChanging(EndpointId endpoint, ClusterId cluster, Attribut
|
320 | 328 | }
|
321 | 329 |
|
322 | 330 | Status emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * data,
|
323 |
| - EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, MarkAttributeDirty markDirty) |
| 331 | + EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, MarkAttributeDirty markDirty, |
| 332 | + AttributeChanged * changeState) |
324 | 333 | {
|
| 334 | + if (changeState) |
| 335 | + { |
| 336 | + *changeState = AttributeChanged::kValueNotChanged; |
| 337 | + } |
| 338 | + |
325 | 339 | const EmberAfAttributeMetadata * metadata = nullptr;
|
326 | 340 | EmberAfAttributeSearchRecord record;
|
327 | 341 | record.endpoint = endpoint;
|
@@ -454,6 +468,12 @@ Status emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId at
|
454 | 468 | return status;
|
455 | 469 | }
|
456 | 470 |
|
| 471 | + // internal value has changed. Report to the caller. |
| 472 | + if (changeState != nullptr) |
| 473 | + { |
| 474 | + *changeState = AttributeChanged::kValueChanged; |
| 475 | + } |
| 476 | + |
457 | 477 | // Save the attribute to persistent storage if needed
|
458 | 478 | // The callee will weed out attributes that do not need to be stored.
|
459 | 479 | emAfSaveAttributeToStorageIfNeeded(data, endpoint, cluster, metadata);
|
|
0 commit comments