APS.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**************************************************************************************************
  2. Filename: APS.h
  3. Revised: $Date: 2009-03-19 13:41:00 -0700 (Thu, 19 Mar 2009) $
  4. Revision: $Revision: 19470 $
  5. Description: Primitives of the Application Support Sub Layer Task functions.
  6. Copyright 2004-2009 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 APS_H
  34. #define APS_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /*********************************************************************
  39. * INCLUDES
  40. */
  41. #include "APSMEDE.h"
  42. #include "BindingTable.h"
  43. #include "reflecttrack.h"
  44. /*********************************************************************
  45. * MACROS
  46. */
  47. /*********************************************************************
  48. * TYPEDEFS
  49. */
  50. typedef struct
  51. {
  52. uint16 nwkSrcAddr;
  53. uint8 nwkSecure;
  54. aps_FrameFormat_t* aff;
  55. } APS_CmdInd_t;
  56. typedef struct
  57. {
  58. osal_event_hdr_t hdr;
  59. zAddrType_t SrcAddress;
  60. uint16 SrcPanId;
  61. uint16 macDestAddr;
  62. NLDE_Signal_t sig;
  63. byte SecurityUse;
  64. uint32 timestamp;
  65. aps_FrameFormat_t aff;
  66. } apsInMsg_t;
  67. typedef void (*pfnBindingTimeoutCB)( void );
  68. typedef struct
  69. {
  70. uint16 srcAddr;
  71. uint8 broadcastId;
  72. uint16 expiryTime;
  73. } apsEndDeviceBroadcast_t;
  74. /*********************************************************************
  75. * CONSTANTS
  76. */
  77. // APS Command IDs - sent messages
  78. #define APS_INCOMING_MSG 0x01
  79. #define APS_CMD_PKT 0x02
  80. // APS Message Fields
  81. #define APS_MSG_ID 0x00
  82. #define APS_MSG_ID_LEN 0x01
  83. // APS Command Messages
  84. #define APS_CMD_PKT_HDR ((uint8) \
  85. (sizeof(APSME_CmdPkt_t) + \
  86. APS_MSG_ID_LEN ))
  87. // APS Events
  88. #define APS_EDBIND_TIMEOUT_TIMER_ID 0x0001
  89. #define APS_DATA_REQUEST_HOLD 0x0002
  90. #define APS_SKA_SLOT_TIMER 0x0004
  91. #define APS_ENDDEVICE_BROADCAST_EVT 0x0008
  92. // APS SKA Timer Fields
  93. #define APS_SKA_SLOT_TIMEOUT 100
  94. // APS Relector Types
  95. #define APS_REFLECTOR_PUBLIC 0
  96. #define APS_REFLECTOR_PRIVATE 1
  97. /*********************************************************************
  98. * GLOBAL VARIABLES
  99. */
  100. extern uint8 APS_Counter;
  101. extern byte APS_TaskID;
  102. extern uint16 AIB_MaxBindingTime;
  103. extern uint8 AIB_apsUseExtendedPANID[Z_EXTADDR_LEN];
  104. extern uint8 AIB_apsUseInsecureJoin;
  105. extern uint8 APS_AllowDataRequests;
  106. #if ( ZG_BUILD_ENDDEVICE_TYPE ) && ( RFD_RCVC_ALWAYS_ON==TRUE )
  107. extern apsEndDeviceBroadcast_t apsEndDeviceBroadcastTable[];
  108. #endif
  109. /*********************************************************************
  110. * APS System Functions
  111. */
  112. /*
  113. * Initialization function for the APS layer.
  114. */
  115. extern void APS_Init( byte task_id );
  116. /*
  117. * Event Loop Processor for APS.
  118. */
  119. extern UINT16 APS_event_loop( byte task_id, UINT16 events );
  120. /*
  121. * Setup the End Device Bind Timeout
  122. */
  123. extern void APS_SetEndDeviceBindTimeout( uint16 timeout, pfnBindingTimeoutCB pfnCB );
  124. /*
  125. * APS Command Indication
  126. */
  127. extern void APS_CmdInd( APS_CmdInd_t* ind );
  128. /*
  129. * APS Reflector Initiatialization
  130. * APS_REFLECTOR_PUBLIC
  131. * APS_REFLECTOR_PRIVATE
  132. */
  133. extern void APS_ReflectorInit( uint8 type );
  134. #if ( ZG_BUILD_ENDDEVICE_TYPE ) && ( RFD_RCVC_ALWAYS_ON==TRUE )
  135. /*
  136. * APS_InitEndDeviceBroadcastTable - Initialize the End Device Broadcast table
  137. */
  138. extern void APS_InitEndDeviceBroadcastTable( void );
  139. /*
  140. * APS_EndDeviceBroadcastCheck
  141. */
  142. extern uint8 APS_EndDeviceBroadcastCheck( NLDE_FrameFormat_t *ff );
  143. #endif // ( ZG_BUILD_ENDDEVICE_TYPE ) && ( RFD_RCVC_ALWAYS_ON==TRUE )
  144. /*********************************************************************
  145. * REFLECTOR FUNCTION POINTERS
  146. */
  147. extern ZStatus_t (*pAPS_UnBind)( byte SrcEndpInt,
  148. uint16 ClusterId, zAddrType_t *DstAddr, byte DstEndpInt );
  149. /*
  150. * Fill in pItem w/ info from the Nth valid binding table entry.
  151. */
  152. extern ZStatus_t (*pAPS_GetBind)( uint16 Nth, apsBindingItem_t *pItem );
  153. extern void (*pAPS_DataConfirmReflect)( nwkDB_t *rec, uint8 status );
  154. extern void (*pAPS_DataIndReflect)( zAddrType_t *SrcAddress, aps_FrameFormat_t *aff,
  155. NLDE_Signal_t *sig, byte AckRequest, byte SecurityUse, uint32 timestamp );
  156. /****************************************************************************
  157. ****************************************************************************/
  158. #ifdef __cplusplus
  159. }
  160. #endif
  161. #endif /* APS_H */