Skip to content

Commit a4e497d

Browse files
committed
Split out attribute-storage/table into a -detail and non-detail header
1 parent 41e950b commit a4e497d

23 files changed

+348
-267
lines changed

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ jobs:
102102
--known-failure app/TestEventTriggerDelegate.h \
103103
--known-failure app/util/attribute-storage.cpp \
104104
--known-failure app/util/attribute-storage.h \
105+
--known-failure app/util/attribute-storage-detail.h \
105106
--known-failure app/util/attribute-table.cpp \
106107
--known-failure app/util/attribute-table.h \
107108
--known-failure app/util/binding-table.cpp \
108109
--known-failure app/util/binding-table.h \
110+
--known-failure app/util/binding-table-detail.h \
109111
--known-failure app/util/config.h \
110112
--known-failure app/util/DataModelHandler.cpp \
111113
--known-failure app/util/DataModelHandler.h \

examples/virtual-device-app/android/java/ColorControlManager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <app-common/zap-generated/attributes/Accessors.h>
2020
#include <app-common/zap-generated/ids/Clusters.h>
2121
#include <app/util/attribute-storage.h>
22+
#include <app/util/config.h>
2223
#include <jni.h>
2324
#include <lib/support/CHIPJNIError.h>
2425
#include <lib/support/JniReferences.h>

examples/virtual-device-app/android/java/DoorLockManager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <app/ConcreteAttributePath.h>
2222
#include <app/clusters/door-lock-server/door-lock-server.h>
2323
#include <app/reporting/reporting.h>
24+
#include <app/util/config.h>
2425
#include <jni.h>
2526
#include <lib/support/CHIPJNIError.h>
2627
#include <lib/support/JniReferences.h>

examples/virtual-device-app/android/java/PowerSourceManager.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <app/ConcreteAttributePath.h>
2323
#include <app/clusters/door-lock-server/door-lock-server.h>
2424
#include <app/reporting/reporting.h>
25+
#include <app/util/config.h>
2526
#include <jni.h>
2627
#include <lib/support/CHIPJNIError.h>
2728
#include <lib/support/JniReferences.h>

src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <app/SafeAttributePersistenceProvider.h>
3030
#include <app/data-model/Encode.h>
3131
#include <app/util/attribute-storage.h>
32+
#include <app/util/config.h>
3233
#include <lib/core/CHIPError.h>
3334
#include <lib/support/logging/CHIPLogging.h>
3435
#include <platform/CHIPDeviceConfig.h>

src/app/clusters/descriptor/descriptor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <app-common/zap-generated/ids/Clusters.h>
2626
#include <app/AttributeAccessInterface.h>
2727
#include <app/util/attribute-storage.h>
28+
#include <app/util/endpoint-config-api.h>
2829
#include <lib/support/CodeUtils.h>
2930
#include <lib/support/logging/CHIPLogging.h>
3031

src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <app/EventLogging.h>
2424
#include <app/InteractionModelEngine.h>
2525
#include <app/util/attribute-storage.h>
26+
#include <app/util/config.h>
2627
#include <lib/support/BitFlags.h>
2728

2829
using namespace chip;

src/app/clusters/door-lock-server/door-lock-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <app/EventLogging.h>
2929
#include <app/server/Server.h>
3030
#include <app/util/attribute-storage.h>
31+
#include <app/util/config.h>
3132
#include <cinttypes>
3233

3334
#include <app/CommandHandler.h>

src/app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <app/EventLogging.h>
2424
#include <app/reporting/reporting.h>
2525
#include <app/util/attribute-storage.h>
26+
#include <app/util/config.h>
2627

2728
using chip::Protocols::InteractionModel::Status;
2829

src/app/clusters/fan-control-server/fan-control-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <app/ConcreteCommandPath.h>
3333
#include <app/clusters/fan-control-server/fan-control-server.h>
3434
#include <app/util/attribute-storage.h>
35+
#include <app/util/config.h>
3536
#include <lib/support/CodeUtils.h>
3637
#include <lib/support/logging/CHIPLogging.h>
3738
#include <protocols/interaction_model/StatusCode.h>

src/app/clusters/sample-mei-server/sample-mei-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <app/InteractionModelEngine.h>
1111
#include <app/reporting/reporting.h>
1212
#include <app/util/attribute-storage.h>
13+
#include <app/util/config.h>
1314
#include <app/util/util.h>
1415
#include <lib/support/CodeUtils.h>
1516
#include <lib/support/logging/CHIPLogging.h>

src/app/clusters/scenes-server/SceneHandlerImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <app/clusters/scenes-server/SceneTable.h>
1919
#include <app/util/attribute-storage.h>
20+
#include <app/util/types_stub.h>
2021
#include <lib/core/DataModelTypes.h>
2122

2223
namespace chip {

src/app/clusters/scenes-server/scenes-server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <app/reporting/reporting.h>
2626
#include <app/server/Server.h>
2727
#include <app/util/attribute-storage.h>
28+
#include <app/util/config.h>
2829
#include <credentials/GroupDataProvider.h>
2930
#include <lib/support/CommonIterator.h>
3031
#include <lib/support/Span.h>

src/app/clusters/scenes-server/scenes-server.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <app/data-model/DecodableList.h>
2626
#include <app/data-model/Nullable.h>
2727
#include <app/util/attribute-storage.h>
28+
#include <app/util/config.h>
2829
#include <credentials/GroupDataProvider.h>
2930

3031
namespace chip {
+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/**
2+
*
3+
* Copyright (c) 2020 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include <app/AttributeAccessInterface.h>
21+
#include <app/ConcreteAttributePath.h>
22+
#include <app/util/config.h>
23+
#include <app/util/endpoint-config-api.h>
24+
#include <lib/support/CodeUtils.h>
25+
26+
#include <app/util/att-storage.h>
27+
#include <app/util/attribute-metadata.h>
28+
#include <zap-generated/endpoint_config.h>
29+
30+
#include <protocols/interaction_model/StatusCode.h>
31+
32+
// If we have fixed number of endpoints, then max is the same.
33+
#ifdef FIXED_ENDPOINT_COUNT
34+
#define MAX_ENDPOINT_COUNT (FIXED_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
35+
#endif
36+
37+
#include <app-common/zap-generated/attribute-type.h>
38+
39+
#define DECLARE_DYNAMIC_ENDPOINT(endpointName, clusterList) \
40+
EmberAfEndpointType endpointName = { clusterList, ArraySize(clusterList), 0 }
41+
42+
#define DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName) EmberAfCluster clusterListName[] = {
43+
44+
// The role argument should be used to determine whether cluster works as a server or a client.
45+
// It can be assigned with the ZAP_CLUSTER_MASK(SERVER) or ZAP_CLUSTER_MASK(CLUSTER) values.
46+
#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands) \
47+
{ \
48+
clusterId, clusterAttrs, ArraySize(clusterAttrs), 0, role, NULL, incomingCommands, outgoingCommands \
49+
}
50+
51+
#define DECLARE_DYNAMIC_CLUSTER_LIST_END }
52+
53+
#define DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(attrListName) EmberAfAttributeMetadata attrListName[] = {
54+
55+
#define DECLARE_DYNAMIC_ATTRIBUTE_LIST_END() \
56+
{ \
57+
ZAP_EMPTY_DEFAULT(), 0xFFFD, 2, ZAP_TYPE(INT16U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) \
58+
} /* cluster revision */ \
59+
}
60+
61+
#define DECLARE_DYNAMIC_ATTRIBUTE(attId, attType, attSizeBytes, attrMask) \
62+
{ \
63+
ZAP_EMPTY_DEFAULT(), attId, attSizeBytes, ZAP_TYPE(attType), attrMask | ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) \
64+
}
65+
66+
extern uint8_t attributeData[]; // main storage bucket for all attributes
67+
68+
void emAfCallInits();
69+
70+
chip::Protocols::InteractionModel::Status emAfReadOrWriteAttribute(const EmberAfAttributeSearchRecord * attRecord,
71+
const EmberAfAttributeMetadata ** metadata, uint8_t * buffer,
72+
uint16_t readLength, bool write);
73+
74+
//
75+
// Given a cluster ID, endpoint ID and a cluster mask, finds a matching cluster within that endpoint
76+
// with a matching mask. If one is found, the relative index of that cluster within the list of clusters on that
77+
// endpoint is returned. Otherwise, 0xFF is returned.
78+
//
79+
uint8_t emberAfClusterIndex(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfClusterMask mask);
80+
81+
// Returns the clusterId of Nth server or client cluster,
82+
// depending on server toggle.
83+
// Returns Optional<ClusterId>::Missing if cluster does not exist.
84+
chip::Optional<chip::ClusterId> emberAfGetNthClusterId(chip::EndpointId endpoint, uint8_t n, bool server);
85+
86+
// Returns cluster within the endpoint; Does not ignore disabled endpoints
87+
const EmberAfCluster * emberAfFindClusterIncludingDisabledEndpoints(chip::EndpointId endpoint, chip::ClusterId clusterId,
88+
EmberAfClusterMask mask);
89+
90+
// Function mask must contain one of the CLUSTER_MASK function macros,
91+
// then this method either returns the function pointer or null if
92+
// function doesn't exist. Before you call the function, you must
93+
// cast it.
94+
EmberAfGenericClusterFunction emberAfFindClusterFunction(const EmberAfCluster * cluster, EmberAfClusterMask functionMask);
95+
96+
// After the RAM value has changed, code should call this function. If this
97+
// attribute has been tagged as non-volatile, its value will be stored.
98+
void emAfSaveAttributeToStorageIfNeeded(uint8_t * data, chip::EndpointId endpoint, chip::ClusterId clusterId,
99+
const EmberAfAttributeMetadata * metadata);
100+
101+
// Calls the attribute changed callback
102+
void emAfClusterAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath);
103+
104+
// Calls the attribute changed callback for a specific cluster.
105+
chip::Protocols::InteractionModel::Status
106+
emAfClusterPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType,
107+
uint16_t size, uint8_t * value);
108+
109+
// Register a dynamic endpoint. This involves registering descriptors that describe
110+
// the composition of the endpoint (encapsulated in the 'ep' argument) as well as providing
111+
// storage for data versions.
112+
//
113+
// dataVersionStorage.size() needs to be at least as large as the number of
114+
// server clusters on this endpoint. If it's not, the endpoint will not be able
115+
// to store data versions, which may break consumers.
116+
//
117+
// The memory backing dataVersionStorage needs to remain allocated until this dynamic
118+
// endpoint is cleared.
119+
//
120+
// An optional device type list can be passed in as well. If provided, the memory
121+
// backing the list needs to remain allocated until this dynamic endpoint is cleared.
122+
//
123+
// An optional parent endpoint id should be passed for child endpoints of composed device.
124+
//
125+
// Returns CHIP_NO_ERROR No error.
126+
// CHIP_ERROR_NO_MEMORY MAX_ENDPOINT_COUNT is reached or when no storage is left for clusters
127+
// CHIP_ERROR_INVALID_ARGUMENT The EndpointId value passed is kInvalidEndpointId
128+
// CHIP_ERROR_ENDPOINT_EXISTS If the EndpointId value passed already exists
129+
//
130+
CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep,
131+
const chip::Span<chip::DataVersion> & dataVersionStorage,
132+
chip::Span<const EmberAfDeviceType> deviceTypeList = {},
133+
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
134+
chip::EndpointId emberAfClearDynamicEndpoint(uint16_t index);
135+
uint16_t emberAfGetDynamicIndexFromEndpoint(chip::EndpointId id);
136+
137+
// Get the number of attributes of the specific cluster under the endpoint.
138+
// Returns 0 if the cluster does not exist.
139+
uint16_t emberAfGetServerAttributeCount(chip::EndpointId endpoint, chip::ClusterId cluster);
140+
141+
// Get the index of the given attribute of the specific cluster under the endpoint.
142+
// Returns UINT16_MAX if the attribute does not exist.
143+
uint16_t emberAfGetServerAttributeIndexByAttributeId(chip::EndpointId endpoint, chip::ClusterId cluster,
144+
chip::AttributeId attributeId);
145+
146+
// Get the attribute id at the attributeIndex of the cluster under the endpoint. This function is useful for iterating over the
147+
// attributes.
148+
// Returns Optional<chip::AttributeId>::Missing() if the attribute does not exist.
149+
chip::Optional<chip::AttributeId> emberAfGetServerAttributeIdByIndex(chip::EndpointId endpoint, chip::ClusterId cluster,
150+
uint16_t attributeIndex);
151+

src/app/util/attribute-storage.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include <app/util/attribute-storage.h>
1919

20+
#include <app/util/attribute-storage-detail.h>
21+
2022
#include <app/AttributeAccessInterfaceCache.h>
2123
#include <app/AttributePersistenceProvider.h>
2224
#include <app/InteractionModelEngine.h>
@@ -818,8 +820,14 @@ namespace app {
818820

819821
EnabledEndpointsWithServerCluster::EnabledEndpointsWithServerCluster(ClusterId clusterId) : mClusterId(clusterId)
820822
{
823+
mEndpointCount = emberAfEndpointCount();
821824
EnsureMatchingEndpoint();
822825
}
826+
827+
EndpointId EnabledEndpointsWithServerCluster::operator*() const {
828+
return emberAfEndpointFromIndex(mEndpointIndex);
829+
}
830+
823831
EnabledEndpointsWithServerCluster & EnabledEndpointsWithServerCluster::operator++()
824832
{
825833
++mEndpointIndex;

0 commit comments

Comments
 (0)