Price Common#

API and Callbacks for the Price Common Component.

This component provides common utility functions used by both the Price Server and Price Client components.

Modules#

EmberAfPriceCommonInfo

EmberAfScheduledPrice

API#

uint8_t
emberAfPluginPriceCommonGetCommonMatchingOrUnusedIndex(EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries, uint32_t newIssuerEventId, uint32_t newStartTime, bool expireTimedOut)

Return the best matching or other index to use for inserting new data.

void
emberAfPluginPriceCommonSort(EmberAfPriceCommonInfo *commonInfos, uint8_t *dataArray, uint16_t dataArrayBlockSizeInByte, uint16_t dataArraySize)

Sort price-related data structures.

void
emberAfPluginPriceCommonUpdateDurationForOverlappingEvents(EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Update durations to avoid overlapping the next event.

uint32_t
emberAfPluginPriceCommonSecondsUntilSecondIndexActive(EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Determine the time until the next index becomes active.

uint8_t
emberAfPluginPriceCommonFindValidEntries(uint8_t *validEntries, uint8_t numberOfEntries, EmberAfPriceCommonInfo *commonInfos, uint32_t earliestStartTime, uint32_t minIssuerEventId, uint8_t numberOfCommands)

Find valid entries in the EmberAfPriceCommonInfo structure array.

uint8_t
emberAfPluginPriceCommonServerGetActiveIndex(EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Return the index of the active entry in the EmberAfPriceCommonInfo array.

uint8_t
emberAfPluginPriceCommonServerGetFutureIndex(EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries, uint32_t *secUntilFutureEvent)

Return the index to the most recent entry that will become active in the future.

API Documentation#

emberAfPluginPriceCommonGetCommonMatchingOrUnusedIndex#

uint8_t emberAfPluginPriceCommonGetCommonMatchingOrUnusedIndex (EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries, uint32_t newIssuerEventId, uint32_t newStartTime, bool expireTimedOut)

Return the best matching or other index to use for inserting new data.

Parameters
N/AcommonInfos

An array of EmberAfPriceCommonInfo structures whose data is used to find the best available index.

N/AnumberOfEntries

The number of entries in the EmberAfPriceCommonInfo array.

N/AnewIssuerEventId

The issuerEventId of the new data. This is used to see if a match is present.

N/AnewStartTime

The startTime of the new data.

N/AexpireTimedOut

Treats any timed-out entries as invalid if set to true.

Returns

  • The best index - either a matching index, if found, or an invalid or timed out index.


Definition at line 113 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonSort#

void emberAfPluginPriceCommonSort (EmberAfPriceCommonInfo *commonInfos, uint8_t *dataArray, uint16_t dataArrayBlockSizeInByte, uint16_t dataArraySize)

Sort price-related data structures.

Parameters
N/AcommonInfos

The destination address to which the command should be sent.

N/AdataArray

The source endpoint used in the transmission.

N/AdataArrayBlockSizeInByte

The source endpoint used in the transmission.

N/AdataArraySize

The source endpoint used in the transmission.

This semi-generic sorting function can be used to sort all structures that utilizes the EmberAfPriceCommonInfo data type.


Definition at line 131 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonUpdateDurationForOverlappingEvents#

void emberAfPluginPriceCommonUpdateDurationForOverlappingEvents (EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Update durations to avoid overlapping the next event.

Parameters
N/AcommonInfos

An array of EmberAfPriceCommonInfo structures that will be evaluated.

N/AnumberOfEntries

The number of entries in the EmberAfPriceCommonInfo array.


Definition at line 143 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonSecondsUntilSecondIndexActive#

uint32_t emberAfPluginPriceCommonSecondsUntilSecondIndexActive (EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Determine the time until the next index becomes active.

Parameters
N/AcommonInfos

An array of EmberAfPriceCommonInfo structures that will be evaluated.

N/AnumberOfEntries

The number of entries in the EmberAfPriceCommonInfo array.

This function assumes the commonInfos[] array is already sorted by startTime from earliest to latest.


Definition at line 155 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonFindValidEntries#

uint8_t emberAfPluginPriceCommonFindValidEntries (uint8_t *validEntries, uint8_t numberOfEntries, EmberAfPriceCommonInfo *commonInfos, uint32_t earliestStartTime, uint32_t minIssuerEventId, uint8_t numberOfCommands)

Find valid entries in the EmberAfPriceCommonInfo structure array.

Parameters
N/AvalidEntries

An array of the same size as the EmberAfPriceCommonInfo array that will store the valid flag for each entry (true or false).

N/AnumberOfEntries

The number of entries in the validEntries array and the commonInfos array.

N/AcommonInfos

The EmberAfPriceCommonInfo array that will be searched for valid entries.

N/AearliestStartTime

A minimum start time such that all valid entries have a start time greater than or equal to this value. @minIssuerEventId A minimum event ID such that all valid entries have an issuerEventId greater than or equal to this. @numberOfRequestedCommands The maximum number of valid entries to be returned.

N/AminIssuerEventId
N/AnumberOfCommands

Returns

  • The number of valid commands found in the commonInfos array.


Definition at line 173 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonServerGetActiveIndex#

uint8_t emberAfPluginPriceCommonServerGetActiveIndex (EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries)

Return the index of the active entry in the EmberAfPriceCommonInfo array.

Parameters
N/AcommonInfos

The EmberAfPriceCommonInfo array that will be searched for an active entry.

N/AnumberOfEntries

The number of entries in the commonInfo array.

Search through array for the most recent active entry. "Issuer Event Id" has higher priority than "start time".

Returns

  • The index of the active entry, or 0xFF if an active entry is not found.


Definition at line 191 of file app/framework/plugin/price-common/price-common.h

emberAfPluginPriceCommonServerGetFutureIndex#

uint8_t emberAfPluginPriceCommonServerGetFutureIndex (EmberAfPriceCommonInfo *commonInfos, uint8_t numberOfEntries, uint32_t *secUntilFutureEvent)

Return the index to the most recent entry that will become active in the future.

Parameters
N/AcommonInfos

The EmberAfPriceCommonInfo array that will be searched for the entry. @numberOfEntries The number of entries in the commonInfo array. @secUntilFutureEvent The output pointer to the number of seconds until the next active entry.

N/AnumberOfEntries
N/AsecUntilFutureEvent

Returns

  • The index of the next-active entry, or 0xFF if an active entry is not found.


Definition at line 205 of file app/framework/plugin/price-common/price-common.h

Macro Definition Documentation#

EMBER_AF_PRICE_CLUSTER_SERVER_ENDPOINT_COUNT#

#define EMBER_AF_PRICE_CLUSTER_SERVER_ENDPOINT_COUNT
Value:
(1)

Definition at line 39 of file app/framework/plugin/price-common/price-common.h

EVENT_ID_UNSPECIFIED#

#define EVENT_ID_UNSPECIFIED
Value:
(0xFFFFFFFFUL)

Definition at line 42 of file app/framework/plugin/price-common/price-common.h

TARIFF_TYPE_UNSPECIFIED#

#define TARIFF_TYPE_UNSPECIFIED
Value:
(0xFFu)

Definition at line 43 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_PRICE_ACKNOWLEDGEMENT_MASK#

#define ZCL_PRICE_CLUSTER_PRICE_ACKNOWLEDGEMENT_MASK
Value:
(0x01u)

Definition at line 44 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_RESERVED_MASK#

#define ZCL_PRICE_CLUSTER_RESERVED_MASK
Value:
(0xFEu)

Definition at line 45 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_DURATION16_UNTIL_CHANGED#

#define ZCL_PRICE_CLUSTER_DURATION16_UNTIL_CHANGED
Value:
(0xFFFFu)

Definition at line 46 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_DURATION_SEC_UNTIL_CHANGED#

#define ZCL_PRICE_CLUSTER_DURATION_SEC_UNTIL_CHANGED
Value:
(0xFFFFFFFFUL)

Definition at line 47 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_END_TIME_NEVER#

#define ZCL_PRICE_CLUSTER_END_TIME_NEVER
Value:
(0xFFFFFFFFUL)

Definition at line 48 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_NUMBER_OF_EVENTS_ALL#

#define ZCL_PRICE_CLUSTER_NUMBER_OF_EVENTS_ALL
Value:
(0x00u)

Definition at line 49 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_START_TIME_NOW#

#define ZCL_PRICE_CLUSTER_START_TIME_NOW
Value:
(0x00000000UL)

Definition at line 50 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_WILDCARD_ISSUER_ID#

#define ZCL_PRICE_CLUSTER_WILDCARD_ISSUER_ID
Value:
(0xFFFFFFFFUL)

Definition at line 51 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_INVALID_ENDPOINT_INDEX#

#define ZCL_PRICE_INVALID_ENDPOINT_INDEX
Value:
(0xFFu)

Definition at line 52 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_INVALID_INDEX#

#define ZCL_PRICE_INVALID_INDEX
Value:
(0xFFu)

Definition at line 53 of file app/framework/plugin/price-common/price-common.h

ZCL_PRICE_CLUSTER_DURATION_UNTIL_CHANGED#

#define ZCL_PRICE_CLUSTER_DURATION_UNTIL_CHANGED
Value:
(0xFFFFu)

Definition at line 54 of file app/framework/plugin/price-common/price-common.h