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#

sl_zigbee_af_price_common_info_t

sl_zigbee_af_scheduled_price_t

API#

uint8_t
sl_zigbee_af_price_common_get_common_matching_or_unused_index(sl_zigbee_af_price_common_info_t *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
sl_zigbee_af_price_common_sort(sl_zigbee_af_price_common_info_t *commonInfos, uint8_t *dataArray, uint16_t dataArrayBlockSizeInByte, uint16_t dataArraySize)

Sort price-related data structures.

void
sl_zigbee_af_price_common_update_duration_for_overlapping_events(sl_zigbee_af_price_common_info_t *commonInfos, uint8_t numberOfEntries)

Update durations to avoid overlapping the next event.

uint32_t
sl_zigbee_af_price_common_seconds_until_second_index_active(sl_zigbee_af_price_common_info_t *commonInfos, uint8_t numberOfEntries)

Determine the time until the next index becomes active.

uint8_t
sl_zigbee_af_price_common_find_valid_entries(uint8_t *validEntries, uint8_t numberOfEntries, sl_zigbee_af_price_common_info_t *commonInfos, uint32_t earliestStartTime, uint32_t minIssuerEventId, uint8_t numberOfCommands)

Find valid entries in the sl_zigbee_af_price_common_info_t structure array.

uint8_t
sl_zigbee_af_price_common_server_get_active_index(sl_zigbee_af_price_common_info_t *commonInfos, uint8_t numberOfEntries)

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

uint8_t
sl_zigbee_af_price_common_server_get_future_index(sl_zigbee_af_price_common_info_t *commonInfos, uint8_t numberOfEntries, uint32_t *secUntilFutureEvent)

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

Macros#

#define
SL_ZIGBEE_ZCL_PRICE_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define
EVENT_ID_UNSPECIFIED (0xFFFFFFFFUL)
#define
TARIFF_TYPE_UNSPECIFIED (0xFFu)
#define
ZCL_PRICE_CLUSTER_PRICE_ACKNOWLEDGEMENT_MASK (0x01u)
#define
ZCL_PRICE_CLUSTER_RESERVED_MASK (0xFEu)
#define
ZCL_PRICE_CLUSTER_DURATION16_UNTIL_CHANGED (0xFFFFu)
#define
ZCL_PRICE_CLUSTER_DURATION_SEC_UNTIL_CHANGED (0xFFFFFFFFUL)
#define
ZCL_PRICE_CLUSTER_END_TIME_NEVER (0xFFFFFFFFUL)
#define
ZCL_PRICE_CLUSTER_NUMBER_OF_EVENTS_ALL (0x00u)
#define
ZCL_PRICE_CLUSTER_START_TIME_NOW (0x00000000UL)
#define
ZCL_PRICE_CLUSTER_WILDCARD_ISSUER_ID (0xFFFFFFFFUL)
#define
ZCL_PRICE_INVALID_ENDPOINT_INDEX (0xFFu)
#define
ZCL_PRICE_INVALID_INDEX (0xFFu)
#define
ZCL_PRICE_CLUSTER_DURATION_UNTIL_CHANGED (0xFFFFu)

API Documentation#

sl_zigbee_af_price_common_get_common_matching_or_unused_index#

uint8_t sl_zigbee_af_price_common_get_common_matching_or_unused_index (sl_zigbee_af_price_common_info_t * 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
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

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

uint8_tN/AnumberOfEntries

The number of entries in the sl_zigbee_af_price_common_info_t array.

uint32_tN/AnewIssuerEventId

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

uint32_tN/AnewStartTime

The startTime of the new data.

boolN/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.


sl_zigbee_af_price_common_sort#

void sl_zigbee_af_price_common_sort (sl_zigbee_af_price_common_info_t * commonInfos, uint8_t * dataArray, uint16_t dataArrayBlockSizeInByte, uint16_t dataArraySize)

Sort price-related data structures.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

The destination address to which the command should be sent.

uint8_t *N/AdataArray

The source endpoint used in the transmission.

uint16_tN/AdataArrayBlockSizeInByte

The source endpoint used in the transmission.

uint16_tN/AdataArraySize

The source endpoint used in the transmission.

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


sl_zigbee_af_price_common_update_duration_for_overlapping_events#

void sl_zigbee_af_price_common_update_duration_for_overlapping_events (sl_zigbee_af_price_common_info_t * commonInfos, uint8_t numberOfEntries)

Update durations to avoid overlapping the next event.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

An array of sl_zigbee_af_price_common_info_t structures that will be evaluated.

uint8_tN/AnumberOfEntries

The number of entries in the sl_zigbee_af_price_common_info_t array.


sl_zigbee_af_price_common_seconds_until_second_index_active#

uint32_t sl_zigbee_af_price_common_seconds_until_second_index_active (sl_zigbee_af_price_common_info_t * commonInfos, uint8_t numberOfEntries)

Determine the time until the next index becomes active.

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

An array of sl_zigbee_af_price_common_info_t structures that will be evaluated.

uint8_tN/AnumberOfEntries

The number of entries in the sl_zigbee_af_price_common_info_t array.

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


sl_zigbee_af_price_common_find_valid_entries#

uint8_t sl_zigbee_af_price_common_find_valid_entries (uint8_t * validEntries, uint8_t numberOfEntries, sl_zigbee_af_price_common_info_t * commonInfos, uint32_t earliestStartTime, uint32_t minIssuerEventId, uint8_t numberOfCommands)

Find valid entries in the sl_zigbee_af_price_common_info_t structure array.

Parameters
TypeDirectionArgument NameDescription
uint8_t *N/AvalidEntries

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

uint8_tN/AnumberOfEntries

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

sl_zigbee_af_price_common_info_t *N/AcommonInfos

The sl_zigbee_af_price_common_info_t array that will be searched for valid entries.

uint32_tN/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.

uint32_tN/AminIssuerEventId
uint8_tN/AnumberOfCommands

Returns

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


sl_zigbee_af_price_common_server_get_active_index#

uint8_t sl_zigbee_af_price_common_server_get_active_index (sl_zigbee_af_price_common_info_t * commonInfos, uint8_t numberOfEntries)

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

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

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

uint8_tN/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.


sl_zigbee_af_price_common_server_get_future_index#

uint8_t sl_zigbee_af_price_common_server_get_future_index (sl_zigbee_af_price_common_info_t * commonInfos, uint8_t numberOfEntries, uint32_t * secUntilFutureEvent)

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

Parameters
TypeDirectionArgument NameDescription
sl_zigbee_af_price_common_info_t *N/AcommonInfos

The sl_zigbee_af_price_common_info_t 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.

uint8_tN/AnumberOfEntries
uint32_t *N/AsecUntilFutureEvent

Returns

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