#ifndef ______00IKONKE_COMMON_PROCESS_H_____
#define ______00IKONKE_COMMON_PROCESS_H_____

#include "app/framework/include/af.h"
#include "././00ikonke-app/general/ikk-debug.h"
#include "./general/ikk-module-def.h"
#define 	BUILD_UINT16(lowByte, highByte) \
          	  ((uint16_t)(((lowByte) & 0x00FF) + (((highByte) & 0x00FF) << 8)))

#define 	HIGH_UINT16(a) (((a) >> 8) & 0xFF)
#define 	LOW_UINT16(a) ((a) & 0xFF)

#define 	FCC0_ATTR_Error_Code							0X1000
#define 	FCC0_ATTR_Child_Lock							0X1001
#define 	FCC0_ATTR_Delay_Off								0X1002
#define 	FCC0_ATTR_Swing_Mode							0X1003
#define 	FCC0_ATTR_Screen_Saver_Time						0X1004
#define 	FCC0_ATTR_Filter_Clean_Time						0X1005
#define 	FCC0_ATTR_System_Mode							0X1006
#define 	FCC0_ATTR_Target_Temperature					0X1007
#define 	FCC0_ATTR_Current_Temperature					0X1008
#define 	FCC0_ATTR_Calibration_Temperature				0X1009
#define 	FCC0_ATTR_Fan_Mode								0X100A
#define 	FCC0_ATTR_ON_OFF								0X100B
#define 	FCC0_ATTR_No_Disturb_Mode						0X100C




#define 	Device_Type_Air_Condition         	1
#define 	Device_Type_Floor_Heating         	2
#define 	Device_Type_Fan					  	3


EmberStatus Write_Attr(bool Report,uint8_t ep,uint16_t cluster,uint16_t attr, uint8_t* dataPtr,EmberAfAttributeType datatype);

#define Write_OnOff_Attr(x,ep,data)    			Write_Attr(x,ep,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,data,ZCL_BOOLEAN_ATTRIBUTE_TYPE)
#define Write_SystemMode_Attr(x,ep,data)    	Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,data,ZCL_ENUM8_ATTRIBUTE_TYPE)
#define Write_TargetTemp_Attr(x,ep,data)    	Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,(uint8_t*)data,ZCL_INT16S_ATTRIBUTE_TYPE)
#define Write_CurrentTemp_Attr(x,ep,data)   	Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,(uint8_t*)data,ZCL_INT16S_ATTRIBUTE_TYPE)
#define Write_CalibrationTemp_Attr(x,ep,data)   Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID,data,ZCL_INT8S_ATTRIBUTE_TYPE)
#define Write_FanSpeed_Attr(x,ep,data)      	Write_Attr(x,ep,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,data,ZCL_ENUM8_ATTRIBUTE_TYPE)
//#define Write_ERROR_CODE_Attr(x,ep,data)   		Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,data,ZCL_INT8U_ATTRIBUTE_TYPE)

#define Write_Child_Lock_Attr(x,ep,data)   		Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,data,ZCL_BOOLEAN_ATTRIBUTE_TYPE)
#define Write_Delay_off_Attr(x,ep,data)   		Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,data,ZCL_INT8U_ATTRIBUTE_TYPE)
#define Write_Wind_Direct_Attr(x,ep,data)   	Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Swing_Mode,data,ZCL_ENUM8_ATTRIBUTE_TYPE)
#define Write_Screen_Save_Time_Attr(x,ep,data)  Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,data,ZCL_ENUM8_ATTRIBUTE_TYPE)
#define Write_Filter_Clean_Time_Attr(x,ep,data) Write_Attr(x,ep,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,data,ZCL_INT16U_ATTRIBUTE_TYPE)

#define Write_MaxTemp_Attr(x,ep,data)    		Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_MAX_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID,(uint8_t*)data,ZCL_INT16S_ATTRIBUTE_TYPE)
#define Write_MinTemp_Attr(x,ep,data)    		Write_Attr(x,ep,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_MIN_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID,(uint8_t*)data,ZCL_INT16S_ATTRIBUTE_TYPE)


typedef struct
{
	EmberEUI64  addr1,addr2;
	uint8_t     bind_flag1,bind_flag2;
}BIND_Info_Store;
typedef struct
{
	uint8_t  Device_Type;
	uint8_t  Device_subType;
	uint8_t  is_support_winddirect;
	uint8_t  Binding_Device_SrcEP[2];
	uint8_t  mcu_software_version;
	uint8_t  mcu_hardware_version;
}DEVICVE_INFO_ST;

extern DEVICVE_INFO_ST g_sDevice_Info;
uint8_t Read_Zigbee_Version(void);
kk_err_t PrivateClusterHandler(EmberAfClusterCommand* cmd);
BIND_Info_Store kGetBindConfigInfo(void);
void Reset_Binding_Token(void);
/**********************common interface*******************************/
uint8_t Get_Device_Endpoint(void);
uint8_t  Get_Binding_Device_EP(void);
void print_all_attr_vaule(uint8_t ep);
#endif /* 00IKONKE_APP_BL55072A_H_ */
