esp_data.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /**************************************************************************************************
  2. Filename: esp_data.c
  3. Revised: $Date: 2007-08-29 10:52:11 -0700 (Wed, 29 Aug 2007) $
  4. Revision: $Revision: 15242 $
  5. Description: File that contains attribute and simple descriptor
  6. definitions for the ESP
  7. Copyright 2009 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. **************************************************************************************************/
  34. /*********************************************************************
  35. * INCLUDES
  36. */
  37. #include "ZComDef.h"
  38. #include "OSAL_Clock.h"
  39. #include "ZDConfig.h"
  40. #include "se.h"
  41. #include "esp.h"
  42. #include "zcl_general.h"
  43. #include "zcl_se.h"
  44. #include "zcl_key_establish.h"
  45. /*********************************************************************
  46. * CONSTANTS
  47. */
  48. #define ESP_DEVICE_VERSION 0
  49. #define ESP_FLAGS 0
  50. #define ESP_HWVERSION 1
  51. #define ESP_ZCLVERSION 1
  52. /*********************************************************************
  53. * TYPEDEFS
  54. */
  55. /*********************************************************************
  56. * MACROS
  57. */
  58. /*********************************************************************
  59. * GLOBAL VARIABLES
  60. */
  61. // Basic Cluster
  62. const uint8 espZCLVersion = ESP_ZCLVERSION;
  63. const uint8 espHWVersion = ESP_HWVERSION;
  64. const uint8 espManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
  65. const uint8 espModelId[] = { 16, 'T','I','0','0','0','1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  66. const uint8 espDateCode[] = { 16, '2','0','0','6','0','8','3','1',' ',' ',' ',' ',' ',' ',' ',' ' };
  67. const uint8 espPowerSource = POWER_SOURCE_MAINS_1_PHASE;
  68. uint8 espLocationDescription[] = { 16, ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  69. uint8 espPhysicalEnvironment = PHY_UNSPECIFIED_ENV;
  70. uint8 espDeviceEnabled = DEVICE_ENABLED;
  71. // Identify Cluster Attributes
  72. uint16 espIdentifyTime = 0;
  73. uint32 espTime = 0;
  74. uint8 espTimeStatus = 0x01;
  75. // Simple Metering Cluster - Reading Information Set Attributes
  76. uint8 espCurrentSummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  77. uint8 espCurrentSummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  78. uint8 espCurrentMaxDemandDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  79. uint8 espCurrentMaxDemandReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  80. uint8 espCurrentTier1SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  81. uint8 espCurrentTier1SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  82. uint8 espCurrentTier2SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  83. uint8 espCurrentTier2SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  84. uint8 espCurrentTier3SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  85. uint8 espCurrentTier3SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  86. uint8 espCurrentTier4SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  87. uint8 espCurrentTier4SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  88. uint8 espCurrentTier5SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  89. uint8 espCurrentTier5SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  90. uint8 espCurrentTier6SummationDelivered[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  91. uint8 espCurrentTier6SummationReceived[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  92. uint8 espDFTSummation[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
  93. uint16 espDailyFreezeTime = 0x01;
  94. int8 espPowerFactor = 0x01;
  95. UTCTime espSnapshotTime = 0x00;
  96. UTCTime espMaxDemandDeliverdTime = 0x00;
  97. UTCTime espMaxDemandReceivedTime = 0x00;
  98. // Simple Metering Cluster - Meter Status Attributes
  99. uint8 espStatus = 0x12;
  100. // Simple Metering Cluster - Formatting Attributes
  101. uint8 espUnitOfMeasure = 0x01;
  102. uint24 espMultiplier = 0x01;
  103. uint24 espDivisor = 0x01;
  104. uint8 espSummationFormating = 0x01;
  105. uint8 espDemandFormatting = 0x01;
  106. uint8 espHistoricalConsumptionFormatting = 0x01;
  107. // Simple Metering Cluster - esp Historical Consumption Attributes
  108. uint24 espInstanteneousDemand = 0x01;
  109. uint24 espCurrentdayConsumptionDelivered = 0x01;
  110. uint24 espCurrentdayConsumptionReceived = 0x01;
  111. uint24 espPreviousdayConsumptionDelivered = 0x01;
  112. uint24 espPreviousdayConsumtpionReceived = 0x01;
  113. UTCTime espCurrentPartialProfileIntervalStartTime = 0x1000;
  114. uint24 espCurrentPartialProfileIntervalValue = 0x0001;
  115. uint8 espMaxNumberOfPeriodsDelivered = 0x01;
  116. // Demand Response and Load Control
  117. uint8 espUtilityDefinedGroup = 0x00;
  118. uint8 espStartRandomizeMinutes = 0x00;
  119. uint8 espStopRandomizeMinutes = 0x00;
  120. uint8 espSignature[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  121. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
  122. // Key Establishment
  123. uint16 espKeyEstablishmentSuite = CERTIFICATE_BASED_KEY_ESTABLISHMENT;
  124. /*********************************************************************
  125. * ATTRIBUTE DEFINITIONS - Uses Cluster IDs
  126. */
  127. CONST zclAttrRec_t espAttrs[ESP_MAX_ATTRIBUTES] =
  128. {
  129. // *** General Basic Cluster Attributes ***
  130. {
  131. ZCL_CLUSTER_ID_GEN_BASIC, // Cluster IDs - defined in the foundation (ie. zcl.h)
  132. { // Attribute record
  133. ATTRID_BASIC_ZCL_VERSION, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  134. ZCL_DATATYPE_UINT8, // Data Type - found in zcl.h
  135. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  136. (void *)&espZCLVersion // Pointer to attribute variable
  137. }
  138. },
  139. {
  140. ZCL_CLUSTER_ID_GEN_BASIC,
  141. { // Attribute record
  142. ATTRID_BASIC_HW_VERSION,
  143. ZCL_DATATYPE_UINT8,
  144. ACCESS_CONTROL_READ,
  145. (void *)&espHWVersion
  146. }
  147. },
  148. {
  149. ZCL_CLUSTER_ID_GEN_BASIC,
  150. { // Attribute record
  151. ATTRID_BASIC_MANUFACTURER_NAME,
  152. ZCL_DATATYPE_CHAR_STR,
  153. ACCESS_CONTROL_READ,
  154. (void *)espManufacturerName
  155. }
  156. },
  157. {
  158. ZCL_CLUSTER_ID_GEN_BASIC,
  159. { // Attribute record
  160. ATTRID_BASIC_MODEL_ID,
  161. ZCL_DATATYPE_CHAR_STR,
  162. ACCESS_CONTROL_READ,
  163. (void *)espModelId
  164. }
  165. },
  166. {
  167. ZCL_CLUSTER_ID_GEN_BASIC,
  168. { // Attribute record
  169. ATTRID_BASIC_DATE_CODE,
  170. ZCL_DATATYPE_CHAR_STR,
  171. ACCESS_CONTROL_READ,
  172. (void *)espDateCode
  173. }
  174. },
  175. {
  176. ZCL_CLUSTER_ID_GEN_BASIC,
  177. { // Attribute record
  178. ATTRID_BASIC_POWER_SOURCE,
  179. ZCL_DATATYPE_ENUM8,
  180. ACCESS_CONTROL_READ,
  181. (void *)&espPowerSource
  182. }
  183. },
  184. {
  185. ZCL_CLUSTER_ID_GEN_BASIC,
  186. { // Attribute record
  187. ATTRID_BASIC_LOCATION_DESC,
  188. ZCL_DATATYPE_CHAR_STR,
  189. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  190. (void *)espLocationDescription
  191. }
  192. },
  193. {
  194. ZCL_CLUSTER_ID_GEN_BASIC,
  195. { // Attribute record
  196. ATTRID_BASIC_PHYSICAL_ENV,
  197. ZCL_DATATYPE_ENUM8,
  198. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  199. (void *)&espPhysicalEnvironment
  200. }
  201. },
  202. {
  203. ZCL_CLUSTER_ID_GEN_BASIC,
  204. { // Attribute record
  205. ATTRID_BASIC_DEVICE_ENABLED,
  206. ZCL_DATATYPE_BOOLEAN,
  207. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  208. (void *)&espDeviceEnabled
  209. }
  210. },
  211. // *** Identify Cluster Attribute ***
  212. {
  213. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  214. { // Attribute record
  215. ATTRID_IDENTIFY_TIME,
  216. ZCL_DATATYPE_UINT16,
  217. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  218. (void *)&espIdentifyTime
  219. }
  220. },
  221. // *** Time Cluster Attribute ***
  222. // In SE domain, only master clock will be used. Therefore
  223. // mark the access control to only readable.
  224. {
  225. ZCL_CLUSTER_ID_GEN_TIME,
  226. { // Attribute record
  227. ATTRID_TIME_TIME,
  228. ZCL_DATATYPE_UTC,
  229. ACCESS_CONTROL_READ,
  230. (void *)&espTime
  231. }
  232. },
  233. // In SE domain, only master clock will be used. Therefore
  234. // mark the access control to only readable.
  235. {
  236. ZCL_CLUSTER_ID_GEN_TIME,
  237. { // Attribute record
  238. ATTRID_TIME_STATUS,
  239. ZCL_DATATYPE_BITMAP8,
  240. ACCESS_CONTROL_READ,
  241. (void *)&espTimeStatus
  242. }
  243. },
  244. // SE Attributes
  245. {
  246. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  247. { // Attribute record
  248. ATTRID_SE_CURRENT_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  249. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  250. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  251. (void *)espCurrentSummationDelivered // Pointer to attribute variable
  252. }
  253. },
  254. {
  255. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  256. { // Attribute record
  257. ATTRID_SE_CURRENT_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  258. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  259. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  260. (void *)espCurrentSummationReceived // Pointer to attribute variable
  261. }
  262. },
  263. {
  264. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  265. { // Attribute record
  266. ATTRID_SE_CURRENT_MAX_DEMAND_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  267. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  268. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  269. (void *)espCurrentMaxDemandDelivered // Pointer to attribute variable
  270. }
  271. },
  272. {
  273. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  274. { // Attribute record
  275. ATTRID_SE_CURRENT_MAX_DEMAND_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  276. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  277. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  278. (void *)espCurrentMaxDemandReceived // Pointer to attribute variable
  279. }
  280. },
  281. {
  282. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  283. { // Attribute record
  284. ATTRID_SE_CURRENT_TIER1_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  285. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  286. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  287. (void *)espCurrentTier1SummationDelivered // Pointer to attribute variable
  288. }
  289. },
  290. {
  291. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  292. { // Attribute record
  293. ATTRID_SE_CURRENT_TIER1_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  294. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  295. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  296. (void *)espCurrentTier1SummationReceived // Pointer to attribute variable
  297. }
  298. },
  299. {
  300. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  301. { // Attribute record
  302. ATTRID_SE_CURRENT_TIER2_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  303. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  304. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  305. (void *)espCurrentTier2SummationDelivered // Pointer to attribute variable
  306. }
  307. },
  308. {
  309. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  310. { // Attribute record
  311. ATTRID_SE_CURRENT_TIER2_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  312. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  313. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  314. (void *)espCurrentTier2SummationReceived // Pointer to attribute variable
  315. }
  316. },
  317. {
  318. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  319. { // Attribute record
  320. ATTRID_SE_CURRENT_TIER3_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  321. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  322. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  323. (void *)espCurrentTier3SummationDelivered // Pointer to attribute variable
  324. }
  325. },
  326. {
  327. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  328. { // Attribute record
  329. ATTRID_SE_CURRENT_TIER3_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  330. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  331. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  332. (void *)espCurrentTier3SummationReceived // Pointer to attribute variable
  333. }
  334. },
  335. {
  336. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  337. { // Attribute record
  338. ATTRID_SE_CURRENT_TIER4_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  339. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  340. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  341. (void *)espCurrentTier4SummationDelivered // Pointer to attribute variable
  342. }
  343. },
  344. {
  345. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  346. { // Attribute record
  347. ATTRID_SE_CURRENT_TIER4_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  348. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  349. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  350. (void *)espCurrentTier4SummationReceived // Pointer to attribute variable
  351. }
  352. },
  353. {
  354. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  355. { // Attribute record
  356. ATTRID_SE_CURRENT_TIER5_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  357. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  358. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  359. (void *)espCurrentTier5SummationDelivered // Pointer to attribute variable
  360. }
  361. },
  362. {
  363. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  364. { // Attribute record
  365. ATTRID_SE_CURRENT_TIER5_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  366. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  367. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  368. (void *)espCurrentTier5SummationReceived // Pointer to attribute variable
  369. }
  370. },
  371. {
  372. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  373. { // Attribute record
  374. ATTRID_SE_CURRENT_TIER6_SUMMATION_DELIVERED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  375. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  376. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  377. (void *)espCurrentTier6SummationDelivered // Pointer to attribute variable
  378. }
  379. },
  380. {
  381. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  382. { // Attribute record
  383. ATTRID_SE_CURRENT_TIER6_SUMMATION_RECEIVED, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  384. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  385. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  386. (void *)espCurrentTier6SummationReceived // Pointer to attribute variable
  387. }
  388. },
  389. {
  390. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  391. { // Attribute record
  392. ATTRID_SE_DFT_SUMMATION, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  393. ZCL_DATATYPE_UINT48, // Data Type - found in zcl.h
  394. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  395. (void *)espDFTSummation // Pointer to attribute variable
  396. }
  397. },
  398. {
  399. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  400. { // Attribute record
  401. ATTRID_SE_DAILY_FREEZE_TIME, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  402. ZCL_DATATYPE_UINT16, // Data Type - found in zcl.h
  403. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  404. (void *)&espDailyFreezeTime // Pointer to attribute variable
  405. }
  406. },
  407. {
  408. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  409. { // Attribute record
  410. ATTRID_SE_POWER_FACTOR, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  411. ZCL_DATATYPE_INT8, // Data Type - found in zcl.h
  412. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  413. (void *)&espPowerFactor // Pointer to attribute variable
  414. }
  415. },
  416. {
  417. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  418. { // Attribute record
  419. ATTRID_SE_READING_SNAPSHOT_TIME, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  420. ZCL_DATATYPE_UTC, // Data Type - found in zcl.h
  421. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  422. (void *)&espSnapshotTime // Pointer to attribute variable
  423. }
  424. },
  425. {
  426. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  427. { // Attribute record
  428. ATTRID_SE_CURRENT_MAX_DEMAND_DELIVERD_TIME, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  429. ZCL_DATATYPE_UTC, // Data Type - found in zcl.h
  430. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  431. (void *)&espMaxDemandDeliverdTime // Pointer to attribute variable
  432. }
  433. },
  434. {
  435. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  436. { // Attribute record
  437. ATTRID_SE_CURRENT_MAX_DEMAND_RECEIVED_TIME, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  438. ZCL_DATATYPE_UTC, // Data Type - found in zcl.h
  439. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  440. (void *)&espMaxDemandReceivedTime // Pointer to attribute variable
  441. }
  442. },
  443. {
  444. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  445. { // Attribute record
  446. ATTRID_SE_STATUS, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  447. ZCL_DATATYPE_BITMAP8, // Data Type - found in zcl.h
  448. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  449. (void *)&espStatus // Pointer to attribute variable
  450. }
  451. },
  452. {
  453. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  454. { // Attribute record
  455. ATTRID_SE_UNIT_OF_MEASURE, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  456. ZCL_DATATYPE_ENUM8, // Data Type - found in zcl.h
  457. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  458. (void *)&espUnitOfMeasure // Pointer to attribute variable
  459. }
  460. },
  461. {
  462. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  463. { // Attribute record
  464. ATTRID_SE_MULTIPLIER, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  465. ZCL_DATATYPE_UINT24, // Data Type - found in zcl.h
  466. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  467. (void *)&espMultiplier // Pointer to attribute variable
  468. }
  469. },
  470. {
  471. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  472. { // Attribute record
  473. ATTRID_SE_DIVISOR, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  474. ZCL_DATATYPE_UINT24, // Data Type - found in zcl.h
  475. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  476. (void *)&espDivisor // Pointer to attribute variable
  477. }
  478. },
  479. {
  480. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  481. { // Attribute record
  482. ATTRID_SE_SUMMATION_FORMATTING, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  483. ZCL_DATATYPE_BITMAP8, // Data Type - found in zcl.h
  484. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  485. (void *)&espSummationFormating // Pointer to attribute variable
  486. }
  487. },
  488. {
  489. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  490. { // Attribute record
  491. ATTRID_SE_DEMAND_FORMATTING, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  492. ZCL_DATATYPE_BITMAP8, // Data Type - found in zcl.h
  493. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  494. (void *)&espDemandFormatting // Pointer to attribute variable
  495. }
  496. },
  497. {
  498. ZCL_CLUSTER_ID_SE_SIMPLE_METERING, // Cluster IDs - defined in the profile (ie. se.h)
  499. { // Attribute record
  500. ATTRID_SE_HISTORICAL_CONSUMPTION_FORMATTING, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  501. ZCL_DATATYPE_BITMAP8, // Data Type - found in zcl.h
  502. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  503. (void *)&espHistoricalConsumptionFormatting // Pointer to attribute variable
  504. }
  505. },
  506. {
  507. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  508. { // Attribute record
  509. ATTRID_SE_INSTANTANEOUS_DEMAND,
  510. ZCL_DATATYPE_UINT24,
  511. ACCESS_CONTROL_READ,
  512. (void *)&espInstanteneousDemand
  513. }
  514. },
  515. {
  516. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  517. { // Attribute record
  518. ATTRID_SE_CURRENTDAY_CONSUMPTION_DELIVERED,
  519. ZCL_DATATYPE_UINT24,
  520. ACCESS_CONTROL_READ,
  521. (void *)&espCurrentdayConsumptionDelivered
  522. }
  523. },
  524. {
  525. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  526. { // Attribute record
  527. ATTRID_SE_CURRENTDAY_CONSUMPTION_RECEIVED,
  528. ZCL_DATATYPE_UINT24,
  529. ACCESS_CONTROL_READ,
  530. (void *)&espCurrentdayConsumptionReceived
  531. }
  532. },
  533. {
  534. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  535. { // Attribute record
  536. ATTRID_SE_PREVIOUSDAY_CONSUMPTION_DELIVERED,
  537. ZCL_DATATYPE_UINT24,
  538. ACCESS_CONTROL_READ,
  539. (void *)&espPreviousdayConsumptionDelivered
  540. }
  541. },
  542. {
  543. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  544. { // Attribute record
  545. ATTRID_SE_PREVIOUSDAY_CONSUMPTION_RECEIVED,
  546. ZCL_DATATYPE_UINT24,
  547. ACCESS_CONTROL_READ,
  548. (void *)&espPreviousdayConsumtpionReceived
  549. }
  550. },
  551. {
  552. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  553. { // Attribute record
  554. ATTRID_SE_CURRENT_PARTIAL_PROFILE_INTERVAL_START_TIME,
  555. ZCL_DATATYPE_UTC,
  556. ACCESS_CONTROL_READ,
  557. (void *)&espCurrentPartialProfileIntervalStartTime
  558. }
  559. },
  560. {
  561. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  562. { // Attribute record
  563. ATTRID_SE_CURRENT_PARTIAL_PROFILE_INTERVAL_VALUE,
  564. ZCL_DATATYPE_UINT24,
  565. ACCESS_CONTROL_READ,
  566. (void *)&espCurrentPartialProfileIntervalValue
  567. }
  568. },
  569. {
  570. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  571. { // Attribute record
  572. ATTRID_SE_MAX_NUMBER_OF_PERIODS_DELIVERED,
  573. ZCL_DATATYPE_UINT8,
  574. ACCESS_CONTROL_READ,
  575. (void *)&espMaxNumberOfPeriodsDelivered
  576. }
  577. },
  578. {
  579. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  580. { // Attribute record
  581. ATTRID_SE_UTILITY_DEFINED_GROUP,
  582. ZCL_DATATYPE_UINT8,
  583. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  584. (void *)&espUtilityDefinedGroup
  585. }
  586. },
  587. {
  588. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  589. { // Attribute record
  590. ATTRID_SE_START_RANDOMIZE_MINUTES,
  591. ZCL_DATATYPE_UINT8,
  592. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  593. (void *)&espStartRandomizeMinutes
  594. }
  595. },
  596. {
  597. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  598. { // Attribute record
  599. ATTRID_SE_STOP_RANDOMIZE_MINUTES,
  600. ZCL_DATATYPE_UINT8,
  601. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  602. (void *)&espStopRandomizeMinutes
  603. }
  604. },
  605. {
  606. ZCL_CLUSTER_ID_GEN_KEY_ESTABLISHMENT,
  607. { // Attribute record
  608. ATTRID_KEY_ESTABLISH_SUITE,
  609. ZCL_DATATYPE_BITMAP16,
  610. ACCESS_CONTROL_READ,
  611. (void *)&espKeyEstablishmentSuite
  612. }
  613. },
  614. };
  615. /*********************************************************************
  616. * CLUSTER OPTION DEFINITIONS
  617. */
  618. zclOptionRec_t espOptions[ESP_MAX_OPTIONS] =
  619. {
  620. // *** General Cluster Options ***
  621. {
  622. ZCL_CLUSTER_ID_GEN_TIME, // Cluster IDs - defined in the foundation (ie. zcl.h)
  623. ( AF_EN_SECURITY /*| AF_ACK_REQUEST*/ ), // Options - Found in AF header (ie. AF.h)
  624. },
  625. // *** Smart Energy Cluster Options ***
  626. {
  627. ZCL_CLUSTER_ID_SE_PRICING,
  628. ( AF_EN_SECURITY ),
  629. },
  630. {
  631. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  632. ( AF_EN_SECURITY ),
  633. },
  634. {
  635. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  636. ( AF_EN_SECURITY ),
  637. },
  638. {
  639. ZCL_CLUSTER_ID_SE_MESSAGE,
  640. ( AF_EN_SECURITY ),
  641. },
  642. {
  643. ZCL_CLUSTER_ID_SE_SE_TUNNELING,
  644. ( AF_EN_SECURITY ),
  645. },
  646. {
  647. ZCL_CLUSTER_ID_SE_PRE_PAYMENT,
  648. ( AF_EN_SECURITY ),
  649. },
  650. };
  651. /*********************************************************************
  652. * SIMPLE DESCRIPTOR
  653. */
  654. // This is the Cluster ID List and should be filled with Application
  655. // specific cluster IDs.
  656. #define ESP_MAX_INCLUSTERS 6
  657. const cId_t espInClusterList[ESP_MAX_INCLUSTERS] =
  658. {
  659. ZCL_CLUSTER_ID_GEN_BASIC,
  660. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  661. ZCL_CLUSTER_ID_SE_PRICING,
  662. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  663. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  664. ZCL_CLUSTER_ID_SE_MESSAGE
  665. };
  666. #define ESP_MAX_OUTCLUSTERS 6
  667. const cId_t espOutClusterList[ESP_MAX_OUTCLUSTERS] =
  668. {
  669. ZCL_CLUSTER_ID_GEN_BASIC,
  670. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  671. ZCL_CLUSTER_ID_SE_PRICING,
  672. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  673. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  674. ZCL_CLUSTER_ID_SE_MESSAGE
  675. };
  676. SimpleDescriptionFormat_t espSimpleDesc =
  677. {
  678. ESP_ENDPOINT, // uint8 Endpoint;
  679. ZCL_SE_PROFILE_ID, // uint16 AppProfId[2];
  680. ZCL_SE_DEVICEID_ESP, // uint16 AppDeviceId[2];
  681. ESP_DEVICE_VERSION, // int AppDevVer:4;
  682. ESP_FLAGS, // int AppFlags:4;
  683. ESP_MAX_INCLUSTERS, // uint8 AppNumInClusters;
  684. (cId_t *)espInClusterList, // cId_t *pAppInClusterList;
  685. ESP_MAX_OUTCLUSTERS, // uint8 AppNumInClusters;
  686. (cId_t *)espOutClusterList // cId_t *pAppInClusterList;
  687. };
  688. /*********************************************************************
  689. * GLOBAL FUNCTIONS
  690. */
  691. /*********************************************************************
  692. * LOCAL FUNCTIONS
  693. */
  694. /****************************************************************************
  695. ****************************************************************************/