reflecttrack.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /**************************************************************************************************
  2. Filename: reflecttrack.h
  3. Revised: $Date: 2009-03-12 16:25:22 -0700 (Thu, 12 Mar 2009) $
  4. Revision: $Revision: 19404 $
  5. Description: APS Reflect Tracking Database Module
  6. Copyright 2005-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 REFLECTTRACK_H
  34. #define REFLECTTRACK_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "ZComdef.h"
  42. #include "osal.h"
  43. /*********************************************************************
  44. * MACROS
  45. */
  46. /*********************************************************************
  47. * CONSTANTS
  48. */
  49. // This is the default number of max entries. If you would like to
  50. // change this value, DON'T change this constant - call
  51. // reflectTracking_SetMaxEntries() instead.
  52. #define REFTRACK_MAX_ENTRIES 5
  53. // This is the maximum number of simultaneous messages sent for a reflection.
  54. // For example if a message is to be reflected to 10 devices, this constant
  55. // restricts the number of messages that are currently being sent, the others
  56. // wait for the simultaneous messages to complete. If you would like to
  57. // change this value, DON'T change this constant - call
  58. // reflectTracking_SetMaxSimultaneous() instead.
  59. #define REFTRACK_MAX_SIMUL 3
  60. // This is the maximum number of indirect messages of REFTRACK_MAX_SIMUL.
  61. // If you would like to change this value, DON'T change this constant - call
  62. // reflectTracking_SetMaxIndirect() instead. The parameter can't be
  63. // larger than REFTRACK_MAX_SIMUL
  64. #define REFTRACK_MAX_INDIRECTS 1
  65. // ReflectDestRec_t options
  66. #define REFDEST_WAITING 0x00
  67. #define REFDEST_SENT 0x01
  68. #define REFDEST_APS_ACK_EXPECTED 0x02
  69. #define REFDEST_DELIVERED 0x04
  70. #define REFDEST_FAILED 0x08
  71. #define REFDEST_INDIRECT 0x80
  72. /*********************************************************************
  73. * TYPEDEFS
  74. */
  75. typedef struct
  76. {
  77. uint8 dstAddrMode; // 0 - normal short addr, 1 - group Address
  78. uint16 dstAddr; // depends on dstAddrMode
  79. uint8 dstEP;
  80. uint8 handle;
  81. uint8 options;
  82. } ReflectDestRec_t;
  83. typedef struct
  84. {
  85. void *next; // Next in the link List
  86. uint8 ID; // Unique ID
  87. uint8 srcEP;
  88. uint16 clusterID;
  89. uint8 confirmed;
  90. uint16 transID;
  91. uint8* asdu; // saved asdu
  92. uint8 numdests; // number of the destination reflections
  93. ReflectDestRec_t dests[]; // Arrary of destinations
  94. // - the number of destinations must
  95. // be used to allocate this element
  96. } ReflectTracking_t;
  97. /*********************************************************************
  98. * GLOBAL VARIABLES
  99. */
  100. /*********************************************************************
  101. * FUNCTIONS
  102. */
  103. /*
  104. * Set the Maximum number of tracking entries. This is also the
  105. * number of simultaneous reflections that can occur. Also, if you
  106. * would like to keep a history, make this value more than you need.
  107. */
  108. extern void reflectTrack_SetMaxEntries( uint8 newEntries );
  109. /*
  110. * Set a new maximum for the maximum number of simultaneous
  111. * messages sent for a reflection. For example if a message
  112. * is to be reflected to 10 devices, this constant restricts
  113. * the number of messages that are currently being sent, the
  114. * others wait for the simultaneous messages to complete.
  115. */
  116. extern void reflectTracking_SetMaxSimultaneous( uint8 newEntries );
  117. /*
  118. * Get the number of simultaneous bufs.
  119. */
  120. extern uint8 reflectTracking_GetMaxSimultaneous( void );
  121. /*
  122. * Get the number of simultaneous bufs adjusted for the
  123. * number of bufs already sent.
  124. */
  125. extern uint8 reflectTracking_GetMaxSimultaneousAdjusted( ReflectTracking_t *entry );
  126. /*
  127. * Set a new maximum for the maximum number of indirect
  128. * messages of REFTRACK_MAX_SIMUL.
  129. */
  130. extern void reflectTracking_SetMaxIndirect( uint8 newEntries );
  131. /*
  132. * Get a new maximum for the maximum number of indirect
  133. * messages.
  134. */
  135. extern uint8 reflectTracking_GetMaxIndirect( void );
  136. /*
  137. * Get a new maximum for the maximum number of indirect
  138. * messages adjusted for the number being sent.
  139. */
  140. extern uint8 reflectTracking_GetMaxIndirectAdjusted( ReflectTracking_t *entry );
  141. /*
  142. * Gets a memory block for a reflect tracking entry. This doesn't add
  143. * to the list. It just gets the memory, you must fill in and add to
  144. * the list by calling
  145. */
  146. extern ReflectTracking_t *reflectTrack_GetNewEntry( uint8 numDests,
  147. uint8 asduLen );
  148. /*
  149. * Get the number of entries currently in the list.
  150. */
  151. extern uint8 reflectTrack_NumEntries( void );
  152. /*
  153. * Remove an entry from the list and release its memory.
  154. */
  155. extern void reflectTrack_RemoveEntry( ReflectTracking_t *entry );
  156. /*
  157. * Stub for notifying user of entry deletion
  158. */
  159. extern void reflectTrack_RemoveEntryNotify( ReflectTracking_t *entry);
  160. /*
  161. * Add this entry to the end of the list.
  162. */
  163. extern void reflectTrack_AddToEnd( ReflectTracking_t *entry );
  164. /*
  165. * Add entry to the list. It will add to the end of the list.
  166. * if the list is full, the first entry will be deleted.
  167. * returns the unique reflect ID
  168. */
  169. extern uint8 reflectTrack_AddNewEntry( ReflectTracking_t *newEntry );
  170. /*
  171. * Find entry in list based on the reflectID returned
  172. * from the call to reflectTrack_AddNewEntry().
  173. */
  174. extern ReflectTracking_t *reflectTrack_FindEntry( byte refID );
  175. /*
  176. * Find entry in list based on the handle returned
  177. * from the call to reflectTrack_AddNewEntry().
  178. */
  179. extern ReflectTracking_t *reflectTrack_FindHandle( byte handle );
  180. /*
  181. * Update (OR in) options for the passed in parameters.
  182. */
  183. extern void reflectTrack_UpdateOption( ReflectTracking_t *ref, byte handle, byte option );
  184. /*
  185. * Find entry in list based on the source address, endpoint,
  186. * and clusterID.
  187. */
  188. extern ReflectTracking_t *reflectTrack_FindEntryStatus( uint8 endpoint, uint16 clusterID );
  189. /*
  190. * Returns the number of reflections completed.
  191. */
  192. extern uint8 reflectTracking_GetNumDelivered( ReflectTracking_t *entry );
  193. /*
  194. * Returns the number of reflections failed.
  195. */
  196. extern uint8 reflectTracking_GetNumFailed( ReflectTracking_t *entry );
  197. /*
  198. * Fills in an array of failed short addresses.
  199. */
  200. extern void reflectTracking_FillInFailed( ReflectTracking_t *entry, uint16 *list );
  201. /*********************************************************************
  202. *********************************************************************/
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif /* REFLECTTRACK_H */