ZDConfig.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**************************************************************************************************
  2. Filename: ZDConfig.c
  3. Revised: $Date: 2008-02-12 16:32:50 -0800 (Tue, 12 Feb 2008) $
  4. Revision: $Revision: 16393 $
  5. Description: This file contains the configuration attributes for the Zigbee Device Object.
  6. These are references to Configuration items that MUST be defined in ZDApp.c.
  7. The names mustn't change.
  8. Copyright 2004-2007 Texas Instruments Incorporated. All rights reserved.
  9. IMPORTANT: Your use of this Software is limited to those specific rights
  10. granted under the terms of a software license agreement between the user
  11. who downloaded the software, his/her employer (which must be your employer)
  12. and Texas Instruments Incorporated (the "License"). You may not use this
  13. Software unless you agree to abide by the terms of the License. The License
  14. limits your use, and you acknowledge, that the Software may not be modified,
  15. copied or distributed unless embedded on a Texas Instruments microcontroller
  16. or used solely and exclusively in conjunction with a Texas Instruments radio
  17. frequency transceiver, which is integrated into your product. Other than for
  18. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  19. works of, modify, distribute, perform, display or sell this Software and/or
  20. its documentation for any purpose.
  21. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  22. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  23. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  24. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  25. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  26. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  27. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  28. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  29. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  30. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  31. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  32. Should you have any questions regarding your right to use this Software,
  33. contact Texas Instruments Incorporated at www.TI.com.
  34. **************************************************************************************************/
  35. /*********************************************************************
  36. * INCLUDES
  37. */
  38. #include "ZComdef.h"
  39. #include "AF.h"
  40. #include "ZDObject.h"
  41. #include "ZDConfig.h"
  42. /*********************************************************************
  43. * MACROS
  44. */
  45. /*********************************************************************
  46. * CONSTANTS
  47. */
  48. /*********************************************************************
  49. * TYPEDEFS
  50. */
  51. /*********************************************************************
  52. * GLOBAL VARIABLES
  53. */
  54. NodeDescriptorFormat_t ZDO_Config_Node_Descriptor;
  55. NodePowerDescriptorFormat_t ZDO_Config_Power_Descriptor;
  56. /*********************************************************************
  57. * EXTERNAL VARIABLES
  58. */
  59. /*********************************************************************
  60. * EXTERNAL FUNCTIONS
  61. */
  62. /*********************************************************************
  63. * LOCAL FUNCTIONS
  64. */
  65. /*********************************************************************
  66. * LOCAL VARIABLES
  67. */
  68. /*********************************************************************
  69. * @fn ZDConfig_InitDescriptors()
  70. *
  71. * @brief Setup the ZDO descriptors
  72. * Node, Power
  73. *
  74. * @param none
  75. *
  76. * @return none
  77. */
  78. void ZDConfig_InitDescriptors( void )
  79. {
  80. ZDConfig_UpdateNodeDescriptor();
  81. ZDConfig_UpdatePowerDescriptor();
  82. }
  83. /*********************************************************************
  84. * @fn ZDConfig_UpdateNodeDescriptor()
  85. *
  86. * @brief Update the ZDO Node Descriptor
  87. *
  88. * @param none
  89. *
  90. * @return none
  91. */
  92. void ZDConfig_UpdateNodeDescriptor( void )
  93. {
  94. // Build the Node Descriptor
  95. if ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
  96. ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
  97. else if ( ZSTACK_ROUTER_BUILD )
  98. ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_ROUTER;
  99. else if ( ZSTACK_END_DEVICE_BUILD )
  100. ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_DEVICE;
  101. ZDO_Config_Node_Descriptor.ComplexDescAvail = FALSE; // set elsewhere
  102. ZDO_Config_Node_Descriptor.UserDescAvail = FALSE; // set elsewhere
  103. ZDO_Config_Node_Descriptor.Reserved = 0; // Reserved
  104. ZDO_Config_Node_Descriptor.APSFlags = 0; // NO APS flags
  105. ZDO_Config_Node_Descriptor.FrequencyBand = NODEFREQ_2400; // Frequency Band
  106. // MAC Capabilities
  107. if ( ZSTACK_ROUTER_BUILD )
  108. {
  109. ZDO_Config_Node_Descriptor.CapabilityFlags
  110. = (CAPINFO_DEVICETYPE_FFD | CAPINFO_POWER_AC | CAPINFO_RCVR_ON_IDLE);
  111. if ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
  112. ZDO_Config_Node_Descriptor.CapabilityFlags |= CAPINFO_ALTPANCOORD;
  113. }
  114. else if ( ZSTACK_END_DEVICE_BUILD )
  115. {
  116. ZDO_Config_Node_Descriptor.CapabilityFlags = (CAPINFO_DEVICETYPE_RFD
  117. #if ( RFD_RCVC_ALWAYS_ON == TRUE)
  118. | CAPINFO_RCVR_ON_IDLE
  119. #endif
  120. );
  121. }
  122. // Manufacturer Code - *YOU FILL IN*
  123. ZDO_Config_Node_Descriptor.ManufacturerCode[0] = 0;
  124. ZDO_Config_Node_Descriptor.ManufacturerCode[1] = 0;
  125. // Maximum Buffer Size
  126. ZDO_Config_Node_Descriptor.MaxBufferSize = MAX_BUFFER_SIZE;
  127. // Maximum Incoming Transfer Size Field
  128. ZDO_Config_Node_Descriptor.MaxInTransferSize[0] = LO_UINT16( MAX_TRANSFER_SIZE );
  129. ZDO_Config_Node_Descriptor.MaxInTransferSize[1] = HI_UINT16( MAX_TRANSFER_SIZE );
  130. // Maximum Outgoing Transfer Size Field
  131. ZDO_Config_Node_Descriptor.MaxOutTransferSize[0] = LO_UINT16( MAX_TRANSFER_SIZE );
  132. ZDO_Config_Node_Descriptor.MaxOutTransferSize[1] = HI_UINT16( MAX_TRANSFER_SIZE );
  133. // Server Mask
  134. ZDO_Config_Node_Descriptor.ServerMask = 0;
  135. // Descriptor Capability Field - extended active endpoint list and
  136. // extended simple descriptor are not supported.
  137. ZDO_Config_Node_Descriptor.DescriptorCapability = 0;
  138. }
  139. /*********************************************************************
  140. * @fn ZDConfig_UpdatePowerDescriptor()
  141. *
  142. * @brief Update the ZDO Power Descriptor
  143. *
  144. * @param none
  145. *
  146. * @return none
  147. */
  148. void ZDConfig_UpdatePowerDescriptor( void )
  149. {
  150. // Build the Power Descriptor
  151. if ( ZSTACK_ROUTER_BUILD )
  152. {
  153. ZDO_Config_Power_Descriptor.PowerMode = NODECURPWR_RCVR_ALWAYS_ON;
  154. ZDO_Config_Power_Descriptor.AvailablePowerSources = NODEAVAILPWR_MAINS;
  155. ZDO_Config_Power_Descriptor.CurrentPowerSource = NODEAVAILPWR_MAINS;
  156. ZDO_Config_Power_Descriptor.CurrentPowerSourceLevel = NODEPOWER_LEVEL_100;
  157. }
  158. else if ( ZSTACK_END_DEVICE_BUILD )
  159. {
  160. if ( zgPollRate )
  161. ZDO_Config_Power_Descriptor.PowerMode = NODECURPWR_RCVR_AUTO;
  162. else
  163. ZDO_Config_Power_Descriptor.PowerMode = NODECURPWR_RCVR_STIM;
  164. ZDO_Config_Power_Descriptor.AvailablePowerSources = NODEAVAILPWR_RECHARGE;
  165. ZDO_Config_Power_Descriptor.CurrentPowerSource = NODEAVAILPWR_RECHARGE;
  166. ZDO_Config_Power_Descriptor.CurrentPowerSourceLevel = NODEPOWER_LEVEL_66;
  167. }
  168. }
  169. /*********************************************************************
  170. *********************************************************************/