AssocList.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /**************************************************************************************************
  2. Filename: AssocList.h
  3. Revised: $Date: 2012-02-14 13:39:10 -0800 (Tue, 14 Feb 2012) $
  4. Revision: $Revision: 29286 $
  5. Description: Associated Device List.
  6. Copyright 2004-2012 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 ASSOCLIST_H
  34. #define ASSOCLIST_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "ZComDef.h"
  42. /*********************************************************************
  43. * MACROS
  44. */
  45. /*********************************************************************
  46. * CONSTANTS
  47. */
  48. #define NVINDEX_NOT_FOUND 0xFFFF
  49. #define NVINDEX_THIS_DEVICE 0xFFFE
  50. #define ASSOC_INDEX_NOT_FOUND 0xFFFF
  51. // Bitmap of associated devices status fields
  52. #define DEV_LINK_STATUS 0x01 // link is in-active ?
  53. #define DEV_LINK_REPAIR 0x02 // link repair in progress ?
  54. #define DEV_SEC_INIT_STATUS 0x04 // security init
  55. #define DEV_SEC_AUTH_STATUS 0x08 // security authenticated
  56. #define DEV_SECURED_JOIN 0x20 // Device joined secure
  57. #define DEV_REJOIN_STATUS 0x40 // Device rejoined
  58. #define DEV_HIGH_SEC_STATUS 0x80 // Device joined as High Security
  59. // Node Relations
  60. #define PARENT 0
  61. #define CHILD_RFD 1
  62. #define CHILD_RFD_RX_IDLE 2
  63. #define CHILD_FFD 3
  64. #define CHILD_FFD_RX_IDLE 4
  65. #define NEIGHBOR 5
  66. #define OTHER 6
  67. #define NOTUSED 0xFF
  68. /*********************************************************************
  69. * TYPEDEFS
  70. */
  71. typedef struct
  72. {
  73. UINT16 shortAddr; // Short address of associated device
  74. uint16 addrIdx; // Index from the address manager
  75. byte nodeRelation;
  76. byte devStatus; // bitmap of various status values
  77. byte assocCnt;
  78. byte age;
  79. linkInfo_t linkInfo;
  80. } associated_devices_t;
  81. typedef struct
  82. {
  83. uint16 numRecs;
  84. } nvDeviceListHdr_t;
  85. /*********************************************************************
  86. * GLOBAL VARIABLES
  87. */
  88. //extern byte _numAssocDev;
  89. extern associated_devices_t AssociatedDevList[];
  90. /*********************************************************************
  91. * FUNCTIONS
  92. */
  93. /*
  94. * Variable initialization
  95. */
  96. extern void AssocInit( void );
  97. /*
  98. * Create a new or update a previous association.
  99. */
  100. extern associated_devices_t *AssocAddNew( uint16 shortAddr, byte *extAddr,
  101. byte nodeRelation );
  102. /*
  103. * Count number of devices.
  104. */
  105. extern uint16 AssocCount( byte startRelation, byte endRelation );
  106. /*
  107. * Check if the device is a child.
  108. */
  109. extern byte AssocIsChild( uint16 shortAddr );
  110. /*
  111. * Check if the device is a reduced funtion child
  112. */
  113. byte AssocIsRFChild( uint16 shortAddr );
  114. /*
  115. * Check if the device is my parent.
  116. */
  117. extern byte AssocIsParent( uint16 shortAddr );
  118. /*
  119. * Search the Device list using shortAddr.
  120. */
  121. extern associated_devices_t *AssocGetWithShort( uint16 shortAddr );
  122. /*
  123. * Search the Device list using extended Address.
  124. */
  125. extern associated_devices_t *AssocGetWithExt( byte *extAddr );
  126. /*
  127. * Remove a device from the list. Uses the extended address.
  128. */
  129. extern byte AssocRemove( byte *extAddr );
  130. /*
  131. * Returns the next inactive child node
  132. */
  133. extern uint16 AssocGetNextInactiveNode( uint16 shortAddr );
  134. /*
  135. * Returns the next child node
  136. */
  137. extern uint16 AssocGetNextChildNode( uint16 shortAddr );
  138. /*
  139. * Remove all devices from the list and reset it
  140. */
  141. extern void AssocReset( void );
  142. /*
  143. * AssocMakeList - Make a list of associate devices
  144. * NOTE: this function returns a dynamically allocated buffer
  145. * that MUST be deallocated (osal_mem_free).
  146. */
  147. extern uint16 *AssocMakeList( byte *pCount );
  148. /*
  149. * Gets next device that matches the status parameter
  150. */
  151. extern associated_devices_t *AssocMatchDeviceStatus( uint8 status );
  152. /*
  153. * Initialize the Assoc Device List NV Item
  154. */
  155. extern byte AssocInitNV( void );
  156. /*
  157. * Set Assoc Device list NV Item to defaults
  158. */
  159. extern void AssocSetDefaultNV( void );
  160. /*
  161. * Restore the device list (assoc list) from NV
  162. */
  163. extern uint8 AssocRestoreFromNV( void );
  164. /*
  165. * Save the device list (assoc list) to NV
  166. */
  167. extern void AssocWriteNV( void );
  168. /*
  169. * Find Nth active device in list
  170. */
  171. extern associated_devices_t *AssocFindDevice( byte number );
  172. extern uint8 AssocChangeNwkAddr( uint16 nwkAddr, uint8 *ieeeAddr );
  173. extern void AssocCheckDupNeighbors( void );
  174. /*********************************************************************
  175. *********************************************************************/
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* ASSOCLIST_H */