tranthudo

BasicClientCommands.c

Jun 6th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.62 KB | None | 0 0
  1. /*****************************************************************************
  2.  *
  3.  * MODULE:             Basic Cluster
  4.  *
  5.  * COMPONENT:          BasicClientCommands.h
  6.  *
  7.  * AUTHOR:             Lee Mitchell
  8.  *
  9.  * DESCRIPTION:        Send a Basic cluster command
  10.  *
  11.  * $HeadURL: https://www.collabnet.nxp.com/svn/lprf_sware/Projects/Components/ZCL/Trunk/Clusters/General/Source/BasicClientCommands.c $
  12.  *
  13.  * $Revision: 65575 $
  14.  *
  15.  * $LastChangedBy: nxp57621 $
  16.  *
  17.  * $LastChangedDate: 2014-11-14 12:35:30 +0100 (Fri, 14 Nov 2014) $
  18.  *
  19.  * $Id: BasicClientCommands.c 65575 2014-11-14 11:35:30Z nxp57621 $
  20.  *
  21.  ****************************************************************************
  22.  *
  23.  * This software is owned by NXP B.V. and/or its supplier and is protected
  24.  * under applicable copyright laws. All rights are reserved. We grant You,
  25.  * and any third parties, a license to use this software solely and
  26.  * exclusively on NXP products [NXP Microcontrollers such as JN5168, JN5164,
  27.  * JN5161, JN5148, JN5142, JN5139].
  28.  * You, and any third parties must reproduce the copyright and warranty notice
  29.  * and any other legend of ownership on each  copy or partial copy of the software.
  30.  *
  31.  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
  32.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  34.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  35.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  36.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  37.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  38.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  39.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41.  * POSSIBILITY OF SUCH DAMAGE.
  42.  *
  43.  * Copyright NXP B.V. 2012. All rights reserved
  44.  *
  45.  ****************************************************************************/
  46.  
  47. /****************************************************************************/
  48. /***        Include files                                                 ***/
  49. /****************************************************************************/
  50. #include <jendefs.h>
  51.  
  52. #include "zcl.h"
  53. #include "zcl_customcommand.h"
  54.  
  55. #include "Basic.h"
  56.  
  57. #include "pdum_apl.h"
  58. #include "zps_apl.h"
  59. #include "zps_apl_af.h"
  60.  
  61. #include "dbg.h"
  62.  
  63. #ifdef DEBUG_CLD_BASIC
  64. #define TRACE_BASIC    TRUE
  65. #else
  66. #define TRACE_BASIC    FALSE
  67. #endif
  68.  
  69. /****************************************************************************/
  70. /***        Macro Definitions                                             ***/
  71. /****************************************************************************/
  72.  
  73. /****************************************************************************/
  74. /***        Type Definitions                                              ***/
  75. /****************************************************************************/
  76.  
  77. /****************************************************************************/
  78. /***        Local Function Prototypes                                     ***/
  79. /****************************************************************************/
  80.  
  81. /****************************************************************************/
  82. /***        Exported Variables                                            ***/
  83. /****************************************************************************/
  84.  
  85. /****************************************************************************/
  86. /***        Local Variables                                               ***/
  87. /****************************************************************************/
  88.  
  89. /****************************************************************************/
  90. /***        Public Functions                                              ***/
  91. /****************************************************************************/
  92.  
  93. /****************************************************************************
  94.  **
  95.  ** NAME:       eCLD_BasicCommandResetToFactoryDefaultsSend
  96.  **
  97.  ** DESCRIPTION:
  98.  ** Builds and sends a basic cluster command
  99.  **
  100.  ** PARAMETERS:                 Name                           Usage
  101.  ** uint8                       u8SourceEndPointId             Source EP Id
  102.  ** uint8                       u8DestinationEndPointId        Destination EP Id
  103.  ** tsZCL_Address              *psDestinationAddress           Destination Address
  104.  ** uint8                      *pu8TransactionSequenceNumber   Sequence number Pointer
  105.  **
  106.  ** RETURN:
  107.  ** teZCL_Status
  108.  **
  109.  ****************************************************************************/
  110. PUBLIC teZCL_Status eCLD_BasicCommandResetToFactoryDefaultsSend(
  111.                     uint8                       u8SourceEndPointId,
  112.                     uint8                       u8DestinationEndPointId,
  113.                     tsZCL_Address               *psDestinationAddress,
  114.                     uint8                       *pu8TransactionSequenceNumber)
  115. {
  116.  
  117.     return eZCL_CustomCommandSend(u8SourceEndPointId,
  118.                                   u8DestinationEndPointId,
  119.                                   psDestinationAddress,
  120.                                   GENERAL_CLUSTER_ID_BASIC,
  121.                                   FALSE,
  122.                                   E_CLD_BASIC_CMD_RESET_TO_FACTORY_DEFAULTS,
  123.                                   pu8TransactionSequenceNumber,
  124.                                   0,
  125.                                   FALSE,
  126.                                   0,
  127.                                   0);
  128.  
  129. }
  130.  
  131.  
  132. /****************************************************************************
  133.  **
  134.  ** NAME:       eCLD_BasicCommandResetToFactoryDefaultsReceive
  135.  **
  136.  ** DESCRIPTION:
  137.  ** handles rx of reset to factory defaults message
  138.  **
  139.  ** PARAMETERS:               Name                          Usage
  140.  ** ZPS_tsAfEvent              *pZPSevent                   Zigbee stack event structure
  141.  ** tsZCL_EndPointDefinition *psEndPointDefinition          EP structure
  142.  ** tsZCL_ClusterInstance    *psClusterInstance             Cluster structure
  143.  ** uint8                    *pu8TransactionSequenceNumber  Sequence number Pointer
  144.  **
  145.  ** RETURN:
  146.  ** teZCL_Status
  147.  **
  148.  ****************************************************************************/
  149. PUBLIC teZCL_Status eCLD_BasicCommandResetToFactoryDefaultsReceive(
  150.                     ZPS_tsAfEvent               *pZPSevent,
  151.                     uint8                       *pu8TransactionSequenceNumber)
  152. {
  153.  
  154.     return eZCL_CustomCommandReceive(pZPSevent,
  155.                                      pu8TransactionSequenceNumber,
  156.                                      0,
  157.                                      0,
  158.                                      E_ZCL_ACCEPT_EXACT);
  159.  
  160. }
  161.  
  162. #ifdef CLD_BAS_CMD_MAN_SPEC_SET_LED_INTENSITY
  163. /****************************************************************************
  164.  **
  165.  ** NAME:       eCLD_BasicCommandSetLedIntensitySend
  166.  **
  167.  ** DESCRIPTION:
  168.  ** Builds and sends a basic cluster command
  169.  **
  170.  ** PARAMETERS:                 Name                           Usage
  171.  ** uint8                       u8SourceEndPointId             Source EP Id
  172.  ** uint8                       u8DestinationEndPointId        Destination EP Id
  173.  ** tsZCL_Address              *psDestinationAddress           Destination Address
  174.  ** uint8                      *pu8TransactionSequenceNumber   Sequence number Pointer
  175.  **
  176.  ** RETURN:
  177.  ** teZCL_Status
  178.  **
  179.  ****************************************************************************/
  180. PUBLIC teZCL_Status eCLD_BasicCommandSetLedIntensitySend(
  181.                     uint8                       u8SourceEndPointId,
  182.                     uint8                       u8DestinationEndPointId,
  183.                     tsZCL_Address               *psDestinationAddress,
  184.                     uint8                       *pu8TransactionSequenceNumber,
  185.                     tsCLD_Basic_SetLedIntensityPayload *psPayload)
  186. {
  187.     tsZCL_TxPayloadItem asPayloadDefinition[] = {
  188.         {1, E_ZCL_UINT8,   &psPayload->u8IntensityLevel}
  189.                                                 };
  190.  
  191.     return eZCL_CustomCommandSend(u8SourceEndPointId,
  192.                                   u8DestinationEndPointId,
  193.                                   psDestinationAddress,
  194.                                   GENERAL_CLUSTER_ID_BASIC,
  195.                                   FALSE,
  196.                                   E_CLD_BASIC_CMD_MAN_SPEC_SET_LED_INTENSITY,
  197.                                   pu8TransactionSequenceNumber,
  198.                                   asPayloadDefinition,
  199.                                   TRUE,
  200.                                   ZCL_MANUFACTURER_CODE,
  201.                                   sizeof(asPayloadDefinition) / sizeof(tsZCL_TxPayloadItem)
  202.                                   );
  203.  
  204. }
  205.  
  206. /****************************************************************************
  207.  **
  208.  ** NAME:       eCLD_BasicCommandSetLedIntensityReceive
  209.  **
  210.  ** DESCRIPTION:
  211.  ** handles rx of reset to factory defaults message
  212.  **
  213.  ** PARAMETERS:               Name                          Usage
  214.  ** ZPS_tsAfEvent              *pZPSevent                   Zigbee stack event structure
  215.  ** tsZCL_EndPointDefinition *psEndPointDefinition          EP structure
  216.  ** tsZCL_ClusterInstance    *psClusterInstance             Cluster structure
  217.  ** uint8                    *pu8TransactionSequenceNumber  Sequence number Pointer
  218.  **
  219.  ** RETURN:
  220.  ** teZCL_Status
  221.  **
  222.  ****************************************************************************/
  223. PUBLIC teZCL_Status eCLD_BasicCommandSetLedIntensityReceive(
  224.                     ZPS_tsAfEvent               *pZPSevent,
  225.                     uint8                       *pu8TransactionSequenceNumber,
  226.                     tsCLD_Basic_SetLedIntensityPayload *psPayload)
  227. {
  228.     uint16 u16ActualQuantity;
  229.  
  230.     tsZCL_RxPayloadItem asPayloadDefinition[] = {
  231.             {1, &u16ActualQuantity, E_ZCL_UINT8,   &psPayload->u8IntensityLevel}
  232.                                                 };
  233.  
  234.     return eZCL_CustomCommandReceive(pZPSevent,
  235.                                      pu8TransactionSequenceNumber,
  236.                                      asPayloadDefinition,
  237.                                      sizeof(asPayloadDefinition) / sizeof(tsZCL_RxPayloadItem),
  238.                                      E_ZCL_ACCEPT_LESS|E_ZCL_DISABLE_DEFAULT_RESPONSE);
  239. }
  240. #endif
  241.  
  242. #ifdef CLD_BAS_CMD_MAN_SPEC_SET_VIBRATION_INTENSITY
  243. /****************************************************************************
  244.  **
  245.  ** NAME:       eCLD_BasicCommandSetVibrationIntensitySend
  246.  **
  247.  ** DESCRIPTION:
  248.  ** Builds and sends a basic cluster command
  249.  **
  250.  ** PARAMETERS:                 Name                           Usage
  251.  ** uint8                       u8SourceEndPointId             Source EP Id
  252.  ** uint8                       u8DestinationEndPointId        Destination EP Id
  253.  ** tsZCL_Address              *psDestinationAddress           Destination Address
  254.  ** uint8                      *pu8TransactionSequenceNumber   Sequence number Pointer
  255.  **
  256.  ** RETURN:
  257.  ** teZCL_Status
  258.  **
  259.  ****************************************************************************/
  260. PUBLIC teZCL_Status eCLD_BasicCommandSetVibrationIntensitySend(
  261.                     uint8                       u8SourceEndPointId,
  262.                     uint8                       u8DestinationEndPointId,
  263.                     tsZCL_Address               *psDestinationAddress,
  264.                     uint8                       *pu8TransactionSequenceNumber,
  265.                     tsCLD_Basic_SetVibrationIntensityPayload *psPayload)
  266. {
  267.     tsZCL_TxPayloadItem asPayloadDefinition[] = {
  268.         {1, E_ZCL_UINT8,   &psPayload->u8IntensityLevel}
  269.                                                 };
  270.  
  271.     return eZCL_CustomCommandSend(u8SourceEndPointId,
  272.                                   u8DestinationEndPointId,
  273.                                   psDestinationAddress,
  274.                                   GENERAL_CLUSTER_ID_BASIC,
  275.                                   FALSE,
  276.                                   E_CLD_BASIC_CMD_MAN_SPEC_SET_VIBRATION_INTENSITY,
  277.                                   pu8TransactionSequenceNumber,
  278.                                   asPayloadDefinition,
  279.                                   TRUE,
  280.                                   ZCL_MANUFACTURER_CODE,
  281.                                   sizeof(asPayloadDefinition) / sizeof(tsZCL_TxPayloadItem)
  282.                                   );
  283. }
  284.  
  285. /****************************************************************************
  286.  **
  287.  ** NAME:       eCLD_BasicCommandSetVibrationIntensityReceive
  288.  **
  289.  ** DESCRIPTION:
  290.  ** handles rx of reset to factory defaults message
  291.  **
  292.  ** PARAMETERS:               Name                          Usage
  293.  ** ZPS_tsAfEvent              *pZPSevent                   Zigbee stack event structure
  294.  ** tsZCL_EndPointDefinition *psEndPointDefinition          EP structure
  295.  ** tsZCL_ClusterInstance    *psClusterInstance             Cluster structure
  296.  ** uint8                    *pu8TransactionSequenceNumber  Sequence number Pointer
  297.  **
  298.  ** RETURN:
  299.  ** teZCL_Status
  300.  **
  301.  ****************************************************************************/
  302. PUBLIC teZCL_Status eCLD_BasicCommandSetVibrationIntensityReceive(
  303.                     ZPS_tsAfEvent               *pZPSevent,
  304.                     uint8                       *pu8TransactionSequenceNumber,
  305.                     tsCLD_Basic_SetVibrationIntensityPayload *psPayload)
  306. {
  307.     uint16 u16ActualQuantity;
  308.  
  309.     tsZCL_RxPayloadItem asPayloadDefinition[] = {
  310.             {1, &u16ActualQuantity, E_ZCL_UINT8,   &psPayload->u8IntensityLevel}
  311.                                                 };
  312.  
  313.     return eZCL_CustomCommandReceive(pZPSevent,
  314.                                      pu8TransactionSequenceNumber,
  315.                                      asPayloadDefinition,
  316.                                      sizeof(asPayloadDefinition) / sizeof(tsZCL_RxPayloadItem),
  317.                                      E_ZCL_ACCEPT_LESS|E_ZCL_DISABLE_DEFAULT_RESPONSE);
  318. }
  319. #endif
  320.  
  321. /****************************************************************************/
  322. /***        Private Functions                                             ***/
  323. /****************************************************************************/
  324.  
  325. /****************************************************************************/
  326. /***        END OF FILE                                                   ***/
  327. /****************************************************************************/
Add Comment
Please, Sign In to add comment