zba.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**************************************************************************************************
  2. Filename: zba.c
  3. Revised: $Date: 2011-05-31 10:03:43 -0700 (Tue, 31 May 2011) $
  4. Revision: $Revision: 26156 $
  5. Description: This file contains the ZigBee Building Automation (ZBA)
  6. Profile implementation.
  7. Copyright 2011 Texas Instruments Incorporated. All rights reserved.
  8. IMPORTANT: Your use of this Software is limited to those specific rights
  9. granted under the terms of a software license agreement between the user
  10. who downloaded the software, his/her employer (which must be your employer)
  11. and Texas Instruments Incorporated (the "License"). You may not use this
  12. Software unless you agree to abide by the terms of the License. The License
  13. limits your use, and you acknowledge, that the Software may not be modified,
  14. copied or distributed unless embedded on a Texas Instruments microcontroller
  15. or used solely and exclusively in conjunction with a Texas Instruments radio
  16. frequency transceiver, which is integrated into your product. Other than for
  17. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  18. works of, modify, distribute, perform, display or sell this Software and/or
  19. its documentation for any purpose.
  20. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  21. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  22. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  23. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  24. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  25. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  26. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  27. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  28. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  29. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  30. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  31. Should you have any questions regarding your right to use this Software,
  32. contact Texas Instruments Incorporated at www.TI.com.
  33. **************************************************************************************************/
  34. /*********************************************************************
  35. * INCLUDES
  36. */
  37. #include "ZComDef.h"
  38. #include "OSAL.h"
  39. #include "OSAL_Nv.h"
  40. #include "ZDApp.h"
  41. #include "zcl.h"
  42. #include "zcl_general.h"
  43. #include "zcl_cc.h"
  44. #include "zcl_key_establish.h"
  45. #include "zba.h"
  46. /*********************************************************************
  47. * MACROS
  48. */
  49. /*********************************************************************
  50. * CONSTANTS
  51. */
  52. // This is the ZBA Global Commissioning EPID reserved by the ZigBee Alliance
  53. const uint8 zbaGlobalCommissioningEPID[Z_EXTADDR_LEN] = { 0x00, 0x00, 0x00, 0x10, 0x77, 0xC2, 0x50, 0x00 };
  54. /*********************************************************************
  55. * Cluster Conversion List - table used to convert between real and
  56. * logical cluster IDs.
  57. */
  58. /*********************************************************************
  59. * TYPEDEFS
  60. */
  61. /*********************************************************************
  62. * GLOBAL VARIABLES
  63. */
  64. /*********************************************************************
  65. * EXTERNAL VARIABLES
  66. */
  67. /*********************************************************************
  68. * EXTERNAL FUNCTIONS
  69. */
  70. /*********************************************************************
  71. * LOCAL VARIABLES
  72. */
  73. /*********************************************************************
  74. * LOCAL FUNCTIONS
  75. */
  76. /*********************************************************************
  77. * @fn zba_Init
  78. *
  79. * @brief Register the Simple descriptor with the ZBA profile.
  80. * This function also registers the profile's cluster
  81. * conversion table.
  82. *
  83. * @param simpleDesc
  84. *
  85. * @return none
  86. */
  87. void zba_Init( SimpleDescriptionFormat_t *simpleDesc )
  88. {
  89. endPointDesc_t *epDesc;
  90. // Register the application's endpoint descriptor
  91. // - This memory is allocated and never freed.
  92. epDesc = osal_mem_alloc( sizeof ( endPointDesc_t ) );
  93. if ( epDesc )
  94. {
  95. // Fill out the endpoint description.
  96. epDesc->endPoint = simpleDesc->EndPoint;
  97. epDesc->task_id = &zcl_TaskID; // all messages get sent to ZCL first
  98. epDesc->simpleDesc = simpleDesc;
  99. epDesc->latencyReq = noLatencyReqs;
  100. // Register the endpoint description with the AF
  101. if (afRegister(epDesc) == afStatus_SUCCESS)
  102. {
  103. // Set the ZBA Profile-specific APS Fragmentation configuration.
  104. afAPSF_Config_t cfg = { ZBA_APSF_FRAME_DELAY, ZBA_APSF_WINDOW_SIZE };
  105. (void)afAPSF_ConfigSet(epDesc->endPoint, &cfg);
  106. }
  107. }
  108. }
  109. /*********************************************************************
  110. *********************************************************************/