diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 3f8ca3fceb3398..16b2a54da783d7 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -280,7 +280,7 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) uint8_t buffer[kFixedLabelAttributeArraySize]; EmberAfAttributeMetadata am = { .attributeId = ZCL_LABEL_LIST_ATTRIBUTE_ID, .size = kFixedLabelAttributeArraySize, - .defaultValue = nullptr }; + .defaultValue = static_cast(0) }; EncodeFixedLabel("room", dev->GetLocation(), buffer, sizeof(buffer), &am); diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index 3f521173e79eef..73d9f646c12577 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -101,7 +101,7 @@ typedef void (*EmberAfGenericClusterFunction)(void); */ union EmberAfDefaultAttributeValue { - constexpr EmberAfDefaultAttributeValue(uint8_t * ptr) : ptrToDefaultValue(ptr) {} + constexpr EmberAfDefaultAttributeValue(const uint8_t * ptr) : ptrToDefaultValue(ptr) {} constexpr EmberAfDefaultAttributeValue(uint16_t val) : defaultValue(val) {} /** @@ -109,7 +109,7 @@ union EmberAfDefaultAttributeValue * If size is more than 2 bytes, and this value is NULL, * then the default value is all zeroes. */ - uint8_t * ptrToDefaultValue; + const uint8_t * ptrToDefaultValue; /** * Actual default value if the attribute size is 2 bytes or less. @@ -144,15 +144,16 @@ typedef struct */ union EmberAfDefaultOrMinMaxAttributeValue { - constexpr EmberAfDefaultOrMinMaxAttributeValue(uint8_t * ptr) : ptrToDefaultValue(ptr) {} + constexpr EmberAfDefaultOrMinMaxAttributeValue(const uint8_t * ptr) : ptrToDefaultValue(ptr) {} constexpr EmberAfDefaultOrMinMaxAttributeValue(uint16_t val) : defaultValue(val) {} + constexpr EmberAfDefaultOrMinMaxAttributeValue(const EmberAfAttributeMinMaxValue * ptr) : ptrToMinMaxValue(ptr) {} /** * Points to data if size is more than 2 bytes. * If size is more than 2 bytes, and this value is NULL, * then the default value is all zeroes. */ - uint8_t * ptrToDefaultValue; + const uint8_t * ptrToDefaultValue; /** * Actual default value if the attribute size is 2 bytes or less. */ @@ -161,7 +162,7 @@ union EmberAfDefaultOrMinMaxAttributeValue * Points to the min max attribute value structure, if min/max is * supported for this attribute. */ - EmberAfAttributeMinMaxValue * ptrToMinMaxValue; + const EmberAfAttributeMinMaxValue * ptrToMinMaxValue; }; // Attribute masks modify how attributes are used by the framework diff --git a/src/app/util/af.h b/src/app/util/af.h index 2a9824fffb7a4d..a0a743c9c0cee2 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -732,7 +732,7 @@ uint8_t emberAfGetLastSequenceNumber(void); * greater than 4 is being compared * 1, if val2 is smaller. */ -int8_t emberAfCompareValues(uint8_t * val1, uint8_t * val2, uint16_t len, bool signedNumber); +int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t len, bool signedNumber); /** * @brief populates the passed EUI64 with the local EUI64 MAC address. diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index b542a224d31771..7cdd712a33ec12 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -68,6 +68,8 @@ EmberAfDefinedEndpoint emAfEndpoints[MAX_ENDPOINT_COUNT]; uint8_t attributeData[ACTUAL_ATTRIBUTE_SIZE]; +namespace { + #if (!defined(ATTRIBUTE_SINGLETONS_SIZE)) || (ATTRIBUTE_SINGLETONS_SIZE == 0) #define ACTUAL_SINGLETONS_SIZE 1 #else @@ -80,25 +82,25 @@ uint16_t emberEndpointCount = 0; // If we have attributes that are more than 2 bytes, then // we need this data block for the defaults #if (defined(GENERATED_DEFAULTS) && GENERATED_DEFAULTS_COUNT) -const uint8_t generatedDefaults[] = GENERATED_DEFAULTS; +constexpr const uint8_t generatedDefaults[] = GENERATED_DEFAULTS; #endif // GENERATED_DEFAULTS #if (defined(GENERATED_MIN_MAX_DEFAULTS) && GENERATED_MIN_MAX_DEFAULT_COUNT) -const EmberAfAttributeMinMaxValue minMaxDefaults[] = GENERATED_MIN_MAX_DEFAULTS; +constexpr const EmberAfAttributeMinMaxValue minMaxDefaults[] = GENERATED_MIN_MAX_DEFAULTS; #endif // GENERATED_MIN_MAX_DEFAULTS #ifdef GENERATED_FUNCTION_ARRAYS GENERATED_FUNCTION_ARRAYS #endif -const EmberAfAttributeMetadata generatedAttributes[] = GENERATED_ATTRIBUTES; -const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS; -const EmberAfEndpointType generatedEmberAfEndpointTypes[] = GENERATED_ENDPOINT_TYPES; +constexpr const EmberAfAttributeMetadata generatedAttributes[] = GENERATED_ATTRIBUTES; +constexpr const EmberAfCluster generatedClusters[] = GENERATED_CLUSTERS; +constexpr const EmberAfEndpointType generatedEmberAfEndpointTypes[] = GENERATED_ENDPOINT_TYPES; -const EmberAfManufacturerCodeEntry clusterManufacturerCodes[] = GENERATED_CLUSTER_MANUFACTURER_CODES; -const uint16_t clusterManufacturerCodeCount = GENERATED_CLUSTER_MANUFACTURER_CODE_COUNT; -const EmberAfManufacturerCodeEntry attributeManufacturerCodes[] = GENERATED_ATTRIBUTE_MANUFACTURER_CODES; -const uint16_t attributeManufacturerCodeCount = GENERATED_ATTRIBUTE_MANUFACTURER_CODE_COUNT; +constexpr const EmberAfManufacturerCodeEntry clusterManufacturerCodes[] = GENERATED_CLUSTER_MANUFACTURER_CODES; +constexpr const uint16_t clusterManufacturerCodeCount = GENERATED_CLUSTER_MANUFACTURER_CODE_COUNT; +constexpr const EmberAfManufacturerCodeEntry attributeManufacturerCodes[] = GENERATED_ATTRIBUTE_MANUFACTURER_CODES; +constexpr const uint16_t attributeManufacturerCodeCount = GENERATED_ATTRIBUTE_MANUFACTURER_CODE_COUNT; #if !defined(EMBER_SCRIPTED_TEST) #define endpointNumber(x) fixedEndpoints[x] @@ -109,7 +111,6 @@ const uint16_t attributeManufacturerCodeCount = GENERATED_ATTR #define endpointNetworkIndex(x) fixedNetworks[x] #endif -namespace { app::AttributeAccessInterface * gAttributeAccessOverrides = nullptr; } // anonymous namespace diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index b7b3eba24c6370..06dd3f17f1d3d1 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -899,7 +899,7 @@ void emberAfCopyLongString(uint8_t * dest, const uint8_t * src, size_t size) // You can pass in val1 as NULL, which will assume that it is // pointing to an array of all zeroes. This is used so that // default value of NULL is treated as all zeroes. -int8_t emberAfCompareValues(uint8_t * val1, uint8_t * val2, uint16_t len, bool signedNumber) +int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t len, bool signedNumber) { uint8_t i, j, k; if (signedNumber) diff --git a/src/app/zap-templates/templates/app/endpoint_config.zapt b/src/app/zap-templates/templates/app/endpoint_config.zapt index 46a43b0683f8cf..ed461482774e51 100644 --- a/src/app/zap-templates/templates/app/endpoint_config.zapt +++ b/src/app/zap-templates/templates/app/endpoint_config.zapt @@ -19,8 +19,8 @@ #define GENERATED_DEFAULTS_COUNT ({{endpoint_attribute_long_defaults_count}}) #define ZAP_TYPE(type) ZCL_ ## type ## _ATTRIBUTE_TYPE -#define ZAP_LONG_DEFAULTS_INDEX(index) {(uint8_t*)(&generatedDefaults[index])} -#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) {(uint8_t*)(&minMaxDefaults[index])} +#define ZAP_LONG_DEFAULTS_INDEX(index) { &generatedDefaults[index] } +#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) { &minMaxDefaults[index] } #define ZAP_EMPTY_DEFAULT() {(uint16_t) 0} #define ZAP_SIMPLE_DEFAULT(x) {(uint16_t) x} diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index b4dd24a7138f1d..e5159ecc6e8a47 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -1226,11 +1226,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/bridge-app/zap-generated/endpoint_config.h b/zzz_generated/bridge-app/zap-generated/endpoint_config.h index 6efaa11fe7efdb..a2cb01c6bcfe46 100644 --- a/zzz_generated/bridge-app/zap-generated/endpoint_config.h +++ b/zzz_generated/bridge-app/zap-generated/endpoint_config.h @@ -558,11 +558,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/controller-clusters/zap-generated/endpoint_config.h b/zzz_generated/controller-clusters/zap-generated/endpoint_config.h index f7b23d5166a294..f64db749d28538 100644 --- a/zzz_generated/controller-clusters/zap-generated/endpoint_config.h +++ b/zzz_generated/controller-clusters/zap-generated/endpoint_config.h @@ -90,11 +90,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/lighting-app/zap-generated/endpoint_config.h b/zzz_generated/lighting-app/zap-generated/endpoint_config.h index c7069c6b87970d..eac66699b844ef 100644 --- a/zzz_generated/lighting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lighting-app/zap-generated/endpoint_config.h @@ -522,11 +522,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/lock-app/zap-generated/endpoint_config.h b/zzz_generated/lock-app/zap-generated/endpoint_config.h index c135eb1ceff89a..352e54a5242791 100644 --- a/zzz_generated/lock-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lock-app/zap-generated/endpoint_config.h @@ -522,11 +522,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h b/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h index 3bd0ff2a999053..71dabda397a4e2 100644 --- a/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h +++ b/zzz_generated/ota-provider-app/zap-generated/endpoint_config.h @@ -98,11 +98,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h index fb9293f0dc71ac..c5aff2e4eb6783 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h +++ b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h @@ -98,11 +98,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h b/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h index 2e966fbdc219b8..9c108eead6c1bb 100644 --- a/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h +++ b/zzz_generated/placeholder/app1/zap-generated/endpoint_config.h @@ -144,11 +144,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h b/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h index a61dc6a16558ab..2bc2d8587f0dc2 100644 --- a/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h +++ b/zzz_generated/placeholder/app2/zap-generated/endpoint_config.h @@ -144,11 +144,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/pump-app/zap-generated/endpoint_config.h b/zzz_generated/pump-app/zap-generated/endpoint_config.h index 1b3b5b3df90dc1..52c1de77aefafe 100644 --- a/zzz_generated/pump-app/zap-generated/endpoint_config.h +++ b/zzz_generated/pump-app/zap-generated/endpoint_config.h @@ -540,11 +540,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h index 5ed79f5fd57bea..953f763645f888 100644 --- a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h +++ b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h @@ -512,11 +512,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h index 6ef4e4b35800e3..788acee2fcfb0b 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h +++ b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h @@ -244,11 +244,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/thermostat/zap-generated/endpoint_config.h b/zzz_generated/thermostat/zap-generated/endpoint_config.h index 05494a5253b250..f22e8f60fda957 100644 --- a/zzz_generated/thermostat/zap-generated/endpoint_config.h +++ b/zzz_generated/thermostat/zap-generated/endpoint_config.h @@ -606,11 +606,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/tv-app/zap-generated/endpoint_config.h b/zzz_generated/tv-app/zap-generated/endpoint_config.h index a1a8f238aada54..e72102dd5107c0 100644 --- a/zzz_generated/tv-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-app/zap-generated/endpoint_config.h @@ -1010,11 +1010,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h index d7493f13619366..df8eea42a2c944 100644 --- a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h @@ -1020,11 +1020,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \ diff --git a/zzz_generated/window-app/zap-generated/endpoint_config.h b/zzz_generated/window-app/zap-generated/endpoint_config.h index d7de1ac55950dc..e9f7f5edefae04 100644 --- a/zzz_generated/window-app/zap-generated/endpoint_config.h +++ b/zzz_generated/window-app/zap-generated/endpoint_config.h @@ -560,11 +560,11 @@ #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&generatedDefaults[index]) \ + &generatedDefaults[index] \ } #define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ { \ - (uint8_t *) (&minMaxDefaults[index]) \ + &minMaxDefaults[index] \ } #define ZAP_EMPTY_DEFAULT() \ { \