ZDProfile.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /**************************************************************************************************
  2. Filename: ZDProfile.h
  3. Revised: $Date: 2008-06-17 08:47:15 -0700 (Tue, 17 Jun 2008) $
  4. Revision: $Revision: 17269 $
  5. Description: This file contains the interface to the Zigbee Device Object.
  6. Copyright 2004-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. #ifndef ZDPROFILE_H
  34. #define ZDPROFILE_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /*********************************************************************
  40. * INCLUDES
  41. */
  42. #include "ZComDef.h"
  43. #include "NLMEDE.h"
  44. #include "AF.h"
  45. #include "ZDConfig.h"
  46. /*********************************************************************
  47. * CONSTANTS
  48. */
  49. #define ZDO_EP 0 // Endpoint of ZDO
  50. #define ZDO_PROFILE_ID 0
  51. // IEEE_addr_req request types
  52. #define ZDP_ADDR_REQTYPE_SINGLE 0
  53. #define ZDP_ADDR_REQTYPE_EXTENDED 1
  54. #define ZDP_ADDR_REQTYPE_MEMBERSHIP 2
  55. // ZDO Status Values
  56. #define ZDP_SUCCESS 0x00 // Operation completed successfully
  57. #define ZDP_INVALID_REQTYPE 0x80 // The supplied request type was invalid
  58. #define ZDP_DEVICE_NOT_FOUND 0x81 // Reserved
  59. #define ZDP_INVALID_EP 0x82 // Invalid endpoint value
  60. #define ZDP_NOT_ACTIVE 0x83 // Endpoint not described by a simple desc.
  61. #define ZDP_NOT_SUPPORTED 0x84 // Optional feature not supported
  62. #define ZDP_TIMEOUT 0x85 // Operation has timed out
  63. #define ZDP_NO_MATCH 0x86 // No match for end device bind
  64. #define ZDP_TABLE_FULL 0x87 // Bind request failed, no resources
  65. #define ZDP_NO_ENTRY 0x88 // Unbind request failed, no entry
  66. #define ZDP_INSUFFICIENT_SPACE 0x8a
  67. #define ZDP_NOT_PERMITTED 0x8b
  68. #define ZDP_NETWORK_DISCRIPTOR_SIZE 8
  69. #define ZDP_NETWORK_EXTENDED_DISCRIPTOR_SIZE 14
  70. #define ZDP_RTG_DISCRIPTOR_SIZE 5
  71. #define ZDP_BIND_DISCRIPTOR_SIZE 19
  72. // Mgmt_Permit_Join_req fields
  73. #define ZDP_MGMT_PERMIT_JOIN_REQ_DURATION 0
  74. #define ZDP_MGMT_PERMIT_JOIN_REQ_TC_SIG 1
  75. #define ZDP_MGMT_PERMIT_JOIN_REQ_SIZE 2
  76. // Mgmt_Leave_req fields
  77. #define ZDP_MGMT_LEAVE_REQ_REJOIN 1 << 7
  78. #define ZDP_MGMT_LEAVE_REQ_RC 1 << 6 // Remove Children
  79. // Mgmt_Lqi_rsp - (neighbor table) device type
  80. #define ZDP_MGMT_DT_COORD 0x0
  81. #define ZDP_MGMT_DT_ROUTER 0x1
  82. #define ZDP_MGMT_DT_ENDDEV 0x2
  83. // Mgmt_Lqi_rsp - (neighbor table) relationship
  84. #define ZDP_MGMT_REL_PARENT 0x0
  85. #define ZDP_MGMT_REL_CHILD 0x1
  86. #define ZDP_MGMT_REL_SIBLING 0x2
  87. #define ZDP_MGMT_REL_UNKNOWN 0x3
  88. // Mgmt_Lqi_rsp - (neighbor table) unknown boolean value
  89. #define ZDP_MGMT_BOOL_UNKNOWN 0x02
  90. /*********************************************************************
  91. * Message/Cluster IDS
  92. */
  93. // ZDO Cluster IDs
  94. #define ZDO_RESPONSE_BIT_V1_0 ((uint8)0x80)
  95. #define ZDO_RESPONSE_BIT ((uint16)0x8000)
  96. #define NWK_addr_req ((uint16)0x0000)
  97. #define IEEE_addr_req ((uint16)0x0001)
  98. #define Node_Desc_req ((uint16)0x0002)
  99. #define Power_Desc_req ((uint16)0x0003)
  100. #define Simple_Desc_req ((uint16)0x0004)
  101. #define Active_EP_req ((uint16)0x0005)
  102. #define Match_Desc_req ((uint16)0x0006)
  103. #define NWK_addr_rsp (NWK_addr_req | ZDO_RESPONSE_BIT)
  104. #define IEEE_addr_rsp (IEEE_addr_req | ZDO_RESPONSE_BIT)
  105. #define Node_Desc_rsp (Node_Desc_req | ZDO_RESPONSE_BIT)
  106. #define Power_Desc_rsp (Power_Desc_req | ZDO_RESPONSE_BIT)
  107. #define Simple_Desc_rsp (Simple_Desc_req | ZDO_RESPONSE_BIT)
  108. #define Active_EP_rsp (Active_EP_req | ZDO_RESPONSE_BIT)
  109. #define Match_Desc_rsp (Match_Desc_req | ZDO_RESPONSE_BIT)
  110. #define Complex_Desc_req ((uint16)0x0010)
  111. #define User_Desc_req ((uint16)0x0011)
  112. #define Discovery_Cache_req ((uint16)0x0012)
  113. #define Device_annce ((uint16)0x0013)
  114. #define User_Desc_set ((uint16)0x0014)
  115. #define Server_Discovery_req ((uint16)0x0015)
  116. #define Complex_Desc_rsp (Complex_Desc_req | ZDO_RESPONSE_BIT)
  117. #define User_Desc_rsp (User_Desc_req | ZDO_RESPONSE_BIT)
  118. #define Discovery_Cache_rsp (Discovery_Cache_req | ZDO_RESPONSE_BIT)
  119. #define User_Desc_conf (User_Desc_set | ZDO_RESPONSE_BIT)
  120. #define Server_Discovery_rsp (Server_Discovery_req | ZDO_RESPONSE_BIT)
  121. #define End_Device_Bind_req ((uint16)0x0020)
  122. #define Bind_req ((uint16)0x0021)
  123. #define Unbind_req ((uint16)0x0022)
  124. #define Bind_rsp (Bind_req | ZDO_RESPONSE_BIT)
  125. #define End_Device_Bind_rsp (End_Device_Bind_req | ZDO_RESPONSE_BIT)
  126. #define Unbind_rsp (Unbind_req | ZDO_RESPONSE_BIT)
  127. #define Mgmt_NWK_Disc_req ((uint16)0x0030)
  128. #define Mgmt_Lqi_req ((uint16)0x0031)
  129. #define Mgmt_Rtg_req ((uint16)0x0032)
  130. #define Mgmt_Bind_req ((uint16)0x0033)
  131. #define Mgmt_Leave_req ((uint16)0x0034)
  132. #define Mgmt_Direct_Join_req ((uint16)0x0035)
  133. #define Mgmt_Permit_Join_req ((uint16)0x0036)
  134. #define Mgmt_NWK_Update_req ((uint16)0x0038)
  135. #define Mgmt_NWK_Disc_rsp (Mgmt_NWK_Disc_req | ZDO_RESPONSE_BIT)
  136. #define Mgmt_Lqi_rsp (Mgmt_Lqi_req | ZDO_RESPONSE_BIT)
  137. #define Mgmt_Rtg_rsp (Mgmt_Rtg_req | ZDO_RESPONSE_BIT)
  138. #define Mgmt_Bind_rsp (Mgmt_Bind_req | ZDO_RESPONSE_BIT)
  139. #define Mgmt_Leave_rsp (Mgmt_Leave_req | ZDO_RESPONSE_BIT)
  140. #define Mgmt_Direct_Join_rsp (Mgmt_Direct_Join_req | ZDO_RESPONSE_BIT)
  141. #define Mgmt_Permit_Join_rsp (Mgmt_Permit_Join_req | ZDO_RESPONSE_BIT)
  142. #define Mgmt_NWK_Update_notify (Mgmt_NWK_Update_req | ZDO_RESPONSE_BIT)
  143. /*********************************************************************
  144. * TYPEDEFS
  145. */
  146. #define ZDP_BINDINGENTRY_SIZE 19
  147. typedef struct
  148. {
  149. osal_event_hdr_t hdr;
  150. zAddrType_t srcAddr;
  151. uint8 wasBroadcast;
  152. cId_t clusterID;
  153. uint8 SecurityUse;
  154. uint8 TransSeq;
  155. uint8 asduLen;
  156. uint16 macDestAddr;
  157. uint8 *asdu;
  158. } zdoIncomingMsg_t;
  159. // This structure is used to build the Mgmt Network Discover Response
  160. typedef struct
  161. {
  162. uint8 extendedPANID[Z_EXTADDR_LEN]; // The extended PAN ID
  163. uint16 PANId; // The network PAN ID
  164. uint8 logicalChannel; // Network's channel
  165. uint8 stackProfile; // Network's profile
  166. uint8 version; // Network's Zigbee version
  167. uint8 beaconOrder; // Beacon Order
  168. uint8 superFrameOrder;
  169. uint8 permitJoining; // PermitJoining. 1 or 0
  170. } mgmtNwkDiscItem_t;
  171. // This structure is used to build the Mgmt LQI Response
  172. typedef struct
  173. {
  174. uint16 nwkAddr; // device's short address
  175. uint16 PANId; // The neighbor device's PAN ID
  176. uint8 extPANId[Z_EXTADDR_LEN]; // The neighbor device's Extended PanID
  177. uint8 txQuality; // Transmit quality
  178. uint8 rxLqi; // Receive LQI
  179. } neighborLqiItem_t;
  180. #define ZDP_NEIGHBORLQI_SIZE 12
  181. // This structure is used to build the Mgmt_Lqi_rsp
  182. typedef struct
  183. {
  184. uint16 panID; // PAN Id
  185. uint8 extPanID[Z_EXTADDR_LEN];// Extended Pan ID
  186. uint8 extAddr[Z_EXTADDR_LEN]; // Extended address
  187. uint16 nwkAddr; // Network address
  188. uint8 devType; // Device type
  189. uint8 rxOnIdle; // RxOnWhenIdle
  190. uint8 relation; // Relationship
  191. uint8 permit; // Permit joining
  192. uint8 depth; // Depth
  193. uint8 lqi; // LQI
  194. } ZDP_MgmtLqiItem_t;
  195. // devType, rxOnIdle, relation, are all packed into 1 byte: 18-2=16.
  196. #define ZDP_MGMTLQI_SIZE 15
  197. #define ZDP_MGMTLQI_EXTENDED_SIZE 22 // One extra byte for permitJointing, also with extended PanID instead of PanID 15+8-2+1 = 22
  198. // This structure is used to build the Mgmt Routing Response
  199. // Notice, if you change this structure, you must also change
  200. // rtgEntry_t in rtg.h
  201. typedef struct
  202. {
  203. uint16 dstAddress; // Destination short address
  204. uint16 nextHopAddress; // next hop short address
  205. uint8 expiryTime; // expiration time - not used for response
  206. uint8 status; // route entry status
  207. } rtgItem_t;
  208. // expiryTime is not packed & sent OTA.
  209. #define ZDP_ROUTINGENTRY_SIZE 5
  210. typedef struct
  211. {
  212. uint8 TransSeq;
  213. byte SecurityUse;
  214. uint16 srcAddr;
  215. uint16 localCoordinator;
  216. uint8 ieeeAddr[Z_EXTADDR_LEN];
  217. uint8 endpoint;
  218. uint16 profileID;
  219. uint8 numInClusters;
  220. uint16 *inClusters;
  221. uint8 numOutClusters;
  222. uint16 *outClusters;
  223. } ZDEndDeviceBind_t;
  224. /*********************************************************************
  225. * GLOBAL VARIABLES
  226. */
  227. extern byte ZDP_TransID;
  228. /*********************************************************************
  229. * MACROS
  230. */
  231. /*
  232. * Generic data send function
  233. */
  234. extern afStatus_t ZDP_SendData( uint8 *transSeq, zAddrType_t *dstAddr, uint16 cmd, byte len,
  235. uint8 *buf, byte SecurityEnable );
  236. /*
  237. * ZDP_NodeDescReq - Request a Node Description
  238. *
  239. * @MT SPI_CMD_ZDO_NODE_DESC_REQ
  240. * (UInt16 DstAddr,
  241. * UInt16 NWKAddrOfInterest,
  242. * byte SecuritySuite)
  243. *
  244. */
  245. #define ZDP_NodeDescReq( dstAddr, NWKAddrOfInterest, SecurityEnable ) \
  246. ZDP_NWKAddrOfInterestReq( dstAddr, \
  247. NWKAddrOfInterest, Node_Desc_req, SecurityEnable )
  248. /*
  249. * ZDP_PowerDescReq - Request a Power Description
  250. *
  251. * @MT SPI_CMD_ZDO_POWER_DESC_REQ
  252. * (UInt16 DstAddr,
  253. * UInt16 NWKAddrOfInterest,
  254. * byte SecuritySuit)
  255. *
  256. */
  257. #define ZDP_PowerDescReq( dstAddr, NWKAddrOfInterest, SecurityEnable ) \
  258. ZDP_NWKAddrOfInterestReq( dstAddr, \
  259. NWKAddrOfInterest, Power_Desc_req, SecurityEnable )
  260. /*
  261. * ZDP_ActiveEPReq - Request a device's endpoint list
  262. *
  263. * @MT SPI_CMD_ZDO_ACTIVE_EPINT_REQ
  264. * (UInt16 DstAddr,
  265. * UInt16 NWKAddrOfInterest,
  266. * byte SecuritySuite)
  267. *
  268. */
  269. #define ZDP_ActiveEPReq( dstAddr, NWKAddrOfInterest, SecurityEnable ) \
  270. ZDP_NWKAddrOfInterestReq( dstAddr, \
  271. NWKAddrOfInterest, Active_EP_req, SecurityEnable )
  272. /*
  273. * ZDP_ComplexDescReq - Request a device's complex description
  274. *
  275. * @MT SPI_CMD_ZDO_COMPLEX_DESC_REQ
  276. * (UInt16 DstAddr,
  277. * UInt16 NWKAddrOfInterest,
  278. * byte SecuritySuite)
  279. *
  280. */
  281. #define ZDP_ComplexDescReq( dstAddr, NWKAddrOfInterest, SecurityEnable ) \
  282. ZDP_NWKAddrOfInterestReq( dstAddr, \
  283. NWKAddrOfInterest, Complex_Desc_req, SecurityEnable )
  284. /*
  285. * ZDP_UserDescReq - Request a device's user description
  286. *
  287. * @MT SPI_CMD_ZDO_USER_DESC_REQ
  288. * (UInt16 DstAddr,
  289. * UInt16 NWKAddrOfInterest,
  290. * byte SecuritySuite)
  291. *
  292. */
  293. #define ZDP_UserDescReq( dstAddr, NWKAddrOfInterest, SecurityEnable ) \
  294. ZDP_NWKAddrOfInterestReq( dstAddr, \
  295. NWKAddrOfInterest, User_Desc_req, SecurityEnable )
  296. /*
  297. * ZDP_BindReq - bind request
  298. *
  299. * @MT SPI_CMD_ZDO_BIND_REQ
  300. * (UInt16 DstAddr,
  301. * UInt64 SrcAddress,
  302. * byte SrcEndpoint,
  303. * uint16 ClusterID,
  304. * zAddrType_t *DstAddress,
  305. * byte DstEndpoint,
  306. * byte SecuritySuite)
  307. *
  308. */
  309. #define ZDP_BindReq( dstAddr, SourceAddr, SrcEP, \
  310. ClusterID, DestinationAddr, DstEP, SecurityEnable ) \
  311. ZDP_BindUnbindReq( Bind_req, dstAddr, \
  312. SourceAddr, SrcEP, ClusterID, \
  313. DestinationAddr, DstEP, SecurityEnable )
  314. /*
  315. * ZDP_UnbindReq - Unbind request
  316. *
  317. * @MT SPI_CMD_ZDO_UNBIND_REQ
  318. * (UInt16 DstAddr,
  319. * UInt64 SrcAddress,
  320. * byte SrcEndpoint,
  321. * uint16 ClusterID,
  322. * zAddrType_t DestinationAddr,
  323. * byte DstEndpoint,
  324. * byte SecuritySuite)
  325. *
  326. */
  327. #define ZDP_UnbindReq( dstAddr, SourceAddr, SrcEP, \
  328. ClusterID, DestinationAddr, DstEP, SecurityEnable ) \
  329. ZDP_BindUnbindReq( Unbind_req, dstAddr, \
  330. SourceAddr, SrcEP, ClusterID, \
  331. DestinationAddr, DstEP, SecurityEnable )
  332. /*
  333. * ZDP_MgmtLqiReq - Send a Management LQI Request
  334. *
  335. * @MT SPI_CMD_ZDO_MGMT_LQI_REQ
  336. * (UInt16 DstAddr,
  337. * byte StartIndex)
  338. *
  339. */
  340. #define ZDP_MgmtLqiReq( dstAddr, StartIndex, SecurityEnable ) \
  341. ZDP_SendData( &ZDP_TransID, dstAddr, Mgmt_Lqi_req, 1, &StartIndex, SecurityEnable )
  342. /*
  343. * ZDP_MgmtRtgReq - Send a Management Routing Table Request
  344. *
  345. * @MT SPI_CMD_ZDO_MGMT_RTG_REQ
  346. * (UInt16 DstAddr,
  347. * byte StartIndex)
  348. *
  349. */
  350. #define ZDP_MgmtRtgReq( dstAddr, StartIndex, SecurityEnable ) \
  351. ZDP_SendData( &ZDP_TransID, dstAddr, Mgmt_Rtg_req, 1, &StartIndex, SecurityEnable )
  352. /*
  353. * ZDP_MgmtBindReq - Send a Management Binding Table Request
  354. *
  355. * @MT SPI_CMD_ZDO_MGMT_BIND_REQ
  356. * (UInt16 DstAddr,
  357. * byte StartIndex)
  358. *
  359. */
  360. #define ZDP_MgmtBindReq( dstAddr, StartIndex, SecurityEnable ) \
  361. ZDP_SendData( &ZDP_TransID, dstAddr, Mgmt_Bind_req, 1, &StartIndex, SecurityEnable )
  362. #ifdef REMOVE_BY_LAF
  363. /*
  364. * ZDP_NWKAddrRsp - Send a Network Address Response
  365. */
  366. #define ZDP_NWKAddrRsp( TransSeq, dstAddr, Status, IEEEAddrRemoteDev, ReqType, nwkAddr, NumAssocDev, \
  367. StartIndex, NWKAddrAssocDevList, SecurityEnable ) \
  368. ZDP_AddrRsp( NWK_addr_rsp, TransSeq, dstAddr, Status, \
  369. IEEEAddrRemoteDev, ReqType, nwkAddr, NumAssocDev, StartIndex, \
  370. NWKAddrAssocDevList, SecurityEnable )
  371. /*
  372. * ZDP_IEEEAddrRsp - Send an IEEE Address Response
  373. */
  374. #define ZDP_IEEEAddrRsp( TransSeq, dstAddr, Status, IEEEAddrRemoteDev, ReqType, nwkAddr, NumAssocDev, \
  375. StartIndex, NWKAddrAssocDevList, SecurityEnable ) \
  376. ZDP_AddrRsp( IEEE_addr_rsp, TransSeq, dstAddr, Status, \
  377. IEEEAddrRemoteDev, ReqType, nwkAddr, NumAssocDev, StartIndex, \
  378. NWKAddrAssocDevList, SecurityEnable )
  379. #endif
  380. /*
  381. * ZDP_ActiveEPRsp - Send an list of active endpoint
  382. */
  383. #define ZDP_ActiveEPRsp( TransSeq, dstAddr, Status, nwkAddr, Count, \
  384. pEPList, SecurityEnable ) \
  385. ZDP_EPRsp( Active_EP_rsp, TransSeq, dstAddr, Status, \
  386. nwkAddr, Count, pEPList, SecurityEnable )
  387. /*
  388. * ZDP_MatchDescRsp - Send an list of endpoint that match
  389. */
  390. #define ZDP_MatchDescRsp( TransSeq, dstAddr, Status, nwkAddr, Count, \
  391. pEPList, SecurityEnable ) \
  392. ZDP_EPRsp( Match_Desc_rsp, TransSeq, dstAddr, Status, \
  393. nwkAddr, Count, pEPList, SecurityEnable )
  394. /*
  395. * ZDP_ComplexDescRsp - This message isn't supported until we fix it.
  396. */
  397. #define ZDP_ComplexDescRsp( dstAddr, SecurityEnable ) \
  398. ZDP_GenericRsp( dstAddr, Complex_Desc_rsp, SecurityEnable )
  399. /*
  400. * ZDP_UserDescConf - Send a User Descriptor Set Response
  401. */
  402. #define ZDP_UserDescConf( TransSeq, dstAddr, Status, SecurityEnable ) \
  403. ZDP_SendData( &TransSeq, dstAddr, User_Desc_conf, 1, &Status, SecurityEnable )
  404. /*
  405. * ZDP_EndDeviceBindRsp - Send a End Device Bind Response
  406. */
  407. #define ZDP_EndDeviceBindRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  408. ZDP_SendData( &TransSeq, dstAddr, End_Device_Bind_rsp, 1, &Status, SecurityEnable )
  409. /*
  410. * ZDP_BindRsp - Send a Bind Response
  411. */
  412. #define ZDP_BindRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  413. ZDP_SendData( &TransSeq, dstAddr, Bind_rsp, 1, &Status, SecurityEnable )
  414. /*
  415. * ZDP_UnbindRsp - Send an Unbind Response
  416. */
  417. #define ZDP_UnbindRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  418. ZDP_SendData( &TransSeq, dstAddr, Unbind_rsp, 1, &Status, SecurityEnable )
  419. /*
  420. * ZDP_MgmtLeaveRsp - Send a Management Leave Response
  421. */
  422. #define ZDP_MgmtLeaveRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  423. ZDP_SendData( &TransSeq, dstAddr, Mgmt_Leave_rsp, 1, &Status, SecurityEnable )
  424. /*
  425. * ZDP_MgmtPermitJoinRsp - Send a Management Permit Join Response
  426. */
  427. #define ZDP_MgmtPermitJoinRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  428. ZDP_SendData( &TransSeq, dstAddr, Mgmt_Permit_Join_rsp, 1, &Status, SecurityEnable )
  429. /*
  430. * ZDP_MgmtDirectJoinRsp - Send a Mgmt_DirectJoining_Rsp Response
  431. */
  432. #define ZDP_MgmtDirectJoinRsp( TransSeq, dstAddr, Status, SecurityEnable ) \
  433. ZDP_SendData( &TransSeq, dstAddr, Mgmt_Direct_Join_rsp, 1, &Status, SecurityEnable )
  434. /*********************************************************************
  435. * FUNCTIONS - API
  436. */
  437. /*
  438. * ZDP_NWKAddrOfInterestReq - Send request with NWKAddrOfInterest as parameter
  439. */
  440. extern afStatus_t ZDP_NWKAddrOfInterestReq( zAddrType_t *dstAddr,
  441. uint16 nwkAddr, byte cmd, byte SecurityEnable );
  442. /*
  443. * ZDP_NwkAddrReq - Request a Network address
  444. *
  445. * @MT SPI_CMD_ZDO_NWK_ADDR_REQ
  446. * (UInt64 IEEEAddress,
  447. * byte ReqType,
  448. * byte StarIndex,
  449. * byte SecurityEnable)
  450. *
  451. */
  452. extern afStatus_t ZDP_NwkAddrReq( uint8 *IEEEAddress, byte ReqType,
  453. byte StartIndex, byte SecurityEnable );
  454. /*
  455. * ZDP_IEEEAddrReq - Request an IEEE address
  456. *
  457. * @MT SPI_CMD_ZDO_IEEE_ADDR_REQ
  458. * (UInt16 shortAddr,
  459. * byte ReqType,
  460. * byte StartIndex,
  461. * byte SecurityEnable)
  462. *
  463. */
  464. extern afStatus_t ZDP_IEEEAddrReq( uint16 shortAddr, byte ReqType,
  465. byte StartIndex, byte SecurityEnable );
  466. /*
  467. * ZDP_MatchDescReq - Request matching device's endpoint list
  468. *
  469. * @MT SPI_CMD_ZDO_MATCH_DESC_REQ
  470. * (UInt16 DstAddr,
  471. * UInt16 NWKAddrOfInterest,
  472. * UInt16 ProfileID,
  473. * byte NumInClusters,
  474. * uint16 InClusterList[15],
  475. * byte NumOutClusters,
  476. * uint16 OutClusterList[15],
  477. * byte SecuritySuite)
  478. *
  479. */
  480. extern afStatus_t ZDP_MatchDescReq( zAddrType_t *dstAddr, uint16 nwkAddr,
  481. uint16 ProfileID,
  482. byte NumInClusters, uint16 *InClusterList,
  483. byte NumOutClusters, uint16 *OutClusterList,
  484. byte SecurityEnable );
  485. /*
  486. * ZDP_SimpleDescReq - Request Simple Descriptor
  487. *
  488. * @MT SPI_CMD_ZDO_SIMPLE_DESC_REQ
  489. * (UInt16 DstAddr,
  490. * UInt16 NWKAddrOfInterest,
  491. * byte Endpoint,
  492. * byte Security)
  493. *
  494. */
  495. extern afStatus_t ZDP_SimpleDescReq( zAddrType_t *dstAddr, uint16 nwkAddr,
  496. byte ep, byte SecurityEnable );
  497. /*
  498. * ZDP_UserDescSet - Set the User Descriptor
  499. *
  500. * @MT SPI_CMD_ZDO_USER_DESC_SET
  501. * (UInt16 DstAddr,
  502. * UInt16 NWKAddrOfInterest,
  503. * byte DescLen,
  504. * byte Descriptor[15],
  505. * byte SecuritySuite)
  506. *
  507. */
  508. extern afStatus_t ZDP_UserDescSet( zAddrType_t *dstAddr, uint16 nwkAddr,
  509. UserDescriptorFormat_t *UserDescriptor,
  510. byte SecurityEnable );
  511. /*
  512. * ZDP_ServerDiscReq - Build and send a Server_Discovery_req request message.
  513. */
  514. afStatus_t ZDP_ServerDiscReq( uint16 serverMask, byte SecurityEnable );
  515. /*
  516. * ZDP_DeviceAnnce - Device Announce
  517. *
  518. * @MT SPI_CMD_ZDO_DEV_ANNCE
  519. * (UInt16 DevAddr,
  520. * byte DeviceAddress,
  521. * byte SecuritySuite)
  522. *
  523. */
  524. extern afStatus_t ZDP_DeviceAnnce( uint16 nwkAddr, uint8 *IEEEAddr,
  525. byte capabilities, byte SecurityEnable );
  526. /*
  527. * ZDP_EndDeviceBindReq - End Device (hand) bind request
  528. *
  529. * @MT SPI_CMD_ZDO_END_DEV_BIND_REQ
  530. * (UInt16 DstAddr,
  531. * UInt16 LocalCoordinator,
  532. * byte Endpoint,
  533. * UInt16 Profile,
  534. * byte NumInClusters,
  535. * uint16 InClusterList[15],
  536. * byte NumOutClusters,
  537. * uint16 OutClusterList[15],
  538. * byte SecuritySuite)
  539. *
  540. */
  541. extern afStatus_t ZDP_EndDeviceBindReq( zAddrType_t *dstAddr,
  542. uint16 LocalCoordinator,
  543. byte ep,
  544. uint16 ProfileID,
  545. byte NumInClusters, uint16 *InClusterList,
  546. byte NumOutClusters, uint16 *OutClusterList,
  547. byte SecurityEnable );
  548. /*
  549. * ZDP_BindUnbindReq - bind request
  550. */
  551. extern afStatus_t ZDP_BindUnbindReq( uint16 BindOrUnbind, zAddrType_t *dstAddr,
  552. uint8 *SourceAddr, byte SrcEP,
  553. cId_t ClusterID,
  554. zAddrType_t *DestinationAddr, byte DstEP,
  555. byte SecurityEnable );
  556. /*
  557. * ZDP_MgmtNwkDiscReq - Send a Management Network Discovery Request
  558. *
  559. * @MT SPI_CMD_ZDO_MGMT_NWKDISC_REQ
  560. * (UInt16 DstAddr,
  561. * UInt32 ScanChannels,
  562. * byte StartIndex)
  563. *
  564. */
  565. extern afStatus_t ZDP_MgmtNwkDiscReq( zAddrType_t *dstAddr,
  566. uint32 ScanChannels,
  567. byte ScanDuration,
  568. byte StartIndex,
  569. byte SecurityEnable );
  570. /*
  571. * ZDP_MgmtDirectJoinReq - Send a Management Direct Join Request
  572. *
  573. * @MT SPI_CMD_ZDO_MGMT_DIRECT_JOIN_REQ
  574. * (UInt16 DstAddr,
  575. * UInt64 DeviceAddress,
  576. * byte CapInfo)
  577. *
  578. */
  579. extern afStatus_t ZDP_MgmtDirectJoinReq( zAddrType_t *dstAddr,
  580. uint8 *deviceAddr,
  581. byte capInfo,
  582. byte SecurityEnable );
  583. /*
  584. * ZDP_MgmtLeaveReq - Send a Management Leave Request
  585. *
  586. * @MT SPI_CMD_ZDO_MGMT_LEAVE_REQ
  587. * (UInt16 DstAddr,
  588. * UInt64 DeviceAddress
  589. * uint8 RemoveChildren
  590. * uint8 Rejoin
  591. * uint8 SecurityEnable)
  592. */
  593. extern afStatus_t ZDP_MgmtLeaveReq( zAddrType_t *dstAddr,
  594. uint8 *IEEEAddr,
  595. uint8 RemoveChildren,
  596. uint8 Rejoin,
  597. uint8 SecurityEnable );
  598. /*
  599. * ZDP_MgmtPermitJoinReq - Send a Management Permit Join Request
  600. *
  601. * @MT SPI_CMD_ZDO_MGMT_PERMIT_JOIN_REQ
  602. * (UInt16 DstAddr,
  603. * byte duration,
  604. * byte TcSignificance)
  605. *
  606. */
  607. extern afStatus_t ZDP_MgmtPermitJoinReq( zAddrType_t *dstAddr,
  608. byte duration,
  609. byte TcSignificance,
  610. byte SecurityEnable );
  611. /*
  612. * ZDP_MgmtNwkUpdateReq - Send a Management NWK Update Request
  613. *
  614. * @MT SPI_CMD_ZDO_MGMT_NWK_UPDATE_REQ
  615. * (uint16 dstAddr,
  616. * uint32 ChannelMask,
  617. * uint8 ScanDuration,
  618. * uint8 ScanCount,
  619. * uint16 NwkManagerAddr )
  620. *
  621. */
  622. extern afStatus_t ZDP_MgmtNwkUpdateReq( zAddrType_t *dstAddr,
  623. uint32 ChannelMask,
  624. uint8 ScanDuration,
  625. uint8 ScanCount,
  626. uint8 NwkUpdateId,
  627. uint16 NwkManagerAddr );
  628. /*********************************************************************
  629. * @fn ZDP_AddrRsp
  630. *
  631. * @brief Build and send a NWK_addr_rsp or IEEE_addr_rsp message.
  632. *
  633. * @param cId - ClusterID of the rsp, either NWK_addr_rsp or IEEE_addr_rsp.
  634. * @param seq - Message sequence number of the corresponding request.
  635. * @param dst - Destination address for the response.
  636. * @param stat - Response status: ZDP_SUCCESS or other value from ZDProfile.h
  637. * @param ieee - 64-bit IEEE address of the response.
  638. * @param reqType - Type of response requested (single, extended, etc.)
  639. * @param nwkAddr - 16-bit network address of the response.
  640. * @param devCnt - Number of associated devices in the device address list.
  641. * @param strtIdx - Starting index into the dev addr array if extended rsp.
  642. * @param devAddr - Array of 16-bit network addresses of the associated devs.
  643. * @param secOpt - Security Enable Options.
  644. *
  645. * @return afStatus_t
  646. */
  647. afStatus_t ZDP_AddrRsp( byte cId, byte seq, zAddrType_t *dst, byte stat,
  648. uint8 *ieee, byte reqType, uint16 nwkAddr, byte devCnt, byte strtIdx,
  649. uint16 *devAddr, byte secOpt );
  650. /*
  651. * ZDP_NodeDescMsg - Send a Node Descriptor message.
  652. */
  653. extern afStatus_t ZDP_NodeDescMsg( zdoIncomingMsg_t *inMsg,
  654. uint16 nwkAddr, NodeDescriptorFormat_t *pNodeDesc );
  655. /*
  656. * ZDP_PowerDescMsg - Send a Node Power Descriptor message.
  657. */
  658. extern afStatus_t ZDP_PowerDescMsg( zdoIncomingMsg_t *inMsg,
  659. uint16 nwkAddr, NodePowerDescriptorFormat_t *pPowerDesc );
  660. /*
  661. * ZDP_SimpleDescMsg - Send a Simple Descriptor message.
  662. */
  663. extern afStatus_t ZDP_SimpleDescMsg( zdoIncomingMsg_t *inMsg,
  664. byte Status, SimpleDescriptionFormat_t *pSimpleDesc );
  665. /*
  666. * ZDP_EPRsp - Send a list of endpoint
  667. */
  668. extern afStatus_t ZDP_EPRsp( uint16 MsgType, byte TransSeq, zAddrType_t *dstAddr, byte Status,
  669. uint16 nwkAddr, byte Count, uint8 *pEPList,
  670. byte SecurityEnable );
  671. /*
  672. * ZDP_GenericRsp - Sends a response message with only the parameter response
  673. * byte and the addr of interest for data.
  674. */
  675. extern afStatus_t ZDP_GenericRsp( byte TransSeq, zAddrType_t *dstAddr,
  676. byte status, uint16 aoi, uint16 rspID, byte SecurityEnable );
  677. /*
  678. * ZDP_MgmtNwkDiscRsp - Sends the Management Network Discovery Response.
  679. */
  680. extern afStatus_t ZDP_MgmtNwkDiscRsp( byte TransSeq, zAddrType_t *dstAddr,
  681. byte Status,
  682. byte NetworkCount,
  683. byte StartIndex,
  684. byte NetworkCountList,
  685. networkDesc_t *NetworkList,
  686. byte SecurityEnable );
  687. /*
  688. * ZDP_MgmtLqiRsp - Sends the Management LQI Response.
  689. */
  690. extern ZStatus_t ZDP_MgmtLqiRsp( byte TransSeq, zAddrType_t *dstAddr,
  691. byte Status,
  692. byte NeighborLqiEntries,
  693. byte StartIndex,
  694. byte NeighborLqiCount,
  695. ZDP_MgmtLqiItem_t* NeighborList,
  696. byte SecurityEnable );
  697. /*
  698. * ZDP_MgmtRtgRsp - Sends the Management Routing Response.
  699. */
  700. extern ZStatus_t ZDP_MgmtRtgRsp( byte TransSeq, zAddrType_t *dstAddr,
  701. byte Status,
  702. byte RoutingTableEntries,
  703. byte StartIndex,
  704. byte RoutingListCount,
  705. rtgItem_t *RoutingTableList,
  706. byte SecurityEnable );
  707. /*
  708. * ZDP_MgmtBindRsp - Sends the Management Binding Response.
  709. */
  710. extern ZStatus_t ZDP_MgmtBindRsp( byte TransSeq, zAddrType_t *dstAddr,
  711. byte Status,
  712. byte BindingTableEntries,
  713. byte StartIndex,
  714. byte BindingTableListCount,
  715. apsBindingItem_t *BindingTableList,
  716. byte SecurityEnable );
  717. /*
  718. * ZDP_MgmtNwkUpdateNotify - Sends the Management Netwotk Update Notify.
  719. */
  720. extern afStatus_t ZDP_MgmtNwkUpdateNotify( uint8 TransSeq, zAddrType_t *dstAddr,
  721. uint8 status, uint32 scannedChannels,
  722. uint16 totalTransmissions, uint16 transmissionFailures,
  723. uint8 listCount, uint8 *energyValues, uint8 txOptions,
  724. uint8 securityEnable );
  725. /*
  726. * ZDP_UserDescRsp - Sends the user descriptor response message.
  727. */
  728. extern ZStatus_t ZDP_UserDescRsp( byte TransSeq, zAddrType_t *dstAddr,
  729. uint16 nwkAddrOfInterest, UserDescriptorFormat_t *userDesc,
  730. byte SecurityEnable );
  731. /*
  732. * ZDP_ServerDiscRsp - Build and send the User Decriptor Response.
  733. */
  734. ZStatus_t ZDP_ServerDiscRsp( byte transID, zAddrType_t *dstAddr, byte status,
  735. uint16 aoi, uint16 serverMask, byte SecurityEnable );
  736. /*
  737. * ZDP_IncomingData - Incoming data callback from AF layer
  738. */
  739. extern void ZDP_IncomingData( afIncomingMSGPacket_t *pData );
  740. extern ZStatus_t ZDO_RegisterForZDOMsg( uint8 taskID, uint16 clusterID );
  741. extern ZStatus_t ZDO_RemoveRegisteredCB( uint8 taskID, uint16 clusterID );
  742. /*********************************************************************
  743. *********************************************************************/
  744. #ifdef __cplusplus
  745. }
  746. #endif
  747. #endif /* ZDPROFILE_H */