From b24866225a6301d3a663f874725e83c012dc25d3 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 26 Dec 2012 17:36:00 +0100 Subject: digital/beacon: add bitcloud stack into common directory digital/zigbit --- .../stack/Components/ZCL/include/zclPriceCluster.h | 267 +++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h (limited to 'digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h') diff --git a/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h new file mode 100644 index 00000000..0769596b --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclPriceCluster.h @@ -0,0 +1,267 @@ +/************************************************************************//** + \file zclPriceCluster.h + + \brief + The header file describes the Price Cluster. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 05.02.09 A. Mandychev - Changed. +******************************************************************************/ + +#ifndef _ZCLPRICECLUSTER_H +#define _ZCLPRICECLUSTER_H + +/****************************************************************************** + Includes section +******************************************************************************/ +#include +#include + +/****************************************************************************** + Defines section +******************************************************************************/ +/** +\brief Macros defines duration of Publish Price command, + * which means 'until change'. + * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197. +*/ +#define PUBLISH_PRICE_DURATION_UNTIL_CHANGED (0xFFFF) + +/** +\brief Macros defines start time of Publish Price command, + * which means 'now'. + * According to ZB AMI Spec r15, D.4.2.4.1.1, page 197. +*/ +#define PUBLISH_PRICE_START_TIME_NOW (0x0000) + +/** +\brief Macros defines Price Ratio field special value, + * which means 'not used'. + * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198. +*/ +#define PUBLISH_PRICE_PRICE_RATIO_IS_NOT_USED (0xFF) + +/** +\brief Macros defines Generation Price Ratio field special value, + * which means 'not used'. + * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198. +*/ +#define PUBLISH_PRICE_GENERATION_PRICE_RATIO_IS_NOT_USED (0xFF) + +/** +\brief Macros defines Generation Price field special value, + * which means 'not used'. + * According to ZB AMI Spec r15, D.4.2.4.1.1, page 198. +*/ +#define PUBLISH_PRICE_GENERATION_PRICE_IS_NOT_USED (0xFFFFFFFF) + +/** +\brief Macros defines Number Of Block Thresholds field special value, + * which means 'not used'. + * According to ZigBee-095310r23ZB, page 65. +*/ +#define PUBLISH_NUMBER_OF_BLOCK_THRESHOLDS_IS_NOT_USED (0xFF) + +/** +\brief Macros defines Price Control field special value, + * which means 'not used'. + * According to ZigBee-095310r23ZB, page 65. +*/ +#define PUBLISH_PRICE_CONTROL_IS_NOT_USED (0x00) + +/** +\brief Macros defines Standing Charge field special value, + * which means 'not used'. + * According to ZigBee-095310r23ZB, page 65. +*/ +#define PUBLISH_STANDING_CHARGE_IS_NOT_USED (0xFFFFFFFF) + +/** + * \brief Price Server Cluster attributes amount. +*/ +#define PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT 0 + +/** + * \brief Price Client Cluster attributes amount. +*/ +#define PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT 0 + +/** + * \brief Price Client Cluster commands amount. +*/ +#define PRICE_CLUSTER_COMMANDS_AMOUNT 3 + +/** + * \brief Price Server Cluster commands identifiers. +*/ +#define PUBLISH_PRICE_COMMAND_ID 0x00 + +/** + * \brief Price Client Cluster commands identifiers. +*/ +#define GET_CURRENT_PRICE_COMMAND_ID 0x00 +#define GET_SCHEDULED_PRICES_COMMAND_ID 0x01 + +#define RATE_LABEL_MAX_LEN 12 + +/* +#define DEMAND_RESPONSE_CLUSTER_SERVER_COMMANDS(publishPriceInd) \ + DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT), publishPriceInd) + + +#define DEMAND_RESPONSE_CLUSTER_CLIENT_COMMANDS(getCurrentPriceInd) \ + DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER), getCurrentPriceInd) +*/ + +#define PRICE_CLUSTER_COMMANDS(getCurrentPriceInd, publishPriceInd, getScheduledPricesInd) \ + DEFINE_COMMAND(getCurrentPriceCommand, 0x00, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getCurrentPriceInd), \ + DEFINE_COMMAND(publishPriceCommand, 0x00, COMMAND_OPTIONS(SERVER_TO_CLIENT, ZCL_THERE_IS_NO_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), publishPriceInd), \ + DEFINE_COMMAND(getScheduledPricesCommand, GET_SCHEDULED_PRICES_COMMAND_ID, COMMAND_OPTIONS(CLIENT_TO_SERVER, ZCL_THERE_IS_RELEVANT_RESPONSE, ZCL_COMMAND_ACK), getScheduledPricesInd) + +#define PRICE_CLUSTER_ZCL_CLIENT_CLUSTER_TYPE(clattributes, clcommands) \ + { \ + .id = PRICE_CLUSTER_ID, \ + .options = {.type = ZCL_CLIENT_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \ + .attributesAmount = PRICE_CLUSTER_CLIENT_ATTRIBUTES_AMOUNT, \ + .attributes = (uint8_t *)clattributes, \ + .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \ + .commands = (uint8_t *)clcommands \ + } + +#define PRICE_CLUSTER_ZCL_SERVER_CLUSTER_TYPE(clattributes, clcommands) \ + { \ + .id = PRICE_CLUSTER_ID, \ + .options = {.type = ZCL_SERVER_CLUSTER_TYPE, .security = ZCL_APPLICATION_LINK_KEY_CLUSTER_SECURITY}, \ + .attributesAmount = PRICE_CLUSTER_SERVER_ATTRIBUTES_AMOUNT, \ + .attributes = (uint8_t *)clattributes, \ + .commandsAmount = PRICE_CLUSTER_COMMANDS_AMOUNT, \ + .commands = (uint8_t *)clcommands \ + } +#define DEFINE_PRICE_CLUSTER(cltype, clattributes, clcommands) PRICE_CLUSTER_##cltype(clattributes, clcommands) + +/****************************************************************************** + Types section +******************************************************************************/ +BEGIN_PACK +/** + * \brief Publish Price Command Payload format. +*/ +typedef struct PACK +{ + uint32_t providerId; + uint8_t rateLabelLength; + uint8_t rateLabel[RATE_LABEL_MAX_LEN]; + uint32_t issuerEventId; + ZCL_UTCTime_t currentTime; + uint8_t unitOfMeasure; + uint16_t currency; + struct PACK + { + LITTLE_ENDIAN_OCTET(2,( + uint8_t priceTrailDigit : 4, + uint8_t priceTier : 4 + )) + } priceTrailDigitPriceTier; + struct PACK + { + LITTLE_ENDIAN_OCTET(2,( + uint8_t numberOfPriceTiers : 4, + uint8_t registerTier : 4 + )) + } numberOfPriceTiersRegisterTier; + ZCL_UTCTime_t startTime; + uint16_t durationInMinutes; + uint32_t price; + uint8_t priceRatio; + uint32_t generationPrice; + uint8_t generationPriceRatio; + uint32_t alternateCostDelivered; + uint8_t alternateCostUnit; + uint8_t alternateCostTrailingDigit; + uint8_t numberOfBlockThresholds; + uint8_t priceControl; + uint32_t standingCharge; +} ZCL_PublishPrice_t; + +/** + * \brief Get Current Price Command Payload format. +*/ +typedef struct PACK +{ + LITTLE_ENDIAN_OCTET(2,( + uint8_t requestorRxOnWhenIdle :1, //!