text: /*****************************************************************************
   *
   * MODULE:             THERMOSTAT DEVICE
   *
   * COMPONENT:          thermostat_device.h
   *
   * AUTHOR:             nlv10675
   *
   * DESCRIPTION:        Header for ZigBee TemperatureSensor profile functions
   *
   * $HeadURL: https://www.collabnet.nxp.com/svn/lprf_sware/Projects/Components/ZCL/Trunk/Devices/ZHA/HVAC/Include/temperature_sensor.h $
   *
   * $Revision: 78915 $
   *
   * $LastChangedBy: nxp57621 $
   *
   * $LastChangedDate: 2016-04-27 08:35:35 +0200 (Wed, 27 Apr 2016) $
   *
   * $Id: temperature_sensor.h 78915 2016-04-27 06:35:35Z nxp57621 $
   *
   *****************************************************************************
   *
   * This software is owned by NXP B.V. and/or its supplier and is protected
   * under applicable copyright laws. All rights are reserved. We grant You,
   * and any third parties, a license to use this software solely and
   * exclusively on NXP products [NXP Microcontrollers such as JN5148, JN5142, JN5139]. 
   * You, and any third parties must reproduce the copyright and warranty notice 
   * and any other legend of ownership on each  copy or partial copy of the software.
   *
   *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
   * POSSIBILITY OF SUCH DAMAGE. 
   *
   * Copyright NXP B.V. 2013. All rights reserved
   *
   ****************************************************************************/
  
  #ifndef TEMPERATURE_SENSOR_H
  #define TEMPERATURE_SENSOR_H
  
  #if defined __cplusplus
  extern "C" {
  #endif
  
  #include <jendefs.h>
  #include "zcl.h"
  #include "zcl_options.h"
  #include "Basic.h"
  #include "Identify.h"
  #ifdef CLD_POWER_CONFIGURATION
  #include "PowerConfiguration.h"
  #endif
  #ifdef CLD_DEVICE_TEMPERATURE_CONFIGURATION
  #include "DeviceTemperatureConfiguration.h"
  #endif
  #ifdef CLD_ALARMS
  #include "Alarms.h"
  #endif
  #include "Groups.h"
  #include "Scenes.h"
  #ifdef CLD_TEMPERATURE_MEASUREMENT
  #include "TemperatureMeasurement.h"
  #endif
  #ifdef CLD_RELATIVE_HUMIDITY_MEASUREMENT
  #include "RelativeHumidityMeasurement.h"
  #endif
  #ifdef CLD_OCCUPANCY_SENSING
  #include "OccupancySensing.h"
  #endif
  #ifdef CLD_OTA
  #include "OTA.h"
  #endif
  #include "Time.h"
  #ifdef CLD_POLL_CONTROL
      #include "PollControl.h"
  #endif
  #ifdef CLD_ELECTRICAL_MEASUREMENT
  	#include "ElectricalMeasurement.h"
  #endif
  /****************************************************************************/
  /***        Macro Definitions                                             ***/
  /****************************************************************************/
  #define HVAC_TEMPERATURE_SENSOR_DEVICE_ID                              0x0302
  /****************************************************************************/
  /***        Type Definitions                                              ***/
  /****************************************************************************/
  
  /* Holds cluster instances */
  typedef struct 
  {
      /* All HA devices have 2 mandatory clusters - Basic(server) and Identify(server) */
  #if (defined CLD_BASIC) && (defined BASIC_SERVER)
      tsZCL_ClusterInstance sBasicServer;
  #endif
  
  #if (defined CLD_IDENTIFY) && (defined IDENTIFY_SERVER)
      tsZCL_ClusterInstance sIdentifyServer;
  #endif
  
      /* Optional Clusters Common to All HA Server Devices */
  #if (defined CLD_POWER_CONFIGURATION) && (defined POWER_CONFIGURATION_SERVER)
      tsZCL_ClusterInstance sPowerConfigurationServer;
  #endif
  
  #if (defined CLD_DEVICE_TEMPERATURE_CONFIGURATION) && (defined DEVICE_TEMPERATURE_CONFIGURATION_SERVER)
      tsZCL_ClusterInstance sDeviceTemperatureConfigurationServer;
  #endif
  
  #if (defined CLD_ALARMS) && (defined ALARMS_SERVER)
      tsZCL_ClusterInstance sAlarmsServer;
  #endif
  
  #if (defined CLD_POLL_CONTROL) && (defined POLL_CONTROL_SERVER)
      tsZCL_ClusterInstance sPollControlServer;
  #endif
  
  #if (defined CLD_SCENES) && (defined SCENES_SERVER)
      tsZCL_ClusterInstance sScenesServer;
  #endif
  
  #if (defined CLD_GROUPS) && (defined GROUPS_SERVER)
      tsZCL_ClusterInstance sGroupsServer;
  #endif
  
      /* Optional Clusters Common to All HA Client Devices */
  #if (defined CLD_SCENES) && (defined SCENES_CLIENT)
      tsZCL_ClusterInstance sScenesClient;
  #endif
  
  #if (defined CLD_GROUPS) && (defined GROUPS_CLIENT)
      tsZCL_ClusterInstance sGroupsClient;
  #endif
      
      /* Mandatory Server Clusters supported by Temperature Sensor Device */
  #if (defined CLD_TEMPERATURE_MEASUREMENT) && (defined TEMPERATURE_MEASUREMENT_SERVER)
      tsZCL_ClusterInstance sTemperatureMeasurementServer;
  #endif
  
      /* Mandatory Client Clusters supported by Temperature Sensor Device */
  #if (defined CLD_IDENTIFY) && (defined IDENTIFY_CLIENT)
      tsZCL_ClusterInstance sIdentifyClient;
  #endif
  
      /* Optional Client Clusters supported by Temperature Sensor Device */
  #ifdef CLD_OTA
      #ifdef OTA_CLIENT
      /* Add  cluster instance for the OTA cluster */
      tsZCL_ClusterInstance sOTAClient;
      #endif
      
      #ifdef OTA_SERVER
      /* Add  server instance for the OTA cluster */
      tsZCL_ClusterInstance sOTAServer;    
      #endif
  #endif
  
  #if (defined CLD_TIME) && (defined TIME_CLIENT)
      tsZCL_ClusterInstance sTimeClient;
  #endif
          
  #if (defined CLD_POLL_CONTROL) && (defined POLL_CONTROL_CLIENT)
      tsZCL_ClusterInstance sPollControlClient;
  #endif
  
  
  #if (defined CLD_ELECTRICAL_MEASUREMENT && defined ELECTRICAL_MEASUREMENT_SERVER)
      tsZCL_ClusterInstance sElectricalMeasurementServer;
  #endif
  } tsHA_TemperatureSensorDeviceClusterInstances __attribute__ ((aligned(4)));
  
  
  /* Holds everything required to create an instance of a thermostat device */
  typedef struct
  {
      tsZCL_EndPointDefinition sEndPoint;
  
      /* Cluster instances */
      tsHA_TemperatureSensorDeviceClusterInstances sClusterInstance;
  
      /* All HA devices have 2 mandatory clusters - Basic(server) and Identify(server) */
  #if (defined CLD_BASIC) && (defined BASIC_SERVER)
      /* Basic Cluster - Server */
      tsCLD_Basic sBasicServerCluster;
  #endif
  
  #if (defined CLD_IDENTIFY) && (defined IDENTIFY_SERVER)
      /* Identify Cluster - Server */
      tsCLD_Identify sIdentifyServerCluster;
      tsCLD_IdentifyCustomDataStructure sIdentifyServerCustomDataStructure;
  #endif
  
      /* Optional Clusters Common to All HA Server Devices */
  #if (defined CLD_POWER_CONFIGURATION) && (defined POWER_CONFIGURATION_SERVER)
      /* Power Configuration Cluster - Server */
      tsCLD_PowerConfiguration sPowerConfigServerCluster;
  #endif
  
  #if (defined CLD_DEVICE_TEMPERATURE_CONFIGURATION) && (defined DEVICE_TEMPERATURE_CONFIGURATION_SERVER)
      /* Device Temperature Configuration Cluster - Server */
      tsCLD_DeviceTemperatureConfiguration sDeviceTemperatureConfigurationServerCluster;
  #endif
  
  #if (defined CLD_ALARMS) && (defined ALARMS_SERVER)
      /* Alarms Cluster - Server */
      tsCLD_Alarms sAlarmsServerCluster;
      tsCLD_AlarmsCustomDataStructure sAlarmsServerCustomDataStructure;
  #endif
  
  #if (defined CLD_POLL_CONTROL) && (defined POLL_CONTROL_SERVER)
      tsCLD_PollControl sPollControlServerCluster;
      tsCLD_PollControlCustomDataStructure sPollControlServerCustomDataStructure;
  #endif
  
  #if (defined CLD_SCENES) && (defined SCENES_SERVER)
      /* Scenes Cluster - Server */
      tsCLD_Scenes sScenesServerCluster;
      tsCLD_ScenesCustomDataStructure sScenesServerCustomDataStructure;
  #endif
  
  #if (defined CLD_GROUPS) && (defined GROUPS_SERVER)
      /* Groups Cluster - Server */
      tsCLD_Groups sGroupsServerCluster;
      tsCLD_GroupsCustomDataStructure sGroupsServerCustomDataStructure;
  #endif
  
      /* Optional Clusters Common to All HA Client Devices */
  #if (defined CLD_SCENES) && (defined SCENES_CLIENT)
      /* Scenes Cluster - Client */
      tsCLD_Scenes sScenesClientCluster;
      tsCLD_ScenesCustomDataStructure sScenesClientCustomDataStructure;
  #endif
  
  #if (defined CLD_GROUPS) && (defined GROUPS_CLIENT)
      /* Groups Cluster - Client */
      tsCLD_Groups sGroupsClientCluster;
      tsCLD_GroupsCustomDataStructure sGroupsClientCustomDataStructure;
  #endif
  
      /* Mandatory Server Clusters supported by Temperature Sensor Device */    
  #if (defined CLD_TEMPERATURE_MEASUREMENT) && (defined TEMPERATURE_MEASUREMENT_SERVER)
      tsCLD_TemperatureMeasurement sTemperatureMeasurementServerCluster;
  #endif
  
      /* Mandatory Client Clusters supported by Temperature Sensor Device */
  #if (defined CLD_IDENTIFY) && (defined IDENTIFY_CLIENT)
      /* Identify Cluster - Client */
      tsCLD_Identify sIdentifyClientCluster;
      tsCLD_IdentifyCustomDataStructure sIdentifyClientCustomDataStructure;
  #endif
      
      /* Optional Client Clusters supported by Temperature Sensor Device */
  #ifdef CLD_OTA
      /* OTA cluster */
      #ifdef OTA_CLIENT
          tsCLD_AS_Ota sCLD_OTA;
          tsOTA_Common sCLD_OTA_CustomDataStruct;
      #endif
      
      #ifdef OTA_SERVER
          tsCLD_AS_Ota sCLD_ServerOTA;     
          tsOTA_Common sCLD_OTA_ServerCustomDataStruct;
      #endif
  #endif
  
  #if (defined CLD_POLL_CONTROL) && (defined POLL_CONTROL_CLIENT)
      tsCLD_PollControl sPollControlClientCluster;
      tsCLD_PollControlCustomDataStructure sPollControlClientCustomDataStructure;
  #endif
  #if (defined CLD_ELECTRICAL_MEASUREMENT && defined ELECTRICAL_MEASUREMENT_SERVER)
          tsCLD_ElectricalMeasurement sCLD_ElectricalMeasurement;
  #endif
  
  #if (defined CLD_TIME) && (defined TIME_CLIENT)
      tsCLD_Time sTimeClientCluster;
  #endif
  } tsHA_TemperatureSensorDevice;
  
  
  /****************************************************************************/
  /***        Exported Functions                                            ***/
  /****************************************************************************/
  
  PUBLIC teZCL_Status eHA_RegisterTemperatureSensorEndPoint(uint8 u8EndPointIdentifier,
                                                     tfpZCL_ZCLCallBackFunction cbCallBack,
                                                     tsHA_TemperatureSensorDevice *psDeviceInfo);
  
  /****************************************************************************/
  /***        External Variables                                            ***/
  /****************************************************************************/
  
  #if defined __cplusplus
  }
  #endif
  
  /****************************************************************************/
  /***        END OF FILE                                                   ***/
  /****************************************************************************/
  
  #endif /* TEMPERATURE_SENSOR_H */
  