ipd_data.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /**************************************************************************************************
  2. Filename: ipd_data.c
  3. Revised: $Date: 2011-05-17 17:00:08 -0700 (Tue, 17 May 2011) $
  4. Revision: $Revision: 26006 $
  5. Description: File that contains attribute and simple descriptor
  6. definitions for the IPD
  7. Copyright 2009-2011 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 "ipd.h"
  41. #include "zcl_general.h"
  42. #include "zcl_key_establish.h"
  43. /*********************************************************************
  44. * CONSTANTS
  45. */
  46. #define IPD_DEVICE_VERSION 0
  47. #define IPD_FLAGS 0
  48. #define IPD_HWVERSION 1
  49. #define IPD_ZCLVERSION 1
  50. /*********************************************************************
  51. * TYPEDEFS
  52. */
  53. /*********************************************************************
  54. * MACROS
  55. */
  56. /*********************************************************************
  57. * GLOBAL VARIABLES
  58. */
  59. // Basic Cluster
  60. const uint8 ipdZCLVersion = IPD_ZCLVERSION;
  61. const uint8 ipdHWVersion = IPD_HWVERSION;
  62. const uint8 ipdManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
  63. const uint8 ipdModelId[] = { 16, 'T','I','0','0','0','1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  64. const uint8 ipdDateCode[] = { 16, '2','0','0','6','0','8','3','1',' ',' ',' ',' ',' ',' ',' ',' ' };
  65. const uint8 ipdPowerSource = POWER_SOURCE_MAINS_1_PHASE;
  66. uint8 ipdLocationDescription[] = { 16, ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  67. uint8 ipdPhysicalEnvironment = PHY_UNSPECIFIED_ENV;
  68. uint8 ipdDeviceEnabled = DEVICE_ENABLED;
  69. // Identify Cluster Attributes
  70. uint16 ipdIdentifyTime = 0;
  71. uint32 ipdTime = 0;
  72. uint8 ipdTimeStatus = 0x01;
  73. // Key Establishment
  74. uint16 ipdKeyEstablishmentSuite = CERTIFICATE_BASED_KEY_ESTABLISHMENT;
  75. /*********************************************************************
  76. * ATTRIBUTE DEFINITIONS - Uses Cluster IDs
  77. */
  78. CONST zclAttrRec_t ipdAttrs[IPD_MAX_ATTRIBUTES] =
  79. {
  80. // *** General Basic Cluster Attributes ***
  81. {
  82. ZCL_CLUSTER_ID_GEN_BASIC, // Cluster IDs - defined in the foundation (ie. zcl.h)
  83. { // Attribute record
  84. ATTRID_BASIC_ZCL_VERSION, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  85. ZCL_DATATYPE_UINT8, // Data Type - found in zcl.h
  86. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  87. (void *)&ipdZCLVersion // Pointer to attribute variable
  88. }
  89. },
  90. {
  91. ZCL_CLUSTER_ID_GEN_BASIC,
  92. { // Attribute record
  93. ATTRID_BASIC_HW_VERSION,
  94. ZCL_DATATYPE_UINT8,
  95. ACCESS_CONTROL_READ,
  96. (void *)&ipdHWVersion
  97. }
  98. },
  99. {
  100. ZCL_CLUSTER_ID_GEN_BASIC,
  101. { // Attribute record
  102. ATTRID_BASIC_MANUFACTURER_NAME,
  103. ZCL_DATATYPE_CHAR_STR,
  104. ACCESS_CONTROL_READ,
  105. (void *)ipdManufacturerName
  106. }
  107. },
  108. {
  109. ZCL_CLUSTER_ID_GEN_BASIC,
  110. { // Attribute record
  111. ATTRID_BASIC_MODEL_ID,
  112. ZCL_DATATYPE_CHAR_STR,
  113. ACCESS_CONTROL_READ,
  114. (void *)ipdModelId
  115. }
  116. },
  117. {
  118. ZCL_CLUSTER_ID_GEN_BASIC,
  119. { // Attribute record
  120. ATTRID_BASIC_DATE_CODE,
  121. ZCL_DATATYPE_CHAR_STR,
  122. ACCESS_CONTROL_READ,
  123. (void *)ipdDateCode
  124. }
  125. },
  126. {
  127. ZCL_CLUSTER_ID_GEN_BASIC,
  128. { // Attribute record
  129. ATTRID_BASIC_POWER_SOURCE,
  130. ZCL_DATATYPE_ENUM8,
  131. ACCESS_CONTROL_READ,
  132. (void *)&ipdPowerSource
  133. }
  134. },
  135. {
  136. ZCL_CLUSTER_ID_GEN_BASIC,
  137. { // Attribute record
  138. ATTRID_BASIC_LOCATION_DESC,
  139. ZCL_DATATYPE_CHAR_STR,
  140. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  141. (void *)ipdLocationDescription
  142. }
  143. },
  144. {
  145. ZCL_CLUSTER_ID_GEN_BASIC,
  146. { // Attribute record
  147. ATTRID_BASIC_PHYSICAL_ENV,
  148. ZCL_DATATYPE_ENUM8,
  149. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  150. (void *)&ipdPhysicalEnvironment
  151. }
  152. },
  153. {
  154. ZCL_CLUSTER_ID_GEN_BASIC,
  155. { // Attribute record
  156. ATTRID_BASIC_DEVICE_ENABLED,
  157. ZCL_DATATYPE_BOOLEAN,
  158. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  159. (void *)&ipdDeviceEnabled
  160. }
  161. },
  162. // *** Identify Cluster Attribute ***
  163. {
  164. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  165. { // Attribute record
  166. ATTRID_IDENTIFY_TIME,
  167. ZCL_DATATYPE_UINT16,
  168. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  169. (void *)&ipdIdentifyTime
  170. }
  171. },
  172. // *** Time Cluster Attribute ***
  173. // In SE domain, only master clock will be used. Therefore
  174. // mark the access control to only readable.
  175. {
  176. ZCL_CLUSTER_ID_GEN_TIME,
  177. { // Attribute record
  178. ATTRID_TIME_TIME,
  179. ZCL_DATATYPE_UTC,
  180. ACCESS_CONTROL_READ,
  181. (void *)&ipdTime
  182. }
  183. },
  184. // In SE domain, only master clock will be used. Therefore
  185. // mark the access control to only readable.
  186. {
  187. ZCL_CLUSTER_ID_GEN_TIME,
  188. { // Attribute record
  189. ATTRID_TIME_STATUS,
  190. ZCL_DATATYPE_BITMAP8,
  191. ACCESS_CONTROL_READ,
  192. (void *)&ipdTimeStatus
  193. }
  194. },
  195. {
  196. ZCL_CLUSTER_ID_GEN_KEY_ESTABLISHMENT,
  197. { // Attribute record
  198. ATTRID_KEY_ESTABLISH_SUITE,
  199. ZCL_DATATYPE_BITMAP16,
  200. ACCESS_CONTROL_READ,
  201. (void *)&ipdKeyEstablishmentSuite
  202. }
  203. },
  204. };
  205. /*********************************************************************
  206. * CLUSTER OPTION DEFINITIONS
  207. */
  208. zclOptionRec_t ipdOptions[IPD_MAX_OPTIONS] =
  209. {
  210. // *** General Cluster Options ***
  211. {
  212. ZCL_CLUSTER_ID_GEN_TIME, // Cluster IDs - defined in the foundation (ie. zcl.h)
  213. ( AF_EN_SECURITY /*| AF_ACK_REQUEST*/ ), // Options - Found in AF header (ie. AF.h)
  214. },
  215. // *** Smart Energy Cluster Options ***
  216. {
  217. ZCL_CLUSTER_ID_SE_PRICING,
  218. ( AF_EN_SECURITY ),
  219. },
  220. {
  221. ZCL_CLUSTER_ID_SE_MESSAGE,
  222. ( AF_EN_SECURITY ),
  223. },
  224. {
  225. ZCL_CLUSTER_ID_SE_SIMPLE_METERING,
  226. ( AF_EN_SECURITY ),
  227. },
  228. {
  229. ZCL_CLUSTER_ID_SE_PREPAYMENT,
  230. ( AF_EN_SECURITY ),
  231. },
  232. };
  233. /*********************************************************************
  234. * SIMPLE DESCRIPTOR
  235. */
  236. // This is the Cluster ID List and should be filled with Application
  237. // specific cluster IDs.
  238. #define IPD_MAX_INCLUSTERS 6
  239. const cId_t ipdInClusterList[IPD_MAX_INCLUSTERS] =
  240. {
  241. ZCL_CLUSTER_ID_GEN_BASIC,
  242. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  243. ZCL_CLUSTER_ID_GEN_TIME,
  244. ZCL_CLUSTER_ID_SE_PRICING,
  245. ZCL_CLUSTER_ID_SE_MESSAGE,
  246. ZCL_CLUSTER_ID_SE_PREPAYMENT
  247. };
  248. #define IPD_MAX_OUTCLUSTERS 6
  249. const cId_t ipdOutClusterList[IPD_MAX_OUTCLUSTERS] =
  250. {
  251. ZCL_CLUSTER_ID_GEN_BASIC,
  252. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  253. ZCL_CLUSTER_ID_GEN_TIME,
  254. ZCL_CLUSTER_ID_SE_PRICING,
  255. ZCL_CLUSTER_ID_SE_MESSAGE,
  256. ZCL_CLUSTER_ID_SE_PREPAYMENT
  257. };
  258. SimpleDescriptionFormat_t ipdSimpleDesc =
  259. {
  260. IPD_ENDPOINT, // uint8 Endpoint;
  261. ZCL_SE_PROFILE_ID, // uint16 AppProfId[2];
  262. #if defined ( ZCL_PREPAYMENT )
  263. ZCL_SE_DEVICEID_PREPAY_TERMINAL, // uint16 AppDeviceId[2];
  264. #else
  265. ZCL_SE_DEVICEID_IN_PREMISE_DISPLAY, // uint16 AppDeviceId[2];
  266. #endif
  267. IPD_DEVICE_VERSION, // int AppDevVer:4;
  268. IPD_FLAGS, // int AppFlags:4;
  269. IPD_MAX_INCLUSTERS, // uint8 AppNumInClusters;
  270. (cId_t *)ipdInClusterList, // cId_t *pAppInClusterList;
  271. IPD_MAX_OUTCLUSTERS, // uint8 AppNumInClusters;
  272. (cId_t *)ipdOutClusterList // cId_t *pAppInClusterList;
  273. };
  274. /*********************************************************************
  275. * GLOBAL FUNCTIONS
  276. */
  277. /*********************************************************************
  278. * LOCAL FUNCTIONS
  279. */
  280. /****************************************************************************
  281. ****************************************************************************/