Skip to content

Commit

Permalink
Move defines not dependent on ZAP config out of endpoint_config.zapt. (
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 20, 2023
1 parent 532642b commit 39ba730
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// Prevent multiple inclusion
#pragma once

#include <app/util/endpoint-config-defines.h>
#include <lib/core/CHIPConfig.h>

// Default values for the attributes longer than a pointer,
Expand Down Expand Up @@ -267,24 +268,6 @@

#define GENERATED_DEFAULTS_COUNT (32)

#define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE
#define ZAP_LONG_DEFAULTS_INDEX(index) \
{ \
&generatedDefaults[index] \
}
#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \
{ \
&minMaxDefaults[index] \
}
#define ZAP_EMPTY_DEFAULT() \
{ \
(uint32_t) 0 \
}
#define ZAP_SIMPLE_DEFAULT(x) \
{ \
(uint32_t) x \
}

// This is an array of EmberAfAttributeMinMaxValue structures.
#define GENERATED_MIN_MAX_DEFAULT_COUNT 47
#define GENERATED_MIN_MAX_DEFAULTS \
Expand Down Expand Up @@ -370,7 +353,6 @@
} /* StartUpOnOff */ \
}

#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask
// This is an array of EmberAfAttributeMetadata structures.
#define GENERATED_ATTRIBUTE_COUNT 718
#define GENERATED_ATTRIBUTES \
Expand Down Expand Up @@ -1486,11 +1468,6 @@
{ ZAP_EMPTY_DEFAULT(), 0x0000FFFD, 2, ZAP_TYPE(INT16U), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* ClusterRevision */ \
}

// This is an array of EmberAfCluster structures.
#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index])

#define ZAP_GENERATED_COMMANDS_INDEX(index) (&generatedCommands[index])

// clang-format off
#define GENERATED_EVENT_COUNT 23
#define GENERATED_EVENTS { \
Expand Down Expand Up @@ -1539,8 +1516,6 @@

// clang-format on

#define ZAP_GENERATED_EVENTS_INDEX(index) (&generatedEvents[index])

// Cluster function static arrays
#define GENERATED_FUNCTION_ARRAYS \
const EmberAfGenericClusterFunction chipFuncArrayIdentifyServer[] = { \
Expand Down Expand Up @@ -1948,9 +1923,8 @@

// clang-format on

#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask
// This is an array of EmberAfCluster structures.
#define GENERATED_CLUSTER_COUNT 78

// clang-format off
#define GENERATED_CLUSTERS { \
{ \
Expand Down Expand Up @@ -2971,8 +2945,6 @@

// clang-format on

#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index])

#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 77

// This is an array of EmberAfEndpointType structures.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// Prevent multiple inclusion
#pragma once

#include <app/util/endpoint-config-defines.h>
#include <lib/core/CHIPConfig.h>

// Default values for the attributes longer than a pointer,
Expand Down Expand Up @@ -59,24 +60,6 @@

#define GENERATED_DEFAULTS_COUNT (2)

#define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE
#define ZAP_LONG_DEFAULTS_INDEX(index) \
{ \
&generatedDefaults[index] \
}
#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \
{ \
&minMaxDefaults[index] \
}
#define ZAP_EMPTY_DEFAULT() \
{ \
(uint32_t) 0 \
}
#define ZAP_SIMPLE_DEFAULT(x) \
{ \
(uint32_t) x \
}

// This is an array of EmberAfAttributeMinMaxValue structures.
#define GENERATED_MIN_MAX_DEFAULT_COUNT 4
#define GENERATED_MIN_MAX_DEFAULTS \
Expand All @@ -97,7 +80,6 @@
} /* StartUpColorTemperatureMireds */ \
}

#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask
// This is an array of EmberAfAttributeMetadata structures.
#define GENERATED_ATTRIBUTE_COUNT 271
#define GENERATED_ATTRIBUTES \
Expand Down Expand Up @@ -543,11 +525,6 @@
{ ZAP_SIMPLE_DEFAULT(3), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \
}

// This is an array of EmberAfCluster structures.
#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index])

#define ZAP_GENERATED_COMMANDS_INDEX(index) (&generatedCommands[index])

// clang-format off
#define GENERATED_EVENT_COUNT 15
#define GENERATED_EVENTS { \
Expand Down Expand Up @@ -580,8 +557,6 @@

// clang-format on

#define ZAP_GENERATED_EVENTS_INDEX(index) (&generatedEvents[index])

// Cluster function static arrays
#define GENERATED_FUNCTION_ARRAYS \
const EmberAfGenericClusterFunction chipFuncArrayGroupsServer[] = { \
Expand Down Expand Up @@ -788,9 +763,8 @@

// clang-format on

#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask
// This is an array of EmberAfCluster structures.
#define GENERATED_CLUSTER_COUNT 29

// clang-format off
#define GENERATED_CLUSTERS { \
{ \
Expand Down Expand Up @@ -1174,8 +1148,6 @@

// clang-format on

#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index])

#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 28

// This is an array of EmberAfEndpointType structures.
Expand Down
18 changes: 16 additions & 2 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ uint16_t emberEndpointCount = 0;
// we need this data block for the defaults
#if (defined(GENERATED_DEFAULTS) && GENERATED_DEFAULTS_COUNT)
constexpr const uint8_t generatedDefaults[] = GENERATED_DEFAULTS;
#define ZAP_LONG_DEFAULTS_INDEX(index) \
{ \
&generatedDefaults[index] \
}
#endif // GENERATED_DEFAULTS

#if (defined(GENERATED_MIN_MAX_DEFAULTS) && GENERATED_MIN_MAX_DEFAULT_COUNT)
constexpr const EmberAfAttributeMinMaxValue minMaxDefaults[] = GENERATED_MIN_MAX_DEFAULTS;
#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \
{ \
&minMaxDefaults[index] \
}
#endif // GENERATED_MIN_MAX_DEFAULTS

#ifdef GENERATED_FUNCTION_ARRAYS
Expand All @@ -82,14 +90,20 @@ GENERATED_FUNCTION_ARRAYS

#ifdef GENERATED_COMMANDS
constexpr const chip::CommandId generatedCommands[] = GENERATED_COMMANDS;
#define ZAP_GENERATED_COMMANDS_INDEX(index) (&generatedCommands[index])
#endif // GENERATED_COMMANDS

#if (defined(GENERATED_EVENTS) && (GENERATED_EVENT_COUNT > 0))
constexpr const chip::EventId generatedEvents[] = GENERATED_EVENTS;
#define ZAP_GENERATED_EVENTS_INDEX(index) (&generatedEvents[index])
#endif // GENERATED_EVENTS

constexpr const EmberAfAttributeMetadata generatedAttributes[] = GENERATED_ATTRIBUTES;
constexpr const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS;
constexpr const EmberAfAttributeMetadata generatedAttributes[] = GENERATED_ATTRIBUTES;
#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index])

constexpr const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS;
#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index])

constexpr const EmberAfEndpointType generatedEmberAfEndpointTypes[] = GENERATED_ENDPOINT_TYPES;
constexpr const EmberAfDeviceType fixedDeviceTypeList[] = FIXED_DEVICE_TYPES;

Expand Down
33 changes: 33 additions & 0 deletions src/app/util/endpoint-config-defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

/**
* Defines used by endpoint_config.h that may be useful when manually creating
* endpoint configurations (e.g. for dynamic endpoints).
*/
#define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE
#define ZAP_EMPTY_DEFAULT() \
{ \
(uint32_t) 0 \
}
#define ZAP_SIMPLE_DEFAULT(x) \
{ \
(uint32_t) x \
}
#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask
#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask
21 changes: 2 additions & 19 deletions src/app/zap-templates/templates/app/endpoint_config.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <lib/core/CHIPConfig.h>
#include <app/util/endpoint-config-defines.h>

{{#endpoint_config allowUnknownStorageOption="false" spaceForDefaultValue=4}}

Expand All @@ -19,33 +20,19 @@

#define GENERATED_DEFAULTS_COUNT ({{endpoint_attribute_long_defaults_count}})

#define ZAP_TYPE(type) ZCL_ ## type ## _ATTRIBUTE_TYPE
#define ZAP_LONG_DEFAULTS_INDEX(index) { &generatedDefaults[index] }
#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) { &minMaxDefaults[index] }
#define ZAP_EMPTY_DEFAULT() {(uint32_t) 0}
#define ZAP_SIMPLE_DEFAULT(x) {(uint32_t) x}

// This is an array of EmberAfAttributeMinMaxValue structures.
#define GENERATED_MIN_MAX_DEFAULT_COUNT {{endpoint_attribute_min_max_count}}
#define GENERATED_MIN_MAX_DEFAULTS {{endpoint_attribute_min_max_list}}

#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_ ## mask
// This is an array of EmberAfAttributeMetadata structures.
#define GENERATED_ATTRIBUTE_COUNT {{endpoint_attribute_count}}
#define GENERATED_ATTRIBUTES {{ endpoint_attribute_list }}

// This is an array of EmberAfCluster structures.
#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index])

#define ZAP_GENERATED_COMMANDS_INDEX(index) (&generatedCommands[index])

// clang-format off
#define GENERATED_EVENT_COUNT {{ chip_endpoint_generated_event_count }}
#define GENERATED_EVENTS {{ chip_endpoint_generated_event_list }}
// clang-format on

#define ZAP_GENERATED_EVENTS_INDEX(index) (&generatedEvents[index])

// Cluster function static arrays
#define GENERATED_FUNCTION_ARRAYS {{chip_endpoint_generated_functions}}

Expand All @@ -62,16 +49,12 @@
{{/last}}
{{/chip_endpoint_generated_commands_list}}

#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_ ## mask
// This is an array of EmberAfCluster structures.
#define GENERATED_CLUSTER_COUNT {{endpoint_cluster_count}}


// clang-format off
#define GENERATED_CLUSTERS {{chip_endpoint_cluster_list}}
// clang-format on

#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index])

#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT {{chip_endpoint_data_version_count}}

// This is an array of EmberAfEndpointType structures.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39ba730

Please sign in to comment.