ZDNwkMgr.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /**************************************************************************************************
  2. Filename: ZDNwkMgr.h
  3. Revised: $Date: 2007-07-18 10:02:49 -0700 (Wed, 18 Jul 2007) $
  4. Revision: $Revision: 14945 $
  5. Description: This file contains the interface to the ZigBee Network Manager.
  6. Copyright 2007-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 ZDNWKMGR_H
  34. #define ZDNWKMGR_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /******************************************************************************
  40. * INCLUDES
  41. */
  42. #include "ZComDef.h"
  43. #include "nwk_globals.h"
  44. #include "nwk_util.h"
  45. #include "ZDApp.h"
  46. /******************************************************************************
  47. * CONSTANTS
  48. */
  49. // Network Manager Role
  50. #define ZDNWKMGR_DISABLE 0x00
  51. #define ZDNWKMGR_ENABLE 0x01
  52. // Energy level threshold
  53. #define ZDNWKMGR_ACCEPTABLE_ENERGY_LEVEL 0x1E
  54. // Minimum transmissions attempted for Channel Interference detection
  55. #if !defined ( ZDNWKMGR_MIN_TRANSMISSIONS )
  56. #define ZDNWKMGR_MIN_TRANSMISSIONS 20
  57. #endif
  58. // Minimum transmit failure rate for Channel Interference detection
  59. #define ZDNWKMGR_CI_TX_FAILURE 25
  60. // Minimum transmit failure rate for Channel Change
  61. #define ZDNWKMGR_CC_TX_FAILURE 50
  62. // Min and Max Scan Counts for Update Request
  63. #define ZDNWKMGR_MIN_SCAN_COUNT 0
  64. #define ZDNWKMGR_MAX_SCAN_COUNT 5
  65. // Update Request and Notify timers
  66. #define ZDNWKMGR_UPDATE_NOTIFY_TIMER 60 // 1(h) * 60(m)
  67. #define ZDNWKMGR_UPDATE_REQUEST_TIMER 60 // 1(h) * 60(m)
  68. // Network Manager Events
  69. #define ZDNWKMGR_CHANNEL_CHANGE_EVT 0x0001
  70. #define ZDNWKMGR_UPDATE_NOTIFY_EVT 0x0002
  71. #define ZDNWKMGR_UPDATE_REQUEST_EVT 0x0004
  72. #define ZDNWKMGR_SCAN_REQUEST_EVT 0x0008
  73. #define ZDNWKMGR_BCAST_DELIVERY_TIME ( _NIB.BroadcastDeliveryTime * 100 )
  74. /*********************************************************************
  75. * TYPEDEFS
  76. */
  77. // Used for Management Network Update Request message
  78. typedef struct
  79. {
  80. osal_event_hdr_t hdr;
  81. uint8 transSeq;
  82. uint16 srcAddr;
  83. uint32 channelMask;
  84. uint8 scanDuration;
  85. uint8 scanCount;
  86. int16 nwkManagerAddr;
  87. uint8 wasBroadcast;
  88. } ZDNwkMgr_MgmtNwkUpdateRequest_t;
  89. // Used for Management Network Update Notify command
  90. typedef struct
  91. {
  92. osal_event_hdr_t hdr;
  93. uint16 srcAddr;
  94. uint8 status;
  95. uint32 scannedChannels;
  96. uint16 totalTransmissions;
  97. uint16 txFailures;
  98. uint8 listCount;
  99. uint8 *energyValues;
  100. } ZDNwkMgr_MgmtNwkUpdateNotify_t;
  101. // Used for Channel Interference message
  102. typedef struct
  103. {
  104. osal_event_hdr_t hdr;
  105. uint16 totalTransmissions;
  106. uint16 txFailures;
  107. } ZDNwkMgr_ChanInterference_t;
  108. // Used for ED Scan Confirm message
  109. typedef struct
  110. {
  111. osal_event_hdr_t hdr;
  112. uint8 status;
  113. uint32 scannedChannels;
  114. uint8 energyDetectList[ED_SCAN_MAXCHANNELS];
  115. } ZDNwkMgr_EDScanConfirm_t;
  116. // Used for Network Report command
  117. typedef struct
  118. {
  119. osal_event_hdr_t hdr;
  120. uint16 srcAddr;
  121. uint8 reportType;
  122. uint8 EPID[Z_EXTADDR_LEN];
  123. uint8 reportInfoCnt;
  124. uint16 panIDs[];
  125. } ZDNwkMgr_NetworkReport_t;
  126. // Used for Network Update command
  127. typedef struct
  128. {
  129. osal_event_hdr_t hdr;
  130. uint8 updateType;
  131. uint8 updateInfoCnt;
  132. uint16 newPanID;
  133. } ZDNwkMgr_NetworkUpdate_t;
  134. /*********************************************************************
  135. * GLOBAL VARIABLES
  136. */
  137. extern byte ZDNwkMgr_TaskID;
  138. /******************************************************************************
  139. * PUBLIC FUNCTIONS
  140. */
  141. /*********************************************************************
  142. * Task Level Control
  143. */
  144. /*
  145. * ZDNwkMgr Task Initialization Function
  146. */
  147. extern void ZDNwkMgr_Init( byte task_id );
  148. /*
  149. * ZDNwkMgr Task Event Processing Function
  150. */
  151. extern UINT16 ZDNwkMgr_event_loop( byte task_id, UINT16 events );
  152. /*********************************************************************
  153. * Application Level Functions
  154. */
  155. // Frequency Agility functions
  156. extern void (*pZDNwkMgr_EDScanConfirmCB)( NLME_EDScanConfirm_t *EDScanConfirm );
  157. extern void (*pZDNwkMgr_ProcessDataConfirm)( afDataConfirm_t *afDataConfirm );
  158. extern void (*pZDNwkMgr_ReportChannelInterference)( NLME_ChanInterference_t *chanInterference );
  159. // PAN ID Conflict functions
  160. extern void (*pZDNwkMgr_NetworkReportCB)( ZDNwkMgr_NetworkReport_t *pReport );
  161. extern void (*pZDNwkMgr_NetworkUpdateCB)( ZDNwkMgr_NetworkUpdate_t *pUpdate );
  162. #if defined ( NWK_MANAGER )
  163. /*
  164. * ZDNwkMgr set the local device as the Network Manager
  165. */
  166. extern void NwkMgr_SetNwkManager( void );
  167. #endif
  168. /******************************************************************************
  169. ******************************************************************************/
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif /* ZDNWKMGR_H */