pct_data.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /**************************************************************************************************
  2. Filename: pct_data.c
  3. Revised: $Date: 2009-12-16 11:24:35 -0800 (Wed, 16 Dec 2009) $
  4. Revision: $Revision: 21341 $
  5. Description: File that contains attribute and simple descriptor
  6. definitions for the PCT
  7. Copyright 2009-2010 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 "OSAL.h"
  38. #include "ZDConfig.h"
  39. #include "se.h"
  40. #include "pct.h"
  41. #include "zcl_general.h"
  42. #include "zcl_se.h"
  43. #include "zcl_key_establish.h"
  44. /*********************************************************************
  45. * CONSTANTS
  46. */
  47. #define PCT_DEVICE_VERSION 0
  48. #define PCT_FLAGS 0
  49. #define PCT_HWVERSION 1
  50. #define PCT_ZCLVERSION 1
  51. /*********************************************************************
  52. * TYPEDEFS
  53. */
  54. /*********************************************************************
  55. * MACROS
  56. */
  57. /*********************************************************************
  58. * GLOBAL VARIABLES
  59. */
  60. // Basic Cluster
  61. const uint8 pctZCLVersion = PCT_ZCLVERSION;
  62. const uint8 pctHWVersion = PCT_HWVERSION;
  63. const uint8 pctManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
  64. const uint8 pctModelId[] = { 16, 'T','I','0','0','0','1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  65. const uint8 pctDateCode[] = { 16, '2','0','0','6','0','8','3','1',' ',' ',' ',' ',' ',' ',' ',' ' };
  66. const uint8 pctPowerSource = POWER_SOURCE_MAINS_1_PHASE;
  67. uint8 pctLocationDescription[] = { 16, ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  68. uint8 pctPhysicalEnvironment = PHY_UNSPECIFIED_ENV;
  69. uint8 pctDeviceEnabled = DEVICE_ENABLED;
  70. // Identify Cluster Attributes
  71. uint16 pctIdentifyTime = 0;
  72. uint32 pctTime = 0;
  73. uint8 pctTimeStatus = 0x01;
  74. // Demand Response and Load Control
  75. uint8 pctUtilityDefinedGroup = 0x00;
  76. uint8 pctStartRandomizeMinutes = 0x00;
  77. uint8 pctStopRandomizeMinutes = 0x00;
  78. uint8 pctSignature[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
  79. 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
  80. // Key Establishment
  81. uint16 pctKeyEstablishmentSuite = CERTIFICATE_BASED_KEY_ESTABLISHMENT;
  82. /*********************************************************************
  83. * ATTRIBUTE DEFINITIONS - Uses Cluster IDs
  84. */
  85. CONST zclAttrRec_t pctAttrs[PCT_MAX_ATTRIBUTES] =
  86. {
  87. // *** General Basic Cluster Attributes ***
  88. {
  89. ZCL_CLUSTER_ID_GEN_BASIC, // Cluster IDs - defined in the foundation (ie. zcl.h)
  90. { // Attribute record
  91. ATTRID_BASIC_ZCL_VERSION, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  92. ZCL_DATATYPE_UINT8, // Data Type - found in zcl.h
  93. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  94. (void *)&pctZCLVersion // Pointer to attribute variable
  95. }
  96. },
  97. {
  98. ZCL_CLUSTER_ID_GEN_BASIC,
  99. { // Attribute record
  100. ATTRID_BASIC_HW_VERSION,
  101. ZCL_DATATYPE_UINT8,
  102. ACCESS_CONTROL_READ,
  103. (void *)&pctHWVersion
  104. }
  105. },
  106. {
  107. ZCL_CLUSTER_ID_GEN_BASIC,
  108. { // Attribute record
  109. ATTRID_BASIC_MANUFACTURER_NAME,
  110. ZCL_DATATYPE_CHAR_STR,
  111. ACCESS_CONTROL_READ,
  112. (void *)pctManufacturerName
  113. }
  114. },
  115. {
  116. ZCL_CLUSTER_ID_GEN_BASIC,
  117. { // Attribute record
  118. ATTRID_BASIC_MODEL_ID,
  119. ZCL_DATATYPE_CHAR_STR,
  120. ACCESS_CONTROL_READ,
  121. (void *)pctModelId
  122. }
  123. },
  124. {
  125. ZCL_CLUSTER_ID_GEN_BASIC,
  126. { // Attribute record
  127. ATTRID_BASIC_DATE_CODE,
  128. ZCL_DATATYPE_CHAR_STR,
  129. ACCESS_CONTROL_READ,
  130. (void *)pctDateCode
  131. }
  132. },
  133. {
  134. ZCL_CLUSTER_ID_GEN_BASIC,
  135. { // Attribute record
  136. ATTRID_BASIC_POWER_SOURCE,
  137. ZCL_DATATYPE_ENUM8,
  138. ACCESS_CONTROL_READ,
  139. (void *)&pctPowerSource
  140. }
  141. },
  142. {
  143. ZCL_CLUSTER_ID_GEN_BASIC,
  144. { // Attribute record
  145. ATTRID_BASIC_LOCATION_DESC,
  146. ZCL_DATATYPE_CHAR_STR,
  147. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  148. (void *)pctLocationDescription
  149. }
  150. },
  151. {
  152. ZCL_CLUSTER_ID_GEN_BASIC,
  153. { // Attribute record
  154. ATTRID_BASIC_PHYSICAL_ENV,
  155. ZCL_DATATYPE_ENUM8,
  156. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  157. (void *)&pctPhysicalEnvironment
  158. }
  159. },
  160. {
  161. ZCL_CLUSTER_ID_GEN_BASIC,
  162. { // Attribute record
  163. ATTRID_BASIC_DEVICE_ENABLED,
  164. ZCL_DATATYPE_BOOLEAN,
  165. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  166. (void *)&pctDeviceEnabled
  167. }
  168. },
  169. // *** Identify Cluster Attribute ***
  170. {
  171. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  172. { // Attribute record
  173. ATTRID_IDENTIFY_TIME,
  174. ZCL_DATATYPE_UINT16,
  175. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  176. (void *)&pctIdentifyTime
  177. }
  178. },
  179. // *** Time Cluster Attribute ***
  180. // In SE domain, only master clock will be used. Therefore
  181. // mark the access control to only readable.
  182. {
  183. ZCL_CLUSTER_ID_GEN_TIME,
  184. { // Attribute record
  185. ATTRID_TIME_TIME,
  186. ZCL_DATATYPE_UTC,
  187. ACCESS_CONTROL_READ,
  188. (void *)&pctTime
  189. }
  190. },
  191. // In SE domain, only master clock will be used. Therefore
  192. // mark the access control to only readable.
  193. {
  194. ZCL_CLUSTER_ID_GEN_TIME,
  195. { // Attribute record
  196. ATTRID_TIME_STATUS,
  197. ZCL_DATATYPE_BITMAP8,
  198. ACCESS_CONTROL_READ,
  199. (void *)&pctTimeStatus
  200. }
  201. },
  202. // SE Attributes
  203. {
  204. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  205. { // Attribute record
  206. ATTRID_SE_UTILITY_DEFINED_GROUP,
  207. ZCL_DATATYPE_UINT8,
  208. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  209. (void *)&pctUtilityDefinedGroup
  210. }
  211. },
  212. {
  213. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  214. { // Attribute record
  215. ATTRID_SE_START_RANDOMIZE_MINUTES,
  216. ZCL_DATATYPE_UINT8,
  217. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  218. (void *)&pctStartRandomizeMinutes
  219. }
  220. },
  221. {
  222. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  223. { // Attribute record
  224. ATTRID_SE_STOP_RANDOMIZE_MINUTES,
  225. ZCL_DATATYPE_UINT8,
  226. ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
  227. (void *)&pctStopRandomizeMinutes
  228. }
  229. },
  230. {
  231. ZCL_CLUSTER_ID_GEN_KEY_ESTABLISHMENT,
  232. { // Attribute record
  233. ATTRID_KEY_ESTABLISH_SUITE,
  234. ZCL_DATATYPE_BITMAP16,
  235. ACCESS_CONTROL_READ,
  236. (void *)&pctKeyEstablishmentSuite
  237. }
  238. },
  239. };
  240. /*********************************************************************
  241. * CLUSTER OPTION DEFINITIONS
  242. */
  243. zclOptionRec_t pctOptions[PCT_MAX_OPTIONS] =
  244. {
  245. // *** General Cluster Options ***
  246. {
  247. ZCL_CLUSTER_ID_GEN_TIME, // Cluster IDs - defined in the foundation (ie. zcl.h)
  248. ( AF_EN_SECURITY /*| AF_ACK_REQUEST*/ ), // Options - Found in AF header (ie. AF.h)
  249. },
  250. // *** Smart Energy Cluster Options ***
  251. {
  252. ZCL_CLUSTER_ID_SE_PRICING,
  253. ( AF_EN_SECURITY ),
  254. },
  255. {
  256. ZCL_CLUSTER_ID_SE_LOAD_CONTROL,
  257. ( AF_EN_SECURITY ),
  258. },
  259. };
  260. /*********************************************************************
  261. * SIMPLE DESCRIPTOR
  262. */
  263. // This is the Cluster ID List and should be filled with Application
  264. // specific cluster IDs.
  265. #define PCT_MAX_INCLUSTERS 4
  266. const cId_t pctInClusterList[PCT_MAX_INCLUSTERS] =
  267. {
  268. ZCL_CLUSTER_ID_GEN_BASIC,
  269. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  270. ZCL_CLUSTER_ID_GEN_TIME,
  271. ZCL_CLUSTER_ID_SE_LOAD_CONTROL
  272. };
  273. #define PCT_MAX_OUTCLUSTERS 4
  274. const cId_t pctOutClusterList[PCT_MAX_OUTCLUSTERS] =
  275. {
  276. ZCL_CLUSTER_ID_GEN_BASIC,
  277. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  278. ZCL_CLUSTER_ID_GEN_TIME,
  279. ZCL_CLUSTER_ID_SE_LOAD_CONTROL
  280. };
  281. SimpleDescriptionFormat_t pctSimpleDesc =
  282. {
  283. PCT_ENDPOINT, // uint8 Endpoint;
  284. ZCL_SE_PROFILE_ID, // uint16 AppProfId[2];
  285. ZCL_SE_DEVICEID_PCT, // uint16 AppDeviceId[2];
  286. PCT_DEVICE_VERSION, // int AppDevVer:4;
  287. PCT_FLAGS, // int AppFlags:4;
  288. PCT_MAX_INCLUSTERS, // uint8 AppNumInClusters;
  289. (cId_t *)pctInClusterList, // cId_t *pAppInClusterList;
  290. PCT_MAX_OUTCLUSTERS, // uint8 AppNumInClusters;
  291. (cId_t *)pctOutClusterList // cId_t *pAppInClusterList;
  292. };
  293. /*********************************************************************
  294. * GLOBAL FUNCTIONS
  295. */
  296. /*********************************************************************
  297. * LOCAL FUNCTIONS
  298. */
  299. /****************************************************************************
  300. ****************************************************************************/