zcl_pi.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /**************************************************************************************************
  2. Filename: zcl_pi.h
  3. Revised: $Date: 2010-09-28 08:39:46 -0700 (Tue, 28 Sep 2010) $
  4. Revision: $Revision: 23926 $
  5. Description: This file contains the ZCL Protocol Interfaces Definitions
  6. Copyright 2010 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_PI_H
  34. #define ZCL_PI_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. #include "zcl.h"
  43. /*********************************************************************
  44. * CONSTANTS
  45. */
  46. /*************************************************/
  47. /*** Protocol Interface Cluster Attributes ***/
  48. /*************************************************/
  49. // Attributes of the Generic Tunnel cluster
  50. #define ATTRID_PI_GENERIC_TUNNEL_MAX_IN_TRANSFER_SIZE 0x0001
  51. #define ATTRID_PI_GENERIC_TUNNEL_MAX_OUT_TRANSFER_SIZE 0x0002
  52. #define ATTRID_PI_GENERIC_TUNNEL_PROTOCOL_ADDR 0x0003
  53. // The BACnet Protocol Tunnel cluster does not contain any attributes
  54. // Attributes of the 11073 Protocol Tunnel cluster
  55. #define ATTRID_PI_11073_TUNNEL_DEVICEID_LIST 0x0000
  56. #define ATTRID_PI_11073_TUNNEL_MANAGER_TARGET 0x0001
  57. #define ATTRID_PI_11073_TUNNEL_MANAGER_ENDPOINT 0x0002
  58. #define ATTRID_PI_11073_TUNNEL_CONNECTED 0x0003
  59. #define ATTRID_PI_11073_TUNNEL_PREEMPTIBLE 0x0004
  60. #define ATTRID_PI_11073_TUNNEL_IDLE_TIMEOUT 0x0005
  61. // Attributes of the Input, Output and Value (BACnet Reqular) cluster
  62. #define ATTRID_IOV_BACNET_REG_CHANGE_OF_STATE_CNT 0x000F
  63. #define ATTRID_IOV_BACNET_REG_CHANGE_OF_STATE_TIME 0x0010
  64. #define ATTRID_IOV_BACNET_REG_COV_INCREMENT 0x0016
  65. #define ATTRID_IOV_BACNET_REG_DEVICE_TYPE 0x001F
  66. #define ATTRID_IOV_BACNET_REG_ELAPSED_ACT_TIME 0x0021
  67. #define ATTRID_IOV_BACNET_REG_FEEDBACK_VALUE 0x0028
  68. #define ATTRID_IOV_BACNET_REG_OBJECT_ID 0x004B
  69. #define ATTRID_IOV_BACNET_REG_OBJECT_NAME 0x004D
  70. #define ATTRID_IOV_BACNET_REG_OBJECT_TYPE 0x004F
  71. #define ATTRID_IOV_BACNET_REG_UPDATE_INT 0x0076
  72. #define ATTRID_IOV_BACNET_REG_TIME_OF_AT_RESET 0x0072
  73. #define ATTRID_IOV_BACNET_REG_TIME_OF_SC_RESET 0x0073
  74. #define ATTRID_IOV_BACNET_REG_PROFILE_NAME 0x00A8
  75. // Attributes of the Input, Output and Value (BACnet Extended) cluster
  76. #define ATTRID_IOV_BACNET_EXT_ACKED_TRANSIT 0x0000
  77. #define ATTRID_IOV_BACNET_EXT_ALARM_VALUE 0x0006
  78. //#define ATTRID_IOV_BACNET_EXT_ALARM_VALUES 0x0006
  79. #define ATTRID_IOV_BACNET_EXT_NOTIFY_CLASS 0x0011
  80. #define ATTRID_IOV_BACNET_EXT_DEADBAND 0x0019
  81. #define ATTRID_IOV_BACNET_EXT_EVENT_ENABLE 0x0023
  82. #define ATTRID_IOV_BACNET_EXT_EVENT_STATE 0x0024
  83. #define ATTRID_IOV_BACNET_EXT_FAULT_VALUES 0x0025
  84. #define ATTRID_IOV_BACNET_EXT_HI_LIMIT 0x002D
  85. #define ATTRID_IOV_BACNET_EXT_LIMIT_ENABLE 0x0034
  86. #define ATTRID_IOV_BACNET_EXT_LO_LIMIT 0x003B
  87. #define ATTRID_IOV_BACNET_EXT_NOTIFY_TYPE 0x0048
  88. #define ATTRID_IOV_BACNET_EXT_TIME_DELAY 0x0071
  89. #define ATTRID_IOV_BACNET_EXT_EV_TIME_STAMPS 0x0082
  90. /*** Connect Control field: 8-bit bitmap ***/
  91. // Preemptible (bit 1) - indicates whether or not this connection can be
  92. // removed by a different Data Management device.
  93. #define CONNECT_CTRL_PREEMPTIBLE_BIT 0x01
  94. /*** Connect status values ***/
  95. #define CONNECT_STATUS_DISCONNECTED 0x00
  96. #define CONNECT_STATUS_CONNECTED 0x01
  97. #define CONNECT_STATUS_NOT_AUTHORIZED 0x02
  98. #define CONNECT_STATUS_RECONNECT_REQ 0x03
  99. #define CONNECT_STATUS_ALREADY_CONNECTED 0x04
  100. /*** AckedTransitions attribute bits ***/
  101. #define ACKED_TRANSIT_TO_OFFNORMAL 0x01
  102. #define ACKED_TRANSIT_TO_FAULT 0x02
  103. #define ACKED_TRANSIT_TO_NORMAL 0x04
  104. /*** EventState attribute values ***/
  105. #define EVENT_STATE_NORMAL 0x00
  106. #define EVENT_STATE_FAULT 0x01
  107. #define EVENT_STATE_OFFNORMAL 0x02
  108. #define EVENT_STATE_HIGH_LIMIT 0x03
  109. #define EVENT_STATE_LOW_LIMIT 0x04
  110. /*** NotifyType attribute values ***/
  111. #define NORIFY_TYPE_EVENTS 0x00
  112. #define NORIFY_TYPE_ALARMS 0x01
  113. /*************************************************/
  114. /*** Protocol Interface Cluster Commands ***/
  115. /*************************************************/
  116. // Command IDs for the Generic Tunnel Cluster
  117. #define COMMAND_PI_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDR 0x00
  118. #define COMMAND_PI_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDR_RSP 0x00
  119. #define COMMAND_PI_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDR 0x01
  120. // Command IDs for the BACnet Protocol Tunnel Cluster
  121. #define COMMAND_PI_BACNET_TUNNEL_TRANSFER_NPDU 0x00
  122. // Command IDs for the 11073 Protocol Tunnel Cluster
  123. #define COMMAND_PI_11073_TUNNEL_TRANSFER_APDU 0x00
  124. #define COMMAND_PI_11073_TUNNEL_CONNECT_REQ 0x01
  125. #define COMMAND_PI_11073_TUNNEL_DISCONNECT_REQ 0x02
  126. #define COMMAND_PI_11073_TUNNEL_CONNECT_STATUS_NOTI 0x03
  127. /************************************************************************************
  128. * MACROS
  129. */
  130. /****************************************************************************
  131. * TYPEDEFS
  132. */
  133. /*** Structures used for callback functions ***/
  134. /*** ZCL Generic Tunnel Cluster: Match Protocol Address command ***/
  135. typedef struct
  136. {
  137. afAddrType_t *srcAddr; // requestor's address
  138. uint8 seqNum; // sequence number received with command
  139. uint8 len; // length of address protocol
  140. uint8 *protocolAddr; // protocol address
  141. } zclPIMatchProtocolAddr_t;
  142. /*** ZCL Generic Tunnel Cluster: Match Protocol Address Response ***/
  143. typedef struct
  144. {
  145. afAddrType_t *srcAddr; // responder's address
  146. uint8 *ieeeAddr; // device address
  147. uint8 len; // length of address protocol
  148. uint8 *protocolAddr; // protocol address
  149. } zclPIMatchProtocolAddrRsp_t;
  150. /*** ZCL Generic Tunnel Cluster: Advertise Protocol Address command ***/
  151. typedef struct
  152. {
  153. afAddrType_t *srcAddr; // requestor's address
  154. uint8 len; // length of address protocol
  155. uint8 *protocolAddr; // protocol address
  156. } zclPIAdvertiseProtocolAddr_t;
  157. /*** ZCL BACnet Protocol Tunnel Cluster: Transfer NPDU command ***/
  158. typedef struct
  159. {
  160. afAddrType_t *srcAddr; // requestor's address
  161. uint16 len; // length of BACnet NPDU
  162. uint8 *npdu; // BACnet NPDU
  163. } zclBACnetTransferNPDU_t;
  164. /*** ZCL 11073 Protocol Tunnel Cluster: Transfer APDU command ***/
  165. typedef struct
  166. {
  167. afAddrType_t *srcAddr; // requestor's address
  168. uint16 len; // length of 11073 APDU
  169. uint8 *apdu; // 11073 APDU
  170. } zcl11073TransferAPDU_t;
  171. /*** ZCL 11073 Protocol Tunnel Cluster: Connect Request command ***/
  172. typedef struct
  173. {
  174. afAddrType_t *srcAddr; // requestor's address
  175. uint8 seqNum; // sequence number received with command
  176. uint8 connectCtrl; // connect control
  177. uint16 idleTimeout; // inactivity time (in minutes) which Data Management device
  178. // will wait w/o receiving any data before it disconnects
  179. uint8 *managerAddr; // IEEE address (64-bit) of Data Management device
  180. // transmitting this frame
  181. uint8 managerEP; // source endpoint from which Data Management device is
  182. // transmitting this frame
  183. } zcl11073ConnectReq_t;
  184. /*** ZCL 11073 Protocol Tunnel Cluster: Disconnect Request command ***/
  185. typedef struct
  186. {
  187. afAddrType_t *srcAddr; // requestor's address
  188. uint8 seqNum; // sequence number received with command
  189. uint8 *managerAddr; // IEEE address (64-bit) of Data Management device
  190. // transmitting this frame
  191. } zcl11073DisconnectReq_t;
  192. /*** ZCL 11073 Protocol Tunnel Cluster: Connect Status Notification command ***/
  193. typedef struct
  194. {
  195. afAddrType_t *srcAddr; // requestor's address
  196. uint8 connectStatus; // connect status
  197. } zcl11073ConnectStatusNoti_t;
  198. // This callback is called to process a Match Protocol Address command
  199. // pCmd - received command data
  200. typedef void (*zclPICB_MatchProtocolAddr_t)( zclPIMatchProtocolAddr_t *pCmd );
  201. // This callback is called to process a Match Protocol Address response
  202. // pCmd - received command data
  203. typedef void (*zclPICB_MatchProtocolAddrRsp_t)( zclPIMatchProtocolAddrRsp_t *pRsp );
  204. // This callback is called to process a Advertise Protocol Address command
  205. // pCmd - received command data
  206. typedef void (*zclPICB_AdvertiseProtocolAddr_t)( zclPIAdvertiseProtocolAddr_t *pCmd );
  207. // This callback is called to process a BACnet Transfer NPDU command
  208. // pCmd - received command data
  209. typedef void (*zclPICB_BACnetTransferNPDU_t)( zclBACnetTransferNPDU_t *pCmd );
  210. // This callback is called to process an 11037 Transfer APDU command
  211. // pCmd - received command data
  212. typedef void (*zclPICB_11073TransferAPDU_t)( zcl11073TransferAPDU_t *pCmd );
  213. // This callback is called to process an 11037 Connect Request command
  214. // pCmd - received command data
  215. typedef void (*zclPICB_11073ConnectReq_t)( zcl11073ConnectReq_t *pCmd );
  216. // This callback is called to process an 11037 Disconnect Request command
  217. // pCmd - received command data
  218. typedef void (*zclPICB_11073DisconnectReq_t)( zcl11073DisconnectReq_t *pCmd );
  219. // This callback is called to process an 11037 Connect Status Notification command
  220. // pCmd - received command data
  221. typedef void (*zclPICB_11073ConnectStatusNoti_t)( zcl11073ConnectStatusNoti_t *pCmd );
  222. // Register Callbacks table entry - enter function pointers for callbacks that
  223. // the application would like to receive
  224. typedef struct
  225. {
  226. zclPICB_MatchProtocolAddr_t pfnPI_MatchProtocolAddr;
  227. zclPICB_MatchProtocolAddrRsp_t pfnPI_MatchProtocolAddrRsp;
  228. zclPICB_AdvertiseProtocolAddr_t pfnPI_AdvertiseProtocolAddr;
  229. zclPICB_BACnetTransferNPDU_t pfnPI_BACnetTransferNPDU;
  230. zclPICB_11073TransferAPDU_t pfnPI_11073TransferAPDU;
  231. zclPICB_11073ConnectReq_t pfnPI_11073ConnectReq;
  232. zclPICB_11073DisconnectReq_t pfnPI_11073DisconnectReq;
  233. zclPICB_11073ConnectStatusNoti_t pfnPI_11073ConnectStatusNoti;
  234. } zclPI_AppCallbacks_t;
  235. /*********************************************************************
  236. * FUNCTION MACROS
  237. */
  238. /*
  239. * Send a BACnet Transfer NPDU Command. This command is used when a
  240. * BACnet network layer wishes to transfer a BACnet NPDU across a
  241. * ZigBee tunnel to another BACnet network layer.
  242. *
  243. * Use like: ZStatus_t zclPI_Send_BACnetTransferNPDUCmd( uint16 srcEP, afAddrType_t *dstAddr,
  244. * uint16 len, uint8 *npdu,
  245. * uint8 disableDefaultRsp, uint8 seqNum );
  246. * @param srcEP - Sending application's endpoint
  247. * @param dstAddr - where you want the message to go
  248. * @param len - length of NPDU
  249. * @param npdu - pointer to NPDU to be sent
  250. * @param disableDefaultRsp - whether to disable the Default Response command
  251. * @param seqNum - sequence number
  252. *
  253. * @return ZStatus_t
  254. */
  255. #define zclPI_Send_BACnetTransferNPDUCmd(a,b,c,d,e,f) zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_PI_BACNET_PROTOCOL_TUNNEL,\
  256. COMMAND_PI_BACNET_TUNNEL_TRANSFER_NPDU, TRUE,\
  257. ZCL_FRAME_CLIENT_SERVER_DIR, (e), 0, (f), (c), (d) )
  258. /*
  259. * Call to send out an 11073 Disconnect Request Command. This command
  260. * is generated when a Data Management device wishes to disconnect a
  261. * tunnel connection existing on an agent device.
  262. *
  263. * Use Like: ZStatus_t zclPI_Send_11073DisconnectReq( uint8 srcEP, afAddrType_t *dstAddr,
  264. * uint8 *managerAddr,
  265. * uint8 disableDefaultRsp, uint8 seqNum );
  266. * @param srcEP - Sending application's endpoint
  267. * @param dstAddr - where you want the message to go
  268. * @param managerAddr - IEEE address (64-bit) of Data Management device
  269. transmitting this frame
  270. * @param disableDefaultRsp - whether to disable the Default Response command
  271. * @param seqNum - sequence number
  272. *
  273. * @return ZStatus_t
  274. */
  275. #define zclPI_Send_11073DisconnectReq(a,b,c,d,e) zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL,\
  276. COMMAND_PI_11073_TUNNEL_DISCONNECT_REQ, TRUE,\
  277. ZCL_FRAME_CLIENT_SERVER_DIR, (d), 0, (e),\
  278. Z_EXTADDR_LEN, (c) )
  279. /*
  280. * Call to send out an 11073 Connect Status Notification Command. This
  281. * command is generated by an agent device in response to a connect
  282. * request command, disconnect command, or in response to some other
  283. * event that causes the tunnel to become connected or disconnected.
  284. * It is also sent by the agent device to request the Data Management
  285. * device to reconnect a tunnel.
  286. *
  287. * Use Like: ZStatus_t zclPI_Send_11073ConnectStatusNoti( uint8 srcEP, afAddrType_t *dstAddr,
  288. * uint8 connectStatus, uint8 disableDefaultRsp,
  289. * uint8 seqNum );
  290. * @param srcEP - Sending application's endpoint
  291. * @param dstAddr - where you want the message to go
  292. * @param connectStatus - connect status
  293. * @param disableDefaultRsp - whether to disable the Default Response command
  294. * @param seqNum - sequence number
  295. *
  296. * @return ZStatus_t
  297. */
  298. #define zclPI_Send_11073ConnectStatusNoti(a,b,c,d,e) zcl_SendCommand( (a), (b), ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL,\
  299. COMMAND_PI_11073_TUNNEL_CONNECT_STATUS_NOTI, TRUE,\
  300. ZCL_FRAME_SERVER_CLIENT_DIR, (d), 0, (e), 1, &(c) )
  301. /****************************************************************************
  302. * VARIABLES
  303. */
  304. /****************************************************************************
  305. * FUNCTIONS
  306. */
  307. /*
  308. * Register for callbacks from this cluster library
  309. */
  310. extern ZStatus_t zclPI_RegisterCmdCallbacks( uint8 endpoint, zclPI_AppCallbacks_t *callbacks );
  311. /*
  312. * Send out a Match Protocol Address Command
  313. */
  314. extern ZStatus_t zclPI_Send_MatchProtocolAddrCmd( uint8 srcEP, afAddrType_t *dstAddr,
  315. uint8 len, uint8 *protocolAddr,
  316. uint8 disableDefaultRsp, uint8 seqNum );
  317. /*
  318. * Send a Match Protocol Address Response
  319. */
  320. extern ZStatus_t zclPI_Send_MatchProtocolAddrRsp( uint8 srcEP, afAddrType_t *dstAddr,
  321. uint8 *ieeeAddr, uint8 len, uint8 *protocolAddr,
  322. uint8 disableDefaultRsp, uint8 seqNum );
  323. /*
  324. * Send out an Advertise Protocol Address Command
  325. */
  326. extern ZStatus_t zclPI_Send_AdvertiseProtocolAddrCmd( uint8 srcEP, afAddrType_t *dstAddr,
  327. uint8 len, uint8 *protocolAddr,
  328. uint8 disableDefaultRsp, uint8 seqNum );
  329. /*
  330. * Send out an 11073 Transfer APDU Command
  331. */
  332. extern ZStatus_t zclPI_Send_11073TransferAPDUCmd( uint8 srcEP, afAddrType_t *dstAddr,
  333. uint16 len, uint8 *apdu, uint8 seqNum );
  334. /*
  335. * Send out an 11073 Connect Request Command
  336. */
  337. extern ZStatus_t zclPI_Send_11073ConnectReq( uint8 srcEP, afAddrType_t *dstAddr,
  338. uint8 connectCtrl, uint16 idleTimeout,
  339. uint8 *managerAddr, uint8 managerEP,
  340. uint8 disableDefaultRsp, uint8 seqNum );
  341. /*********************************************************************
  342. *********************************************************************/
  343. #ifdef __cplusplus
  344. }
  345. #endif
  346. #endif /* ZCL_PI_H */