zcl_samplelight_data.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /**************************************************************************************************
  2. Filename: zcl_samplelight_data.c
  3. Revised: $Date: 2008-03-11 11:01:35 -0700 (Tue, 11 Mar 2008) $
  4. Revision: $Revision: 16570 $
  5. Description: Zigbee Cluster Library - sample device application.
  6. Copyright 2006-2007 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. /*********************************************************************
  34. * INCLUDES
  35. */
  36. #include "ZComDef.h"
  37. #include "OSAL.h"
  38. #include "AF.h"
  39. #include "ZDConfig.h"
  40. #include "zcl.h"
  41. #include "zcl_general.h"
  42. #include "zcl_ha.h"
  43. #include "zcl_samplelight.h"
  44. /*********************************************************************
  45. * CONSTANTS
  46. */
  47. #define SAMPLELIGHT_DEVICE_VERSION 0
  48. #define SAMPLELIGHT_FLAGS 0
  49. #define SAMPLELIGHT_HWVERSION 1
  50. #define SAMPLELIGHT_ZCLVERSION 1
  51. /*********************************************************************
  52. * TYPEDEFS
  53. */
  54. /*********************************************************************
  55. * MACROS
  56. */
  57. /*********************************************************************
  58. * GLOBAL VARIABLES
  59. */
  60. // Basic Cluster
  61. const uint8 zclSampleLight_HWRevision = SAMPLELIGHT_HWVERSION;
  62. const uint8 zclSampleLight_ZCLVersion = SAMPLELIGHT_ZCLVERSION;
  63. const uint8 zclSampleLight_ManufacturerName[] = { 16, 'T','e','x','a','s','I','n','s','t','r','u','m','e','n','t','s' };
  64. const uint8 zclSampleLight_ModelId[] = { 16, 'T','I','0','0','0','1',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  65. const uint8 zclSampleLight_DateCode[] = { 16, '2','0','0','6','0','8','3','1',' ',' ',' ',' ',' ',' ',' ',' ' };
  66. const uint8 zclSampleLight_PowerSource = POWER_SOURCE_MAINS_1_PHASE;
  67. uint8 zclSampleLight_LocationDescription[17] = { 16, ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ' };
  68. uint8 zclSampleLight_PhysicalEnvironment = 0;
  69. uint8 zclSampleLight_DeviceEnable = DEVICE_ENABLED;
  70. // Identify Cluster
  71. uint16 zclSampleLight_IdentifyTime = 0;
  72. // On/Off Cluster
  73. uint8 zclSampleLight_OnOff = LIGHT_OFF;
  74. /*********************************************************************
  75. * ATTRIBUTE DEFINITIONS - Uses REAL cluster IDs
  76. */
  77. CONST zclAttrRec_t zclSampleLight_Attrs[SAMPLELIGHT_MAX_ATTRIBUTES] =
  78. {
  79. // *** General Basic Cluster Attributes ***
  80. {
  81. ZCL_CLUSTER_ID_GEN_BASIC, // Cluster IDs - defined in the foundation (ie. zcl.h)
  82. { // Attribute record
  83. ATTRID_BASIC_HW_VERSION, // Attribute ID - Found in Cluster Library header (ie. zcl_general.h)
  84. ZCL_DATATYPE_UINT8, // Data Type - found in zcl.h
  85. ACCESS_CONTROL_READ, // Variable access control - found in zcl.h
  86. (void *)&zclSampleLight_HWRevision // Pointer to attribute variable
  87. }
  88. },
  89. {
  90. ZCL_CLUSTER_ID_GEN_BASIC,
  91. { // Attribute record
  92. ATTRID_BASIC_ZCL_VERSION,
  93. ZCL_DATATYPE_UINT8,
  94. ACCESS_CONTROL_READ,
  95. (void *)&zclSampleLight_ZCLVersion
  96. }
  97. },
  98. {
  99. ZCL_CLUSTER_ID_GEN_BASIC,
  100. { // Attribute record
  101. ATTRID_BASIC_MANUFACTURER_NAME,
  102. ZCL_DATATYPE_CHAR_STR,
  103. ACCESS_CONTROL_READ,
  104. (void *)zclSampleLight_ManufacturerName
  105. }
  106. },
  107. {
  108. ZCL_CLUSTER_ID_GEN_BASIC,
  109. { // Attribute record
  110. ATTRID_BASIC_MODEL_ID,
  111. ZCL_DATATYPE_CHAR_STR,
  112. ACCESS_CONTROL_READ,
  113. (void *)zclSampleLight_ModelId
  114. }
  115. },
  116. {
  117. ZCL_CLUSTER_ID_GEN_BASIC,
  118. { // Attribute record
  119. ATTRID_BASIC_DATE_CODE,
  120. ZCL_DATATYPE_CHAR_STR,
  121. ACCESS_CONTROL_READ,
  122. (void *)zclSampleLight_DateCode
  123. }
  124. },
  125. {
  126. ZCL_CLUSTER_ID_GEN_BASIC,
  127. { // Attribute record
  128. ATTRID_BASIC_POWER_SOURCE,
  129. ZCL_DATATYPE_UINT8,
  130. ACCESS_CONTROL_READ,
  131. (void *)&zclSampleLight_PowerSource
  132. }
  133. },
  134. {
  135. ZCL_CLUSTER_ID_GEN_BASIC,
  136. { // Attribute record
  137. ATTRID_BASIC_LOCATION_DESC,
  138. ZCL_DATATYPE_CHAR_STR,
  139. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  140. (void *)zclSampleLight_LocationDescription
  141. }
  142. },
  143. {
  144. ZCL_CLUSTER_ID_GEN_BASIC,
  145. { // Attribute record
  146. ATTRID_BASIC_PHYSICAL_ENV,
  147. ZCL_DATATYPE_UINT8,
  148. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  149. (void *)&zclSampleLight_PhysicalEnvironment
  150. }
  151. },
  152. {
  153. ZCL_CLUSTER_ID_GEN_BASIC,
  154. { // Attribute record
  155. ATTRID_BASIC_DEVICE_ENABLED,
  156. ZCL_DATATYPE_BOOLEAN,
  157. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  158. (void *)&zclSampleLight_DeviceEnable
  159. }
  160. },
  161. // *** Identify Cluster Attribute ***
  162. {
  163. ZCL_CLUSTER_ID_GEN_IDENTIFY,
  164. { // Attribute record
  165. ATTRID_IDENTIFY_TIME,
  166. ZCL_DATATYPE_UINT16,
  167. (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
  168. (void *)&zclSampleLight_IdentifyTime
  169. }
  170. },
  171. // *** On/Off Cluster Attributes ***
  172. {
  173. ZCL_CLUSTER_ID_GEN_ON_OFF,
  174. { // Attribute record
  175. ATTRID_ON_OFF,
  176. ZCL_DATATYPE_UINT8,
  177. ACCESS_CONTROL_READ,
  178. (void *)&zclSampleLight_OnOff
  179. }
  180. },
  181. };
  182. /*********************************************************************
  183. * SIMPLE DESCRIPTOR
  184. */
  185. // This is the Cluster ID List and should be filled with Application
  186. // specific cluster IDs.
  187. #define ZCLSAMPLELIGHT_MAX_INCLUSTERS 5
  188. const cId_t zclSampleLight_InClusterList[ZCLSAMPLELIGHT_MAX_INCLUSTERS] =
  189. {
  190. ZCL_CLUSTER_ID_GEN_BASIC,
  191. ZCL_CLUSTER_ID_GEN_SCENES,
  192. ZCL_CLUSTER_ID_GEN_GROUPS,
  193. ZCL_CLUSTER_ID_GEN_ON_OFF,
  194. ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL
  195. };
  196. #define ZCLSAMPLELIGHT_MAX_OUTCLUSTERS 1
  197. const cId_t zclSampleLight_OutClusterList[ZCLSAMPLELIGHT_MAX_OUTCLUSTERS] =
  198. {
  199. ZCL_CLUSTER_ID_GEN_BASIC
  200. };
  201. SimpleDescriptionFormat_t zclSampleLight_SimpleDesc =
  202. {
  203. SAMPLELIGHT_ENDPOINT, // int Endpoint;
  204. ZCL_HA_PROFILE_ID, // uint16 AppProfId[2];
  205. ZCL_HA_DEVICEID_DIMMABLE_LIGHT, // uint16 AppDeviceId[2];
  206. SAMPLELIGHT_DEVICE_VERSION, // int AppDevVer:4;
  207. SAMPLELIGHT_FLAGS, // int AppFlags:4;
  208. ZCLSAMPLELIGHT_MAX_INCLUSTERS, // byte AppNumInClusters;
  209. (cId_t *)zclSampleLight_InClusterList, // byte *pAppInClusterList;
  210. ZCLSAMPLELIGHT_MAX_OUTCLUSTERS, // byte AppNumInClusters;
  211. (cId_t *)zclSampleLight_OutClusterList // byte *pAppInClusterList;
  212. };
  213. /*********************************************************************
  214. * GLOBAL FUNCTIONS
  215. */
  216. /*********************************************************************
  217. * LOCAL FUNCTIONS
  218. */
  219. /****************************************************************************
  220. ****************************************************************************/