Skip to content

Commit

Permalink
Ember attribute storage API surface simplification (project-chip#31611)
Browse files Browse the repository at this point in the history
* Remove more unused defines and declarations

* Restyle

* Remove support for include overrides

* Add extra space, to not re-order include (not sure if include ordering matters here)

* Remove duplicated include

* Remove more macros that were syntaxed to look like functions
  • Loading branch information
andy31415 authored Jan 23, 2024
1 parent ade3abd commit e06d8ad
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ typedef struct
} State;
static State state;

#ifdef EMBER_SCRIPTED_TEST
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_OPEN_PERIOD_ATTRIBUTE
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_CLOSE_PERIOD_ATTRIBUTE
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_OPEN_EVENTS_ATTRIBUTE
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_CLOSE_EVENTS_ATTRIBUTE
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_OPEN_EVENTS_ATTRIBUTE
#define ZCL_USING_BARRIER_CONTROL_CLUSTER_BARRIER_COMMAND_CLOSE_EVENTS_ATTRIBUTE
#endif

/**********************************************************
* Matter timer scheduling glue logic
*********************************************************/
Expand Down
8 changes: 0 additions & 8 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t

/** @} END addtogroup */

#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
#if defined(EMBER_TEST)
#define EMBER_TEST_ASSERT(x) assert(x)
#else
#define EMBER_TEST_ASSERT(x)
#endif
#endif

/**
* Returns the pointer to the data version storage for the given endpoint and
* cluster. Can return null in the following cases:
Expand Down
33 changes: 9 additions & 24 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ constexpr const EmberAfDeviceType fixedDeviceTypeList[] = FIXED_DEVI
// Not const, because these need to mutate.
DataVersion fixedEndpointDataVersions[ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT];

#if !defined(EMBER_SCRIPTED_TEST)
#define endpointNumber(x) fixedEndpoints[x]
#define endpointDeviceTypeList(x) \
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[x]], fixedDeviceTypeListLengths[x])
// Added 'Macro' to silence MISRA warning about conflict with synonymous vars.
#define endpointTypeMacro(x) (&(generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[x]]))
#endif

AttributeAccessInterface * gAttributeAccessOverrides = nullptr;

// shouldUnregister returns true if the given AttributeAccessInterface should be
Expand Down Expand Up @@ -186,12 +178,10 @@ void emberAfEndpointConfigure()
static_assert(FIXED_ENDPOINT_COUNT <= std::numeric_limits<decltype(ep)>::max(),
"FIXED_ENDPOINT_COUNT must not exceed the size of the endpoint data type");

#if !defined(EMBER_SCRIPTED_TEST)
uint16_t fixedEndpoints[] = FIXED_ENDPOINT_ARRAY;
uint16_t fixedDeviceTypeListLengths[] = FIXED_DEVICE_TYPE_LENGTHS;
uint16_t fixedDeviceTypeListOffsets[] = FIXED_DEVICE_TYPE_OFFSETS;
uint8_t fixedEmberAfEndpointTypes[] = FIXED_ENDPOINT_TYPES;
#endif

#if ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT > 0
// Initialize our data version storage. If
Expand All @@ -210,10 +200,11 @@ void emberAfEndpointConfigure()
DataVersion * currentDataVersions = fixedEndpointDataVersions;
for (ep = 0; ep < FIXED_ENDPOINT_COUNT; ep++)
{
emAfEndpoints[ep].endpoint = endpointNumber(ep);
emAfEndpoints[ep].deviceTypeList = endpointDeviceTypeList(ep);
emAfEndpoints[ep].endpointType = endpointTypeMacro(ep);
emAfEndpoints[ep].dataVersions = currentDataVersions;
emAfEndpoints[ep].endpoint = fixedEndpoints[ep];
emAfEndpoints[ep].deviceTypeList =
Span<const EmberAfDeviceType>(&fixedDeviceTypeList[fixedDeviceTypeListOffsets[ep]], fixedDeviceTypeListLengths[ep]);
emAfEndpoints[ep].endpointType = &generatedEmberAfEndpointTypes[fixedEmberAfEndpointTypes[ep]];
emAfEndpoints[ep].dataVersions = currentDataVersions;

emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isEnabled);
emAfEndpoints[ep].bitmask.Set(EmberAfEndpointOptions::isFlatComposition);
Expand Down Expand Up @@ -918,10 +909,7 @@ uint16_t emberAfGetClusterServerEndpointIndex(EndpointId endpoint, ClusterId clu

bool emberAfEndpointIsEnabled(EndpointId endpoint)
{
uint16_t index = findIndexFromEndpoint(endpoint,
false); // ignore disabled endpoints?

EMBER_TEST_ASSERT(kEmberInvalidEndpointIndex != index);
uint16_t index = findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);

if (kEmberInvalidEndpointIndex == index)
{
Expand All @@ -933,8 +921,7 @@ bool emberAfEndpointIsEnabled(EndpointId endpoint)

bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable)
{
uint16_t index = findIndexFromEndpoint(endpoint,
false); // ignore disabled endpoints?
uint16_t index = findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
bool currentlyEnabled;

if (kEmberInvalidEndpointIndex == index)
Expand Down Expand Up @@ -990,15 +977,13 @@ bool emberAfEndpointEnableDisable(EndpointId endpoint, bool enable)
// Returns the index of a given endpoint. Does not consider disabled endpoints.
uint16_t emberAfIndexFromEndpoint(EndpointId endpoint)
{
return findIndexFromEndpoint(endpoint,
true); // ignore disabled endpoints?
return findIndexFromEndpoint(endpoint, true /* ignoreDisabledEndpoints */);
}

// Returns the index of a given endpoint. Considers disabled endpoints.
uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(EndpointId endpoint)
{
return findIndexFromEndpoint(endpoint,
false); // ignore disabled endpoints?
return findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
}

EndpointId emberAfEndpointFromIndex(uint16_t index)
Expand Down
16 changes: 0 additions & 16 deletions src/app/util/attribute-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,8 @@
#include <app/util/endpoint-config-api.h>
#include <lib/support/CodeUtils.h>

#if !defined(EMBER_SCRIPTED_TEST)
#include <app/att-storage.h>
#endif

#if !defined(ATTRIBUTE_STORAGE_CONFIGURATION) && defined(EMBER_TEST)
#define ATTRIBUTE_STORAGE_CONFIGURATION "attribute-storage-test.h"
#endif

// ATTRIBUTE_STORAGE_CONFIGURATION macro
// contains the file that contains the initial set-up of the
// attribute data structures. If it is missing
// we use the provider sample.
#ifndef ATTRIBUTE_STORAGE_CONFIGURATION
// #error "Must define ATTRIBUTE_STORAGE_CONFIGURATION to specify the App. Builder default attributes file."
#include <zap-generated/endpoint_config.h>
#else
#include ATTRIBUTE_STORAGE_CONFIGURATION
#endif

// If we have fixed number of endpoints, then max is the same.
#ifdef FIXED_ENDPOINT_COUNT
Expand Down
11 changes: 0 additions & 11 deletions src/app/util/attribute-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@

using namespace chip;

//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// External Declarations

//------------------------------------------------------------------------------
// Forward Declarations

//------------------------------------------------------------------------------
// Globals

EmberAfStatus emberAfWriteAttributeExternal(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr,
EmberAfAttributeType dataType)
{
Expand Down
2 changes: 0 additions & 2 deletions src/app/util/attribute-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <app/util/af.h>

#define ZCL_NULL_ATTRIBUTE_TABLE_INDEX 0xFFFF

// Remote devices writing attributes of local device
EmberAfStatus emberAfWriteAttributeExternal(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID,
uint8_t * dataPtr, EmberAfAttributeType dataType);
Expand Down
15 changes: 0 additions & 15 deletions src/app/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,9 @@

#if !CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES

// include generated configuration information from AppBuilder.
// ZA_GENERATED_HEADER is defined in the project file
#ifdef ZA_GENERATED_HEADER
#include ZA_GENERATED_HEADER
#else
#include <zap-generated/gen_config.h>
#endif

#ifdef ATTRIBUTE_STORAGE_CONFIGURATION
#include ATTRIBUTE_STORAGE_CONFIGURATION
#else
#include <zap-generated/endpoint_config.h>
#endif

#endif // !CHIP_CONFIG_SKIP_APP_SPECIFIC_GENERATED_HEADER_INCLUDES

Expand All @@ -42,8 +32,3 @@
#ifndef EMBER_BINDING_TABLE_SIZE
#define EMBER_BINDING_TABLE_SIZE 10
#endif // EMBER_BINDING_TABLE_SIZE

/**
* @brief CHIP uses millisecond ticks
*/
#define MILLISECOND_TICKS_PER_SECOND 1000

0 comments on commit e06d8ad

Please sign in to comment.