14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
- #include " lib/core/CHIPError.h"
18
17
#include < app/codegen-data-model/CodegenDataModel.h>
19
18
20
19
#include < optional>
29
28
#include < app/AttributeValueEncoder.h>
30
29
#include < app/GlobalAttributes.h>
31
30
#include < app/RequiredPrivilege.h>
31
+ #include < app/codegen-data-model/EmberMetadata.h>
32
32
#include < app/data-model/FabricScoped.h>
33
33
#include < app/util/af-types.h>
34
34
#include < app/util/attribute-metadata.h>
@@ -49,56 +49,6 @@ namespace app {
49
49
namespace {
50
50
using namespace chip ::app::Compatibility::Internal;
51
51
52
- // Fetch the source for the given attribute path: either a cluster (for global ones) or attribute
53
- // path.
54
- //
55
- // if returning a CHIP_ERROR, it will NEVER be CHIP_NO_ERROR.
56
- std::variant<const EmberAfCluster *, // global attribute, data from a cluster
57
- const EmberAfAttributeMetadata *, // a specific attribute stored by ember
58
- CHIP_ERROR // error, this will NEVER be CHIP_NO_ERROR
59
- >
60
- FindAttributeMetadata (const ConcreteAttributePath & aPath)
61
- {
62
- for (auto & attr : GlobalAttributesNotInMetadata)
63
- {
64
-
65
- if (attr == aPath.mAttributeId )
66
- {
67
- const EmberAfCluster * cluster = emberAfFindServerCluster (aPath.mEndpointId , aPath.mClusterId );
68
- if (cluster == nullptr )
69
- {
70
- return (emberAfFindEndpointType (aPath.mEndpointId ) == nullptr ) ? CHIP_IM_GLOBAL_STATUS (UnsupportedEndpoint)
71
- : CHIP_IM_GLOBAL_STATUS (UnsupportedCluster);
72
- }
73
-
74
- return cluster;
75
- }
76
- }
77
- const EmberAfAttributeMetadata * metadata =
78
- emberAfLocateAttributeMetadata (aPath.mEndpointId , aPath.mClusterId , aPath.mAttributeId );
79
-
80
- if (metadata == nullptr )
81
- {
82
- const EmberAfEndpointType * type = emberAfFindEndpointType (aPath.mEndpointId );
83
- if (type == nullptr )
84
- {
85
- return CHIP_IM_GLOBAL_STATUS (UnsupportedEndpoint);
86
- }
87
-
88
- const EmberAfCluster * cluster = emberAfFindClusterInType (type, aPath.mClusterId , CLUSTER_MASK_SERVER);
89
- if (cluster == nullptr )
90
- {
91
- return CHIP_IM_GLOBAL_STATUS (UnsupportedCluster);
92
- }
93
-
94
- // Since we know the attribute is unsupported and the endpoint/cluster are
95
- // OK, this is the only option left.
96
- return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute);
97
- }
98
-
99
- return metadata;
100
- }
101
-
102
52
// / Attempts to read via an attribute access interface (AAI)
103
53
// /
104
54
// / If it returns a CHIP_ERROR, then this is a FINAL result (i.e. either failure or success).
@@ -320,7 +270,7 @@ CHIP_ERROR CodegenDataModel::ReadAttribute(const InteractionModel::ReadAttribute
320
270
}
321
271
}
322
272
323
- auto metadata = FindAttributeMetadata (request.path );
273
+ auto metadata = Ember:: FindAttributeMetadata (request.path );
324
274
325
275
// Explicit failure in finding a suitable metadata
326
276
if (const CHIP_ERROR * err = std::get_if<CHIP_ERROR>(&metadata))
0 commit comments