zcl_se.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. /**************************************************************************************************
  2. Filename: zcl_SE.h
  3. Revised: $Date: 2006-09-08 15:51:21 -0700 (Fri, 08 Sep 2006) $
  4. Revision: $Revision: 11934 $
  5. Description: This file contains the ZCL SE (Smart Energy) Profile definitions.
  6. Copyright 2007-2009 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef ZCL_SE_H
  34. #define ZCL_SE_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. #include "zcl.h"
  43. /*********************************************************************
  44. * CONSTANTS
  45. */
  46. /********************************************/
  47. /*** SE Profile Attributes List ************/
  48. /********************************************/
  49. // Simple Metering Attribute Set
  50. #define ATTRID_MASK_SE_READ_INFORMATION_SET 0x0000
  51. #define ATTRID_MASK_SE_TOU_INFORMATION_SET 0x0100
  52. #define ATTRID_MASK_SE_METER_STATUS 0x0200
  53. #define ATTRID_MASK_SE_FORMATTING 0x0300
  54. #define ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION 0x0400
  55. #define ATTRID_MASK_SE_LOAD_PROFILE_CONFIGURATION 0x0500
  56. // Simple Metering Cluster - Reading Information Set Attributes 0x00
  57. #define ATTRID_SE_CURRENT_SUMMATION_DELIVERED ( 0x0000 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  58. #define ATTRID_SE_CURRENT_SUMMATION_RECEIVED ( 0x0001 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  59. #define ATTRID_SE_CURRENT_MAX_DEMAND_DELIVERED ( 0x0002 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  60. #define ATTRID_SE_CURRENT_MAX_DEMAND_RECEIVED ( 0x0003 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  61. #define ATTRID_SE_DFT_SUMMATION ( 0x0004 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  62. #define ATTRID_SE_DAILY_FREEZE_TIME ( 0x0005 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  63. #define ATTRID_SE_POWER_FACTOR ( 0x0006 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  64. #define ATTRID_SE_READING_SNAPSHOT_TIME ( 0x0007 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  65. #define ATTRID_SE_CURRENT_MAX_DEMAND_DELIVERD_TIME ( 0x0008 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  66. #define ATTRID_SE_CURRENT_MAX_DEMAND_RECEIVED_TIME ( 0x0009 | ATTRID_MASK_SE_READ_INFORMATION_SET )
  67. // Simple Metering Cluster - TOU Information Set Attributes 0x01
  68. #define ATTRID_SE_CURRENT_TIER1_SUMMATION_DELIVERED ( 0x0000 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  69. #define ATTRID_SE_CURRENT_TIER1_SUMMATION_RECEIVED ( 0x0001 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  70. #define ATTRID_SE_CURRENT_TIER2_SUMMATION_DELIVERED ( 0x0002 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  71. #define ATTRID_SE_CURRENT_TIER2_SUMMATION_RECEIVED ( 0x0003 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  72. #define ATTRID_SE_CURRENT_TIER3_SUMMATION_DELIVERED ( 0x0004 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  73. #define ATTRID_SE_CURRENT_TIER3_SUMMATION_RECEIVED ( 0x0005 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  74. #define ATTRID_SE_CURRENT_TIER4_SUMMATION_DELIVERED ( 0x0006 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  75. #define ATTRID_SE_CURRENT_TIER4_SUMMATION_RECEIVED ( 0x0007 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  76. #define ATTRID_SE_CURRENT_TIER5_SUMMATION_DELIVERED ( 0x0008 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  77. #define ATTRID_SE_CURRENT_TIER5_SUMMATION_RECEIVED ( 0x0009 | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  78. #define ATTRID_SE_CURRENT_TIER6_SUMMATION_DELIVERED ( 0x000A | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  79. #define ATTRID_SE_CURRENT_TIER6_SUMMATION_RECEIVED ( 0x000B | ATTRID_MASK_SE_TOU_INFORMATION_SET )
  80. // Simple Metering Cluslter - Meter Status Attributes 0x02
  81. #define ATTRID_SE_STATUS ( 0x0000 | ATTRID_MASK_SE_METER_STATUS )
  82. // Simple Metering Cluster - Formatting Attributes 0x03
  83. #define ATTRID_SE_UNIT_OF_MEASURE ( 0x0000 | ATTRID_MASK_SE_FORMATTING )
  84. #define ATTRID_SE_MULTIPLIER ( 0x0001 | ATTRID_MASK_SE_FORMATTING )
  85. #define ATTRID_SE_DIVISOR ( 0x0002 | ATTRID_MASK_SE_FORMATTING )
  86. #define ATTRID_SE_SUMMATION_FORMATTING ( 0x0003 | ATTRID_MASK_SE_FORMATTING )
  87. #define ATTRID_SE_DEMAND_FORMATTING ( 0x0004 | ATTRID_MASK_SE_FORMATTING )
  88. #define ATTRID_SE_HISTORICAL_CONSUMPTION_FORMATTING ( 0x0005 | ATTRID_MASK_SE_FORMATTING )
  89. #define ATTRID_SE_METERING_DEVICE_TYPE ( 0x0006 | ATTRID_MASK_SE_FORMATTING )
  90. // Simple Metering Cluster - ESP Historical Comsumption Attributes 0x04
  91. #define ATTRID_SE_INSTANTANEOUS_DEMAND ( 0x0000 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  92. #define ATTRID_SE_CURRENTDAY_CONSUMPTION_DELIVERED ( 0x0001 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  93. #define ATTRID_SE_CURRENTDAY_CONSUMPTION_RECEIVED ( 0x0002 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  94. #define ATTRID_SE_PREVIOUSDAY_CONSUMPTION_DELIVERED ( 0x0003 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  95. #define ATTRID_SE_PREVIOUSDAY_CONSUMPTION_RECEIVED ( 0x0004 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  96. #define ATTRID_SE_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME ( 0x0005 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  97. #define ATTRID_SE_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE ( 0x0006 | ATTRID_MASK_SE_ESP_HISTORICAL_CONSUMPTION )
  98. // Simple Metering Cluster - Load Profile Configuration Attributes 0x05
  99. #define ATTRID_SE_MAX_NUMBER_OF_PERIODS_DELIVERED ( 0x0000 | ATTRID_MASK_SE_LOAD_PROFILE_CONFIGURATION )
  100. // Demand Response Client Cluster Attributes
  101. #define ATTRID_SE_UTILITY_DEFINED_GROUP 0x0000
  102. #define ATTRID_SE_START_RANDOMIZE_MINUTES 0x0001
  103. #define ATTRID_SE_STOP_RANDOMIZE_MINUTES 0x0002
  104. /************************************************************/
  105. /*** SE Profile Command ID ***/
  106. /************************************************************/
  107. // Simple Metering Cluster
  108. #define COMMAND_SE_GET_PROFILE_CMD 0x0000
  109. #define COMMAND_SE_GET_PROFILE_RSP 0x0000
  110. #define COMMAND_SE_REQ_MIRROR_CMD 0x0001
  111. #define COMMAND_SE_REQ_MIRROR_RSP 0x0001
  112. #define COMMAND_SE_MIRROR_REM_CMD 0x0002
  113. #define COMMAND_SE_MIRROR_REM_RSP 0x0002
  114. // Pricing Cluster
  115. #define COMMAND_SE_GET_CURRENT_PRICE 0x0000
  116. #define COMMAND_SE_GET_SCHEDULED_PRICE 0x0001
  117. #define COMMAND_SE_PUBLISH_PRICE 0x0000
  118. // Messaging Cluster
  119. #define COMMAND_SE_DISPLAY_MESSAGE 0x0000
  120. #define COMMAND_SE_CANCEL_MESSAGE 0x0001
  121. #define COMMAND_SE_GET_LAST_MESSAGE 0x0000
  122. #define COMMAND_SE_MESSAGE_CONFIRMATION 0x0001
  123. // Demand Response and Load Control Cluster
  124. #define COMMAND_SE_LOAD_CONTROL_EVENT 0x0000
  125. #define COMMAND_SE_CANCEL_LOAD_CONTROL_EVENT 0x0001
  126. #define COMMAND_SE_CANCEL_ALL_LOAD_CONTROL_EVENT 0x0002
  127. #define COMMAND_SE_REPORT_EVENT_STATUS 0x0000
  128. #define COMMAND_SE_GET_SCHEDULED_EVENT 0x0001
  129. /******************************************************************/
  130. /*** Other Constants ***/
  131. /******************************************************************/
  132. // Profile Interval Period Time Frame
  133. #define PROFILE_INTERVAL_PERIOD_DAILY 0
  134. #define PROFILE_INTERVAL_PERIOD_60MIN 1
  135. #define PROFILE_INTERVAL_PERIOD_30MIN 2
  136. #define PROFILE_INTERVAL_PERIOD_15MIN 3
  137. #define PROFILE_INTERVAL_PERIOD_10MIN 4
  138. #define PROFILE_INTERVAL_PERIOD_450SEC 5
  139. #define PROFILE_INTERVAL_PERIOD_300SEC 6
  140. #define PROFILE_INTERVAL_PERIOD_150SEC 7
  141. // Profile Interval Status
  142. #define PROFILE_INTERVAL_STAT_SUCCESS 0x00
  143. #define PROFILE_INTERVAL_STAT_UNDEFINED_CHANNEL 0x01
  144. #define PROFILE_INTERVAL_STAT_CHANNEL_NOT_SUPPORT 0x02
  145. #define PROFILE_INTERVAL_STAT_INVALID_END_TIME 0x03
  146. #define PROFILE_INTERVAL_STAT_TOO_MANY_PERIOD 0x04
  147. #define PROFILE_INTERVAL_STAT_NO_INTERVALS 0x05
  148. // Command Packet Length
  149. #define PACKET_LEN_SE_PUBLISH_PRICE 34
  150. #define PACKET_LEN_SE_LOAD_CONTROL_EVENT 23
  151. #define PACKET_LEN_SE_GET_SCHEDULED_EVENT 5
  152. #define PACKET_LEN_SE_CANCEL_LOAD_CONTROL_EVENT 12
  153. #define PACKET_LEN_SE_REPORT_EVENT_STATUS_ONLY 18
  154. #define PACKET_LEN_SE_REPORT_EVENT_STATUS (PACKET_LEN_SE_REPORT_EVENT_STATUS_ONLY + SE_PROFILE_SIGNATURE_LENGTH)
  155. // Maximum value for Command Fields Range Checking
  156. #define MAX_DURATION_IN_MINUTES_SE_LOAD_CONTROL 1440 // One day
  157. #define MAX_CRITICAL_LEVEL_SE_LOAD_CONTROL 0x0F
  158. #define MAX_TEMPERATURE_SETPOINT_SE_LOAD_CONTROL 0x7FFF
  159. #define MIN_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE -100
  160. #define MAX_AVERAGE_LOAD_ADJUSTMENT_PERCENTAGE_SE 100
  161. #define MAX_DUTY_CYCLE_SE_LOAD_CONTROL 100
  162. #define MAX_INTERVAL_CHANNEL_SE_SIMPLE_METERING 1
  163. #define MAX_PROFILE_INTERVAL_PERIOD_SE_SIMPLE_METERING 7
  164. #define MAX_UNIT_OF_MEASURE_SE 7
  165. // Device Class Field Bitmap
  166. #define SE_DEVICE_CLASS_HVAC_COMPRESSOR_FURNACE 0x0001
  167. #define SE_DEVICE_CLASS_STRIP_HEATER 0x0002
  168. #define SE_DEVICE_CLASS_WATER_HEATER 0x0004
  169. #define SE_DEVICE_CLASS_POOL_PUMP 0x0008
  170. #define SE_DEVICE_CLASS_SMART_APPLIANCES 0x0010
  171. #define SE_DEVICE_CLASS_IRRIGATION_PUMP 0x0020
  172. #define SE_DEVICE_CLASS_MANAGED_CI_LOADS 0x0040
  173. #define SE_DEVICE_CLASS_SIMPLE_MISC_LOADS 0x0080
  174. #define SE_DEVICE_CLASS_EXTERIOR_LIGHTING 0x0100
  175. #define SE_DEVICE_CLASS_INTERIOR_LIGHTING 0x0200
  176. #define SE_DEVICE_CLASS_ELECTRIC_VEHICLE 0x0400
  177. #define SE_DEVICE_CLASS_GENERATION_SYSTEMS 0x0800
  178. // Criticality Levels
  179. #define SE_CRITICALITY_LEVELS_GREEN 0x01
  180. #define SE_CRITICALITY_LEVELS_1 0x02
  181. #define SE_CRITICALITY_LEVELS_2 0x03
  182. #define SE_CRITICALITY_LEVELS_3 0x04
  183. #define SE_CRITICALITY_LEVELS_4 0x05
  184. #define SE_CRITICALITY_LEVELS_5 0x06
  185. #define SE_CRITICALITY_LEVELS_EMERGENCY 0x07
  186. #define SE_CRITICALITY_LEVELS_PLANNED_OUTAGE 0x08
  187. #define SE_CRITICALITY_LEVELS_SERVICE_DISCONNECT 0x09
  188. // Event Control Field Bitmap
  189. #define SE_EVENT_CONTROL_FIELD_START_TIME 0x01
  190. #define SE_EVENT_CONTROL_FIELD_END_TIME 0x02
  191. // Optional Fields Value
  192. #define SE_OPTIONAL_FIELD_UINT8 0xFF
  193. #define SE_OPTIONAL_FIELD_UINT16 0xFFFF
  194. #define SE_OPTIONAL_FIELD_UINT32 0xFFFFFFFF
  195. #define SE_OPTIONAL_FIELD_TEMPERATURE_SET_POINT 0x8000
  196. #define SE_OPTIONAL_FIELD_INT8 -128
  197. // Event Status Field Values
  198. #define EVENT_STATUS_LOAD_CONTROL_EVENT_RECEIVED 0x01
  199. #define EVENT_STATUS_LOAD_CONTROL_EVENT_STARTED 0x02
  200. #define EVENT_STATUS_LOAD_CONTROL_EVENT_COMPLETED 0x03
  201. #define EVENT_STATUS_LOAD_CONTROL_USER_OPT_OUT 0x04
  202. #define EVENT_STATUS_LOAD_CONTROL_USER_OPT_IN 0x05
  203. #define EVENT_STATUS_LOAD_CONTROL_EVENT_CANCELLED 0x06
  204. #define EVENT_STATUS_LOAD_CONTROL_EVENT_SUPERSEDED 0x07
  205. #define EVENT_STATUS_LOAD_CONTROL_REJECTED_DUPLICATEID 0xFA
  206. #define EVENT_STATUS_LOAD_CONTROL_REJECTED_EVT_EXPIRED 0xFB
  207. #define EVENT_STATUS_LOAD_CONTROL_REJECTED_EVT_COMPLETED 0xFC
  208. #define EVENT_STATUS_LOAD_CONTROL_REJECTED_UNDEFINED_EVT 0xFD
  209. #define EVENT_STATUS_LOAD_CONTROL_EVENT_REJECTED 0xFE
  210. // Signature type
  211. #define SE_PROFILE_SIGNATURE_TYPE_ECDSA 0x01
  212. // Other constants
  213. #define SE_PROFILE_SIGNATURE_LENGTH 42
  214. #define SE_PROFILE_MSGCTRL_IMPORTANCE 2
  215. #define SE_PROFILE_MSGCTRL_CONFREQUIRED 7
  216. /********************************************************************
  217. * MACROS
  218. */
  219. /*********************************************************************
  220. * TYPEDEFS
  221. */
  222. /*** Structures used for callback functions ***/
  223. typedef struct
  224. {
  225. uint8 channel;
  226. uint32 endTime;
  227. uint8 numOfPeriods;
  228. } zclCCGetProfileCmd_t;
  229. typedef struct
  230. {
  231. uint32 endTime;
  232. uint8 status;
  233. uint8 profileIntervalPeriod;
  234. uint8 numOfPeriodDelivered;
  235. uint24 *intervals;
  236. } zclCCGetProfileRsp_t;
  237. typedef struct
  238. {
  239. uint16 endpointId ;
  240. } zclCCReqMirrorRsp_t ;
  241. typedef struct
  242. {
  243. uint16 endpointId ;
  244. } zclCCMirrorRemRsp_t ;
  245. typedef struct
  246. {
  247. uint8 option;
  248. } zclCCGetCurrentPrice_t;
  249. typedef struct
  250. {
  251. uint32 startTime;
  252. uint8 numEvents;
  253. } zclCCGetScheduledPrice_t;
  254. typedef struct
  255. {
  256. uint32 providerId;
  257. UTF8String_t rateLabel;
  258. uint32 issuerEventId;
  259. uint32 currentTime;
  260. uint8 unitOfMeasure;
  261. uint16 currency;
  262. uint8 priceTralingDigit;
  263. uint32 startTime;
  264. uint16 durationInMinutes;
  265. uint32 price;
  266. uint8 priceRatio;
  267. uint32 generationPrice;
  268. uint8 generationPriceRatio;
  269. uint8 priceTier;
  270. } zclCCPublishPrice_t;
  271. typedef struct
  272. {
  273. uint8 transmissionMode; // valid value 0~2
  274. uint8 importance; // 0~3
  275. uint8 confirmationRequired; // 0~1
  276. } zclMessageCtrl_t;
  277. typedef struct
  278. {
  279. uint32 messageId;
  280. zclMessageCtrl_t messageCtrl;
  281. uint32 startTime;
  282. uint16 durationInMinutes;
  283. UTF8String_t msgString;
  284. } zclCCDisplayMessage_t;
  285. typedef struct
  286. {
  287. uint32 messageId;
  288. zclMessageCtrl_t messageCtrl;
  289. } zclCCCancelMessage_t;
  290. typedef struct
  291. {
  292. uint32 messageId;
  293. uint32 confirmTime;
  294. } zclCCMessageConfirmation_t;
  295. typedef struct
  296. {
  297. uint32 issuerEvent;
  298. uint24 deviceGroupClass;
  299. uint32 startTime;
  300. uint16 durationInMinutes;
  301. uint8 criticalityLevel;
  302. uint8 coolingTemperatureOffset;
  303. uint8 heatingTemperatureOffset;
  304. uint16 coolingTemperatureSetPoint;
  305. uint16 heatingTemperatureSetPoint;
  306. int8 averageLoadAdjustmentPercentage;
  307. uint8 dutyCycle;
  308. uint8 eventControl;
  309. } zclCCLoadControlEvent_t;
  310. typedef struct
  311. {
  312. uint32 issuerEventID;
  313. uint24 deviceGroupClass;
  314. uint8 cancelControl;
  315. uint32 effectiveTime;
  316. } zclCCCancelLoadControlEvent_t;
  317. typedef struct
  318. {
  319. uint8 cancelControl;
  320. } zclCCCancelAllLoadControlEvents_t;
  321. typedef struct
  322. {
  323. uint32 issuerEventID;
  324. uint32 eventStartTime;
  325. uint8 eventStatus;
  326. uint8 criticalityLevelApplied;
  327. uint16 coolingTemperatureSetPointApplied;
  328. uint16 heatingTemperatureSetPointApplied;
  329. int8 averageLoadAdjustment;
  330. uint8 dutyCycleApplied;
  331. uint8 eventControl;
  332. uint8 signatureType;
  333. uint8 signature[SE_PROFILE_SIGNATURE_LENGTH];
  334. } zclCCReportEventStatus_t;
  335. typedef struct
  336. {
  337. uint32 startTime;
  338. uint8 numEvents;
  339. } zclCCGetScheduledEvent_t;
  340. typedef enum
  341. {
  342. zclSE_SimpleMeter_GetProfileRsp_Status_Success = 0,
  343. zclSE_SimpleMeter_GetProfileRsp_Status_UndefinedInterval,
  344. zclSE_SimpleMeter_GetProfileRsp_Status_IntervalNotSupport,
  345. zclSE_SimpleMeter_GetProfileRsp_Status_InvalidEndTime,
  346. zclSE_SimpleMeter_GetProfileRsp_Status_MorePeriodRequested,
  347. zclSE_SimpleMeter_GetProfileRsp_Status_NotAvailable
  348. }zclSE_SimpleMeter_GetProfileRsp_Status;
  349. // This callback is called to process an incoming Get Profile
  350. // command. On receipt of this command, the device responds with
  351. // Get Profile Response.
  352. typedef void (*zclSE_SimpleMeter_GetProfileCmd_t)( zclCCGetProfileCmd_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  353. // This callback is called to process an incoming Get Profile
  354. // Response.
  355. typedef void (*zclSE_SimpleMeter_GetProfileRsp_t)( zclCCGetProfileRsp_t *pRsp, afAddrType_t *srcAddr, uint8 seqNum );
  356. // This callback is called to process an incoming Request Mirror
  357. // command. In receipt of this command, the device finds a mirroring
  358. // endpoint and responds with a Request Mirror Response
  359. typedef void (*zclSE_SimpleMeter_ReqMirrorCmd_t)( afAddrType_t *srcAddr, uint8 seqNum ) ;
  360. // This callback is called to process an incoming Request Mirror Response
  361. typedef void (*zclSE_SimpleMeter_ReqMirrorRsp_t)( zclCCReqMirrorRsp_t *pRsp, afAddrType_t *srcAddr, uint8 seqNum ) ;
  362. // This callback is called to process an incoming Mirror Removed
  363. // command. In receipt of this command, the device removes the
  364. // mirrored data from the metering device and responds with a
  365. // Mirror Removed response.
  366. typedef void (*zclSE_SimpleMeter_MirrorRemCmd_t)( afAddrType_t *srcAddr, uint8 seqNum ) ;
  367. // This callback is called to process an incoming Mirror Remove Response
  368. typedef void (*zclSE_SimpleMeter_MirrorRemRsp_t)( zclCCMirrorRemRsp_t *pRsp, afAddrType_t *srcAddr, uint8 seqNum ) ;
  369. // This callback is called to process an incoming Get Current Price
  370. // command. On receipt of this command, the device responds with
  371. // Publish Price.
  372. typedef void (*zclSE_Pricing_GetCurentPrice_t)( zclCCGetCurrentPrice_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  373. // This callback is called to process an incoming Get Scheduled Price
  374. // command. On receipt of this command, the device responds with
  375. // Publish Price.
  376. typedef void (*zclSE_Pricing_GetScheduledPrice_t)( zclCCGetScheduledPrice_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  377. // This callback is called to process an incoming Get Scheduled Price
  378. // command. On receipt of this command, the device responds with
  379. // Publish Price.
  380. typedef void (*zclSE_Pricing_PublishPrice_t)( zclCCPublishPrice_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  381. // This callback is called to process an incoming Display Message
  382. // command.
  383. typedef void (*zclSE_Message_DisplayMessage_t)( zclCCDisplayMessage_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  384. // This callback is called to process an incoming Cancel Message
  385. // command.
  386. typedef void (*zclSE_Message_CancelMessage_t)( zclCCCancelMessage_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  387. // This callback is called to process an incoming Get Last Message
  388. // command. On receipt of this command, the device responds with
  389. // Display Message.
  390. typedef void (*zclSE_Message_GetLastMessage_t)( afAddrType_t *srcAddr, uint8 seqNum );
  391. // This callback is called to process an incoming Message Confirmation
  392. // command.
  393. typedef void (*zclSE_Message_MessageConfirmation_t)( zclCCMessageConfirmation_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  394. // This callback is called to process an incoming Load Control Event Command
  395. // command.
  396. typedef void (*zclSE_LoadControl_LoadControlEvent_t)( zclCCLoadControlEvent_t *pCmd, afAddrType_t *srcAddr, uint8 status, uint8 seqNum );
  397. // This callback is called to process an incoming Cancel Load Control Event Command
  398. // command.
  399. typedef void (*zclSE_LoadControl_CancelLoadControlEvent_t)( zclCCCancelLoadControlEvent_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum);
  400. // This callback is called to process an incoming Cancel All Load Control Event Command
  401. // command.
  402. typedef void (*zclSE_LoadControl_CancelAllLoadControlEvents_t)( zclCCCancelAllLoadControlEvents_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum );
  403. // This callback is called to process an incoming Report Event Status Command
  404. // command.
  405. typedef void (*zclSE_LoadControl_ReportEventStatus_t)( zclCCReportEventStatus_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum);
  406. // This callback is called to process an incoming Get Scheduled Event Command
  407. // command.
  408. typedef void (*zclSE_LoadControl_GetScheduledEvent_t)( zclCCGetScheduledEvent_t *pCmd, afAddrType_t *srcAddr, uint8 seqNum);
  409. // Register Callbacks table entry - enter function pointers for callbacks that
  410. // the application would like to receive
  411. typedef struct
  412. {
  413. zclSE_SimpleMeter_GetProfileCmd_t pfnSimpleMeter_GetProfileCmd;
  414. zclSE_SimpleMeter_GetProfileRsp_t pfnSimpleMeter_GetProfileRsp;
  415. zclSE_SimpleMeter_ReqMirrorCmd_t pfnSimpleMeter_ReqMirrorCmd;
  416. zclSE_SimpleMeter_ReqMirrorRsp_t pfnSimpleMeter_ReqMirrorRsp;
  417. zclSE_SimpleMeter_MirrorRemCmd_t pfnSimpleMeter_MirrorRemCmd;
  418. zclSE_SimpleMeter_MirrorRemRsp_t pfnSimpleMeter_MirrorRemRsp;
  419. zclSE_Pricing_GetCurentPrice_t pfnPricing_GetCurrentPrice;
  420. zclSE_Pricing_GetScheduledPrice_t pfnPricing_GetScheduledPrice;
  421. zclSE_Pricing_PublishPrice_t pfnPricing_PublishPrice;
  422. zclSE_Message_DisplayMessage_t pfnMessage_DisplayMessage;
  423. zclSE_Message_CancelMessage_t pfnMessage_CancelMessage;
  424. zclSE_Message_GetLastMessage_t pfnMessage_GetLastMessage;
  425. zclSE_Message_MessageConfirmation_t pfnMessage_MessageConfirmation;
  426. zclSE_LoadControl_LoadControlEvent_t pfnLoadControl_LoadControlEvent;
  427. zclSE_LoadControl_CancelLoadControlEvent_t pfnLoadControl_CancelLoadControlEvent;
  428. zclSE_LoadControl_CancelAllLoadControlEvents_t pfnLoadControl_CancelAllLoadControlEvents;
  429. zclSE_LoadControl_ReportEventStatus_t pfnLoadControl_ReportEventStatus;
  430. zclSE_LoadControl_GetScheduledEvent_t pfnLoadControl_GetScheduledEvents;
  431. } zclSE_AppCallbacks_t;
  432. /*********************************************************************
  433. * VARIABLES
  434. */
  435. /*********************************************************************
  436. * FUNCTIONS
  437. */
  438. /*
  439. * Register for callbacks from this cluster library
  440. */
  441. extern ZStatus_t zclSE_RegisterCmdCallbacks( uint8 endpoint, zclSE_AppCallbacks_t *callbacks );
  442. #ifdef ZCL_SIMPLE_METERING
  443. /*
  444. * Send Get Profile Command
  445. */
  446. extern ZStatus_t zclSE_SimpleMetering_Send_GetProfileCmd( uint8 srcEP, afAddrType_t *dstAddr,
  447. uint8 channel, uint32 endTime, uint8 numOfPeriods,
  448. uint8 disableDefaultRsp, uint8 seqNum );
  449. /*
  450. * Send Get Profile Response
  451. */
  452. extern ZStatus_t zclSE_SimpleMetering_Send_GetProfileRsp( uint8 srcEP, afAddrType_t *dstAddr,
  453. uint32 endTime, uint8 rspStatus, uint8 profileIntervalPeriod,
  454. uint8 numOfPeriodDelivered, uint24 *intervals,
  455. uint8 disableDefaultRsp, uint8 seqNum );
  456. /*
  457. * Send Request Mirror Response
  458. */
  459. extern ZStatus_t zclSE_SimpleMetering_Send_ReqMirrorRsp( uint8 srcEP, afAddrType_t *dstAddr,
  460. uint16 endpointId,
  461. uint8 disableDefaultRsp, uint8 seqNum ) ;
  462. /*
  463. * Send Remove Mirror Response
  464. */
  465. extern ZStatus_t zclSE_SimpleMetering_Send_RemMirrorRsp( uint8 srcEP, afAddrType_t *dstAddr,
  466. uint16 endpointId,
  467. uint8 disableDefaultRsp, uint8 seqNum ) ;
  468. #endif
  469. #ifdef ZCL_PRICING
  470. /*
  471. * Send Publish Price Command
  472. */
  473. extern ZStatus_t zclSE_Pricing_Send_PublishPrice( uint8 srcEP, afAddrType_t *dstAddr,
  474. zclCCPublishPrice_t *cmd,
  475. uint8 disableDefaultRsp, uint8 seqNum );
  476. extern ZStatus_t zclSE_Pricing_Send_GetScheduledPrice( uint8 srcEP, afAddrType_t *dstAddr,
  477. zclCCGetScheduledPrice_t *cmd,
  478. uint8 disableDefaultRsp, uint8 seqNum );
  479. #endif
  480. #ifdef ZCL_MESSAGE
  481. /*
  482. * Send Display Message Command
  483. */
  484. extern ZStatus_t zclSE_Message_Send_DisplayMessage( uint8 srcEP, afAddrType_t *dstAddr,
  485. zclCCDisplayMessage_t *cmd,
  486. uint8 disableDefaultRsp, uint8 seqNum );
  487. /*
  488. * Send Cancel Message Command
  489. */
  490. extern ZStatus_t zclSE_Message_Send_CancelMessage( uint8 srcEP, afAddrType_t *dstAddr,
  491. uint32 msgId, uint8 msgCtrl,
  492. uint8 disableDefaultRsp, uint8 seqNum );
  493. /*
  494. * Send Message Confirmation
  495. */
  496. extern ZStatus_t zclSE_Message_Send_MessageConfirmation( uint8 srcEP, afAddrType_t *dstAddr,
  497. uint32 msgId, uint32 confirmTime,
  498. uint8 disableDefaultRsp, uint8 seqNum );
  499. #endif
  500. #ifdef ZCL_LOAD_CONTROL
  501. /*
  502. * Send Load Control Event
  503. */
  504. extern ZStatus_t zclSE_LoadControl_Send_LoadControlEvent( uint8 srcEP, afAddrType_t *dstAddr,
  505. zclCCLoadControlEvent_t* cmd,
  506. uint8 disableDefaultRsp, uint8 seqNum );
  507. /*
  508. * Send Cancel Load Control Event
  509. */
  510. extern ZStatus_t zclSE_LoadControl_Send_CancelLoadControlEvent( uint8 srcEP, afAddrType_t *dstAddr,
  511. zclCCCancelLoadControlEvent_t *cmd,
  512. uint8 disableDefaultRsp, uint8 seqNum );
  513. /*
  514. * Send Report Event Status
  515. */
  516. extern ZStatus_t zclSE_LoadControl_Send_ReportEventStatus( uint8 srcEP, afAddrType_t *dstAddr,
  517. zclCCReportEventStatus_t* cmd,
  518. uint8 disableDefaultRsp, uint8 seqNum );
  519. /*
  520. * Send Get Scheduled Event
  521. */
  522. extern ZStatus_t zclSE_LoadControl_Send_GetScheduledEvent( uint8 srcEP, afAddrType_t *dstAddr,
  523. zclCCGetScheduledEvent_t *cmd,
  524. uint8 disableDefaultRsp, uint8 seqNum );
  525. #endif
  526. #ifdef ZCL_PRICING
  527. /*
  528. * Parse received Publish Price Command
  529. */
  530. extern ZStatus_t zclSE_ParseInCmd_PublishPrice( zclCCPublishPrice_t *cmd, uint8 *buf, uint8 len );
  531. #endif
  532. #ifdef ZCL_MESSAGE
  533. /*
  534. * Parse received Display Message Command
  535. */
  536. extern ZStatus_t zclSE_ParseInCmd_DisplayMessage( zclCCDisplayMessage_t *cmd, uint8 *buf, uint8 len );
  537. #endif
  538. #ifdef ZCL_LOAD_CONTROL
  539. /*
  540. * Parse received Load Control Event
  541. */
  542. extern void zclSE_ParseInCmd_LoadControlEvent( zclCCLoadControlEvent_t *cmd, uint8 *buf, uint8 len );
  543. /*
  544. * Parse received Cancel Load Control Event
  545. */
  546. extern void zclSE_ParseInCmd_CancelLoadControlEvent( zclCCCancelLoadControlEvent_t *cmd, uint8 *buf, uint8 len );
  547. /*
  548. * Parse received Report Event Status
  549. */
  550. extern void zclSE_ParseInCmd_ReportEventStatus( zclCCReportEventStatus_t *cmd, uint8 *buf, uint8 len );
  551. #endif
  552. /*********************************************************************
  553. * FUNCTION MACROS
  554. */
  555. #ifdef ZCL_PRICING
  556. /*********************************************************************
  557. * Call to send out a Get Current Price Command
  558. *
  559. * Use as
  560. * ZStatus_t zclSE_Pricing_Send_GetCurrentPrice( uint8 srcEP, afAddrType_t *dstAddr,
  561. * uint8 option,
  562. * uint8 disableDefaultRsp, uint8 seqNum )
  563. *
  564. * @param srcEP - Sending application's endpoint
  565. * @param dstAddr - where you want the message to go
  566. * @param option - Command option field
  567. * @param disableDefaultRsp - disable default response
  568. * @param seqNum - ZCL sequence number
  569. *
  570. * @return ZStatus_t
  571. */
  572. #define zclSE_Pricing_Send_GetCurrentPrice(a, b, c, d, e) \
  573. zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_SE_PRICING, \
  574. COMMAND_SE_GET_CURRENT_PRICE, TRUE, \
  575. ZCL_FRAME_CLIENT_SERVER_DIR, (d), 0, (e), 1, &(c) );
  576. #endif // ZCL_PRICING
  577. #ifdef ZCL_SIMPLE_METERING
  578. /*********************************************************************
  579. * @fn zclSE_SimpleMetering_Send_ReqMirrorCmd
  580. *
  581. * @brief Call to send out a Request Mirror Command
  582. *
  583. * @param srcEP - Sending application's endpoint
  584. * @param dstAddr - where you want the message to go
  585. * @param disableDefaultRsp - disable default response
  586. * @param seqNum - ZCL sequence number
  587. *
  588. * @return ZStatus_t
  589. */
  590. #define zclSE_SimpleMetering_Send_ReqMirrorCmd(a, b, c, d) \
  591. zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_SE_SIMPLE_METERING, \
  592. COMMAND_SE_REQ_MIRROR_CMD, TRUE, \
  593. ZCL_FRAME_SERVER_CLIENT_DIR, (c), 0, (d), 0, NULL );
  594. /*********************************************************************
  595. * @fn zclSE_SimpleMetering_Send_RemMirrorCmd
  596. *
  597. * @brief Call to send out a Remove Mirror Command
  598. *
  599. * @param srcEP - Sending application's endpoint
  600. * @param dstAddr - where you want the message to go
  601. * @param disableDefaultRsp - disable default response
  602. * @param seqNum - ZCL sequence number
  603. *
  604. * @return ZStatus_t
  605. */
  606. #define zclSE_SimpleMetering_Send_RemMirrorCmd(a, b, c, d) \
  607. zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_SE_SIMPLE_METERING, \
  608. COMMAND_SE_MIRROR_REM_CMD, TRUE, \
  609. ZCL_FRAME_SERVER_CLIENT_DIR, (c), 0, (d), 0, NULL );
  610. #endif // ZCL_SIMPLE_METERING
  611. #ifdef ZCL_MESSAGE
  612. /*********************************************************************
  613. * Call to send out a Get Last Message
  614. *
  615. * Use as
  616. * ZStatus_t zclSE_Message_Send_GetLastMessage( uint8 srcEP, afAddrType_t *dstAddr,
  617. * uint8 disableDefaultRsp, uint8 seqNum )
  618. *
  619. * @param srcEP - Sending application's endpoint
  620. * @param dstAddr - where you want the message to go
  621. * @param disableDefaultRsp - disable default response
  622. * @param seqNum - ZCL sequence number
  623. *
  624. * @return ZStatus_t
  625. */
  626. #define zclSE_Message_Send_GetLastMessage(a, b, c, d) \
  627. zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_SE_MESSAGE, \
  628. COMMAND_SE_GET_LAST_MESSAGE, TRUE, \
  629. ZCL_FRAME_CLIENT_SERVER_DIR, (c), 0, (d), 0, NULL );
  630. #endif // ZCL_MESSAGE
  631. #ifdef ZCL_LOAD_CONTROL
  632. /*********************************************************************
  633. * Call to send out a Cancel All Load Control Event
  634. *
  635. * Use as
  636. * ZStatus_t zclSE_LoadControl_Send_CancelAllLoadControlEvent( uint8 srcEP, afAddrType_t *dstAddr,
  637. * uint8 cancelControl,
  638. * uint8 disableDefaultRsp, uint8 seqNum )
  639. *
  640. * @param srcEP - Sending application's endpoint
  641. * @param dstAddr - where you want the message to go
  642. * @param cancelControl
  643. * @param disableDefaultRsp - disable default response
  644. * @param seqNum - ZCL sequence number
  645. *
  646. * @return ZStatus_t
  647. */
  648. #define zclSE_LoadControl_Send_CancelAllLoadControlEvent(a, b, c, d, e) \
  649. zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_SE_LOAD_CONTROL, \
  650. COMMAND_SE_CANCEL_ALL_LOAD_CONTROL_EVENT, TRUE, \
  651. ZCL_FRAME_SERVER_CLIENT_DIR, (d), 0, (e), 1, &(c) );
  652. #endif // ZCL_LOAD_CONTROL
  653. #ifdef __cplusplus
  654. }
  655. #endif
  656. #endif /* ZCL_SE_H */