Skip to content

Commit d792243

Browse files
committed
Make tv app compile: need dynamic endpoints defines accessible
1 parent 8ec7256 commit d792243

File tree

2 files changed

+63
-55
lines changed

2 files changed

+63
-55
lines changed

src/app/util/attribute-storage-detail.h

-55
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,6 @@
3636

3737
#include <app-common/zap-generated/attribute-type.h>
3838

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-
6639
extern uint8_t attributeData[]; // main storage bucket for all attributes
6740

6841
void emAfCallInits();
@@ -106,34 +79,6 @@ chip::Protocols::InteractionModel::Status
10679
emAfClusterPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType,
10780
uint16_t size, uint8_t * value);
10881

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-
13782
// Get the number of attributes of the specific cluster under the endpoint.
13883
// Returns 0 if the cluster does not exist.
13984
uint16_t emberAfGetServerAttributeCount(chip::EndpointId endpoint, chip::ClusterId cluster);

src/app/util/attribute-storage.h

+63
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,47 @@
2121
#include <app/util/af-types.h>
2222
#include <app/util/att-storage.h>
2323
#include <app/util/attribute-metadata.h>
24+
#include <app/util/endpoint-config-defines.h>
2425
#include <lib/support/CodeUtils.h>
2526

2627
#include <app-common/zap-generated/cluster-objects.h>
28+
#include <app-common/zap-generated/attribute-type.h>
2729

2830
static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF;
2931

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+
#define DECLARE_DYNAMIC_ENDPOINT(endpointName, clusterList) \
38+
EmberAfEndpointType endpointName = { clusterList, ArraySize(clusterList), 0 }
39+
40+
#define DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName) EmberAfCluster clusterListName[] = {
41+
42+
// The role argument should be used to determine whether cluster works as a server or a client.
43+
// It can be assigned with the ZAP_CLUSTER_MASK(SERVER) or ZAP_CLUSTER_MASK(CLUSTER) values.
44+
#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands) \
45+
{ \
46+
clusterId, clusterAttrs, ArraySize(clusterAttrs), 0, role, NULL, incomingCommands, outgoingCommands \
47+
}
48+
49+
#define DECLARE_DYNAMIC_CLUSTER_LIST_END }
50+
51+
#define DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(attrListName) EmberAfAttributeMetadata attrListName[] = {
52+
53+
#define DECLARE_DYNAMIC_ATTRIBUTE_LIST_END() \
54+
{ \
55+
ZAP_EMPTY_DEFAULT(), 0xFFFD, 2, ZAP_TYPE(INT16U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) \
56+
} /* cluster revision */ \
57+
}
58+
59+
#define DECLARE_DYNAMIC_ATTRIBUTE(attId, attType, attSizeBytes, attrMask) \
60+
{ \
61+
ZAP_EMPTY_DEFAULT(), attId, attSizeBytes, ZAP_TYPE(attType), attrMask | ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) \
62+
}
63+
64+
3065
/**
3166
* @brief locate attribute metadata
3267
*
@@ -210,6 +245,34 @@ const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endp
210245
// Initial configuration
211246
void emberAfEndpointConfigure();
212247

248+
249+
// Register a dynamic endpoint. This involves registering descriptors that describe
250+
// the composition of the endpoint (encapsulated in the 'ep' argument) as well as providing
251+
// storage for data versions.
252+
//
253+
// dataVersionStorage.size() needs to be at least as large as the number of
254+
// server clusters on this endpoint. If it's not, the endpoint will not be able
255+
// to store data versions, which may break consumers.
256+
//
257+
// The memory backing dataVersionStorage needs to remain allocated until this dynamic
258+
// endpoint is cleared.
259+
//
260+
// An optional device type list can be passed in as well. If provided, the memory
261+
// backing the list needs to remain allocated until this dynamic endpoint is cleared.
262+
//
263+
// An optional parent endpoint id should be passed for child endpoints of composed device.
264+
//
265+
// Returns CHIP_NO_ERROR No error.
266+
// CHIP_ERROR_NO_MEMORY MAX_ENDPOINT_COUNT is reached or when no storage is left for clusters
267+
// CHIP_ERROR_INVALID_ARGUMENT The EndpointId value passed is kInvalidEndpointId
268+
// CHIP_ERROR_ENDPOINT_EXISTS If the EndpointId value passed already exists
269+
//
270+
CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep,
271+
const chip::Span<chip::DataVersion> & dataVersionStorage,
272+
chip::Span<const EmberAfDeviceType> deviceTypeList = {},
273+
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
274+
chip::EndpointId emberAfClearDynamicEndpoint(uint16_t index);
275+
uint16_t emberAfGetDynamicIndexFromEndpoint(chip::EndpointId id);
213276
/**
214277
* @brief Loads attribute defaults and any non-volatile attributes stored
215278
*

0 commit comments

Comments
 (0)