1
+ /* ****************************************************************************
2
+ * @file sl-matter-attribute-storage.cpp
3
+ * @brief Link zigbee datamodel attribute changes to Matter attribute storage.
4
+ *******************************************************************************
5
+ * # License
6
+ * <b>Copyright 2024 Silicon Laboratories Inc.
7
+ *www.silabs.com</b>
8
+ *******************************************************************************
9
+ *
10
+ * The licensor of this software is Silicon
11
+ *Laboratories Inc. Your use of this software is
12
+ *governed by the terms of Silicon Labs Master
13
+ *Software License Agreement (MSLA) available at
14
+ * www.silabs.com/about-us/legal/master-software-license-agreement.
15
+ *This software is distributed to you in Source Code
16
+ *format and is governed by the sections of the MSLA
17
+ *applicable to Source Code.
18
+ *
19
+ ******************************************************************************/
20
+
21
+ #include < app/util/attribute-metadata.h>
22
+ #include < app/util/attribute-table.h>
23
+ #include < lib/support/TypeTraits.h>
24
+ #include < lib/support/logging/CHIPLogging.h>
25
+ #include < protocols/interaction_model/StatusCode.h>
26
+ #include < sl-matter-attribute-storage.h>
27
+ #include < sl_component_catalog.h>
28
+
29
+ namespace {
30
+ // This is called from simplicity_sdk/protocol/zigbee/app/framework/util/attribute-storage.c on ZB attribute write
31
+ // when GENERATED_MULTI_PROTOCOL_ATTRIBUTE_MAPPING and SL_CATALOG_MULTIPROTOCOL_ZIGBEE_MATTER_COMMON_PRESENT are defined.
32
+ extern " C" sl_status_t sli_matter_af_write_attribute (uint16_t endpointId, uint32_t clusterId, uint32_t attributeId,
33
+ uint8_t * attributeValue, uint8_t type)
34
+ {
35
+ // All type shall be directly applicable. We expect compilation error if type changes.
36
+ chip::EndpointId matterEndpointId = endpointId;
37
+ chip::ClusterId matterClusterId = clusterId;
38
+ chip::AttributeId matterAttributeId = attributeId;
39
+ EmberAfAttributeType matterDataType = type;
40
+
41
+ chip::Protocols::InteractionModel::Status imStatus =
42
+ emberAfWriteAttribute (matterEndpointId, matterClusterId, matterAttributeId, attributeValue, matterDataType);
43
+
44
+ // For sl internal use so we return a known status type to our stack
45
+ sl_status_t slStatus = SL_STATUS_OK;
46
+ if (imStatus != chip::Protocols::InteractionModel::Status::Success)
47
+ {
48
+ ChipLogError (Zcl, " Failed to write Matter attribute from multiprotocol update. Err:0x%02x" , chip::to_underlying (imStatus));
49
+ slStatus = SL_STATUS_FAIL;
50
+ }
51
+
52
+ return slStatus;
53
+ }
54
+ } // namespace
0 commit comments