APS.h 6.2 KB

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