/*
 * COMMON_PROCESS.c
 *
 *  Created on: 2020年7月30日
 *      Author: Seuls
 */
#include PLATFORM_HEADER
#include "stack/include/ember-types.h"
#include "hal/hal.h"
#include "uart_handler.h"
#include "driver/ikk-uart.h"
#include "general/ikk-network.h"
#include "general/ikk-cluster.h"
#include "uart_handler.h"
#include "common_process.h"
#include "general/ikk-opt-tunnel.h"
//join nwk timeout
#define NWK_STEERING_TIMEOUT_MS 				(60 * 1000)


DEVICE_ATTR_ST  sDevice_attr_new = {0};
DEVICE_ATTR_ST  sDevice_attr_last = {0};

static uint8_t sync_first_attr_data = 0;

void Rewite_Attr_Witchout_Report(void)
{
	sync_first_attr_data = 1;
}
static uint8_t Is_Recall_Scense_Cmd(uint8_t ep,uint16_t  Cluster_ID)
{
	ZclReportTableSt zclReportInfo;
	bool status = kZclClusterGetPermitReportInfo(2, Cluster_ID, &zclReportInfo);
	if ((status == true)&&(zclReportInfo.sceneRecallFlg)&&(zclReportInfo.reportEnable == false))
		return true;
	return false;
}
extern void  Process_Device_TypeCallback(uint8_t device_type,uint8_t  device_subtype);

void SWAP_EUI64(uint8_t *ptr);
/****************上电第一次同步数据属性****************************************/
static void First_Synic_air_Attribute_Data(AIR_ATTR_ST *data,uint8_t channel_id)
{
	//开关
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&data->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
			CLUSTER_MASK_SERVER,&data->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	//实时温度
	int16_t  real_temper = 0;
	if(data->real_temperature > 0)
		real_temper = 10*data->real_temperature;
	else
	{
		uint16_t  temp = 65536 - data->real_temperature;
		temp = temp*10;
		real_temper = 65536 - temp;
	}
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	//目标温度
	int16s set_temper = 0;
	set_temper = (data->set_temperature)*10;
	if(channel_id == 1){

		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Target_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	//模式
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&data->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
			CLUSTER_MASK_SERVER,&data->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	//风速
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&data->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Fan_Mode,
			CLUSTER_MASK_SERVER,&data->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	//错误码
	if(channel_id == 1)
	{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
					CLUSTER_MASK_SERVER,&data->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
			CLUSTER_MASK_SERVER,&data->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	//童锁
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		EmberAfStatus status = emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
					CLUSTER_MASK_SERVER,&data->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
			CLUSTER_MASK_SERVER,&data->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	//延时关机时间
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
					CLUSTER_MASK_SERVER,&data->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
			CLUSTER_MASK_SERVER,&data->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	//风向
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Swing_Mode,
					CLUSTER_MASK_SERVER,&data->air_wind_direct,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Swing_Mode,
			CLUSTER_MASK_SERVER,&data->air_wind_direct,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	//屏保时间
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
					CLUSTER_MASK_SERVER,(uint8_t *)&data->screen_save_time,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
			CLUSTER_MASK_SERVER,(uint8_t *)&data->screen_save_time,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	//滤网清洗时间
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,   true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
					CLUSTER_MASK_SERVER,(uint8_t *)&data->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
			CLUSTER_MASK_SERVER,(uint8_t *)&data->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
	}
	//校准温度
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
					CLUSTER_MASK_SERVER,&data->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID, true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
			CLUSTER_MASK_SERVER,&data->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}
	//勿扰模式
	if(channel_id == 1){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
					CLUSTER_MASK_SERVER,&data->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
			CLUSTER_MASK_SERVER,&data->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
}

void First_Synic_FloorHeatingAttribute_Data(FLOOR_HEATING_ATTR *device_attr,uint8_t channel_id)
{
	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
			CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}

	int16_t  real_temper = 0;
	if(device_attr->real_temperature > 0)
		real_temper = 10*device_attr->real_temperature;
	else
	{
		uint16_t  temp = 65536 - device_attr->real_temperature;
		temp = temp*10;
		real_temper = 65536 - temp;
	}
	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}

	int16s set_temper = device_attr->set_temperature*10;
	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Target_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
			CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2)
	{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
					CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
			CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
					CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
			CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
					CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
			CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}

	uint8_t screen_save = device_attr->screen_save_time;
	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
					CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
			CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}

	if(channel_id == 2){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
					CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
			CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
}
void First_Sync_FanAttribute_Data(uint8_t channel_id , FAN_ATTR_ST *device_attr)
{
	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
			CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}

	int16_t  real_temper = 0;
	if(device_attr->real_temperature > 0)
		real_temper = 10*device_attr->real_temperature;
	else
	{
		uint16_t  temp = 65536 - device_attr->real_temperature;
		temp = temp*10;
		real_temper = 65536 - temp;
	}
	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_TEMP_MEASUREMENT_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_TEMP_MEASUREMENT_CLUSTER_ID,ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
			CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
					emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
						CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
			CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Fan_Mode,
			CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3)
	{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
					CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
			CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
					CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
			CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
					CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
			CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
	}

	uint8_t screen_save = device_attr->screen_save_time;
	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
					CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
			CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
					CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
			CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
			CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
			CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
	}

	if(channel_id == 3){
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, false);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
					CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
	else{
		kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
		emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
			CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
	}
}
void AirAttributeChangedReceiveReport(uint8_t channel_id , AIR_ATTR_ST *device_attr)
{
	if(sync_first_attr_data)
	{
		sync_first_attr_data = 0;
		memcpy(&sDevice_attr_last.air_condition,device_attr,sizeof(AIR_ATTR_ST));
		First_Synic_air_Attribute_Data(&sDevice_attr_last.air_condition,channel_id);
		iKonkeAfSelfPrint("####AirAttributeChangedReceiveReport,sync First Data!!\r\n");
	}
	if(!memcmp(&sDevice_attr_last.air_condition,&device_attr,sizeof(AIR_ATTR_ST)))
	{
		iKonkeAfSelfPrint("all same data,return \r\n");
		return;
	}
	/**************************************Z3标准上报**************************************************/
	if(sDevice_attr_last.air_condition.on_off != device_attr->on_off)
	{
		iKonkeAfSelfPrint("on-off current = %d,last = %d\r\n",device_attr->on_off,sDevice_attr_last.air_condition.on_off);
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_ON_OFF_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
				CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
				emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
							CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.on_off = device_attr->on_off;
	}
	if(sDevice_attr_last.air_condition.real_temperature != device_attr->real_temperature)
	{
		int16_t  real_temper = 0;
		if(device_attr->real_temperature > 0)
			real_temper = 10*device_attr->real_temperature;
		else
		{
			uint16_t  temp = 65536 - device_attr->real_temperature;
			temp = temp*10;
			real_temper = 65536 - temp;
		}
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		iKonkeAfSelfPrint("real_temperature current = %d,last = %d\r\n",
				device_attr->real_temperature,sDevice_attr_last.air_condition.real_temperature);
		sDevice_attr_last.air_condition.real_temperature = device_attr->real_temperature;
	}
	if(sDevice_attr_last.air_condition.set_temperature != device_attr->set_temperature)
	{
		int16s set_temper = 0;
		set_temper = (device_attr->set_temperature)*10;
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_THERMOSTAT_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Target_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		iKonkeAfSelfPrint("set_temperature current = %d,last = %d\r\n",
						device_attr->set_temperature,sDevice_attr_last.air_condition.set_temperature);
		sDevice_attr_last.air_condition.set_temperature = device_attr->set_temperature;
	}
	if(sDevice_attr_last.air_condition.system_type != device_attr->system_type)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_THERMOSTAT_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false ,false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
				CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		iKonkeAfSelfPrint("system_type current = %d,last = %d\r\n",
								device_attr->system_type,sDevice_attr_last.air_condition.system_type);
		sDevice_attr_last.air_condition.system_type = device_attr->system_type;
	}
	if(sDevice_attr_last.air_condition.wind_speed != device_attr->wind_speed)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Fan_Mode,
				CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID,  true, false, true, false);
						emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
									CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		iKonkeAfSelfPrint("wind_speed current = %d,last = %d\r\n",
										device_attr->wind_speed,sDevice_attr_last.air_condition.wind_speed);
		sDevice_attr_last.air_condition.wind_speed = device_attr->wind_speed;
	}
	if(sDevice_attr_last.air_condition.error != device_attr->error)
	{
		if(channel_id == g_sDevice_Info.Device_Type)
		{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
						CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
				CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.error = device_attr->error;
	}

	if(sDevice_attr_last.air_condition.lock_flage != device_attr->lock_flage)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			EmberAfStatus status = emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
						CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
			iKonkeAfSelfPrint("write result =0x%x\r\n",status);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
				CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.lock_flage = device_attr->lock_flage;
	}
	if(sDevice_attr_last.air_condition.power_off_time != device_attr->power_off_time)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
						CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
				CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.power_off_time = device_attr->power_off_time;
	}
	if(sDevice_attr_last.air_condition.air_wind_direct != device_attr->air_wind_direct)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Swing_Mode,
						CLUSTER_MASK_SERVER,&device_attr->air_wind_direct,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Swing_Mode,
				CLUSTER_MASK_SERVER,&device_attr->air_wind_direct,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.air_wind_direct = device_attr->air_wind_direct;
	}
	if(sDevice_attr_last.air_condition.screen_save_time != device_attr->screen_save_time)
	{
		uint8_t screen_save = device_attr->screen_save_time;
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
						CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
				CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.screen_save_time = device_attr->screen_save_time;
	}
	if(sDevice_attr_last.air_condition.filter_wash_time != device_attr->filter_wash_time)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
						CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
				CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.filter_wash_time = device_attr->filter_wash_time;
	}
	if(sDevice_attr_last.air_condition.correct_temperature != device_attr->correct_temperature)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
				CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.correct_temperature = device_attr->correct_temperature;
	}
	if(sDevice_attr_last.air_condition.no_disturb_mode != device_attr->no_disturb_mode)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
						CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
				CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.air_condition.no_disturb_mode = device_attr->no_disturb_mode;
	}
	if(sDevice_attr_last.air_condition.air_brand != device_attr->air_brand)
	{
		sDevice_attr_last.air_condition.air_brand = device_attr->air_brand;
	}
	if(sDevice_attr_last.air_condition.no_disturb_mode != device_attr->no_disturb_mode)
	{
		sDevice_attr_last.air_condition.air_type = device_attr->air_type;
	}
	print_all_attr_vaule(channel_id);
}

void FloorHeatingAttributeChangedReceiveReport(uint8_t channel_id , FLOOR_HEATING_ATTR *device_attr)
{
	if(sync_first_attr_data)
	{
		sync_first_attr_data = 0;
		memcpy(&sDevice_attr_last.floor_heating,device_attr,sizeof(FLOOR_HEATING_ATTR));
		First_Synic_FloorHeatingAttribute_Data(&sDevice_attr_last.floor_heating,channel_id);
		iKonkeAfSelfPrint("####FloorHeatingAttributeChangedReceiveReport,sync First Data!!\r\n");
	}
	if(!memcmp(&sDevice_attr_last.floor_heating,&device_attr,sizeof(FLOOR_HEATING_ATTR)))
	{
		iKonkeAfSelfPrint("####FloorHeatingAttributeChangedReceiveReport,all same data,return \r\n");
		return;
	}
	/**************************************Z3标准上报**************************************************/
	if(sDevice_attr_last.floor_heating.on_off != device_attr->on_off)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_ON_OFF_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
					CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
				CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
						emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
								CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.on_off = device_attr->on_off;
	}
	if(sDevice_attr_last.floor_heating.real_temperature != device_attr->real_temperature)
	{
		int16_t  real_temper = 0;
		if(device_attr->real_temperature > 0)
			real_temper = 10*device_attr->real_temperature;
		else
		{
			uint16_t  temp = 65536 - device_attr->real_temperature;
			temp = temp*10;
			real_temper = 65536 - temp;
		}
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		iKonkeAfSelfPrint("real_temperature current = %d,last = %d\r\n",
				device_attr->real_temperature,sDevice_attr_last.floor_heating.real_temperature);
		sDevice_attr_last.floor_heating.real_temperature = device_attr->real_temperature;
	}
	if(sDevice_attr_last.floor_heating.set_temperature != device_attr->set_temperature)
	{
		int16s set_temper = device_attr->set_temperature*10;
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_THERMOSTAT_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Target_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&set_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.set_temperature = device_attr->set_temperature;
	}
	if(sDevice_attr_last.floor_heating.system_type != device_attr->system_type)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_THERMOSTAT_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
				CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_SYSTEM_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.system_type = device_attr->system_type;
	}
	if(sDevice_attr_last.floor_heating.error != device_attr->error)
	{
		if(channel_id == g_sDevice_Info.Device_Type)
		{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
						CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
				CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.error = device_attr->error;
	}

	if(sDevice_attr_last.floor_heating.lock_flage != device_attr->lock_flage)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
						CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
				CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.lock_flage = device_attr->lock_flage;
	}
	if(sDevice_attr_last.floor_heating.power_off_time != device_attr->power_off_time)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
						CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
				CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.power_off_time = device_attr->power_off_time;
	}
	if(sDevice_attr_last.floor_heating.screen_save_time != device_attr->screen_save_time)
	{
		uint8_t screen_save = device_attr->screen_save_time;
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
						CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
				CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.screen_save_time = device_attr->screen_save_time;
	}
	if(sDevice_attr_last.floor_heating.correct_temperature != device_attr->correct_temperature)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_THERMOSTAT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_THERMOSTAT_CLUSTER_ID,ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.correct_temperature = device_attr->correct_temperature;
	}
	if(sDevice_attr_last.floor_heating.no_disturb_mode != device_attr->no_disturb_mode)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
						CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
				CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.floor_heating.no_disturb_mode = device_attr->no_disturb_mode;
	}
	print_all_attr_vaule(channel_id);
}
void FanAttributeChangedReceiveReport(uint8_t channel_id , FAN_ATTR_ST *device_attr)
{
	if(sync_first_attr_data)
	{
		sync_first_attr_data = 0;
		memcpy(&sDevice_attr_last.fan,device_attr,sizeof(FAN_ATTR_ST));
		First_Sync_FanAttribute_Data(channel_id,&sDevice_attr_last.fan);
		iKonkeAfSelfPrint("####FanAttributeChangedReceiveReport,sync First Data!!\r\n");
	}
	if(!memcmp(&sDevice_attr_last.fan,&device_attr,sizeof(FAN_ATTR_ST)))
	{
		iKonkeAfSelfPrint("####FanAttributeChangedReceiveReport,all same data,return \r\n");
		return;
	}
	/**************************************Z3标准上报**************************************************/
	if(sDevice_attr_last.fan.on_off != device_attr->on_off)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			if(Is_Recall_Scense_Cmd(channel_id,ZCL_ON_OFF_CLUSTER_ID))
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, true, false, false);
			else
				kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_ON_OFF,
				CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
			kZclClusterSetPermitReportInfo(channel_id, ZCL_ON_OFF_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_ON_OFF_CLUSTER_ID,ZCL_ON_OFF_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->on_off,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.on_off = device_attr->on_off;
	}
	if(sDevice_attr_last.fan.real_temperature != device_attr->real_temperature)
	{
		int16_t  real_temper = 0;
		if(device_attr->real_temperature > 0)
			real_temper = 10*device_attr->real_temperature;
		else
		{
			uint16_t  temp = 65536 - device_attr->real_temperature;
			temp = temp*10;
			real_temper = 65536 - temp;
		}
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_TEMP_MEASUREMENT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_TEMP_MEASUREMENT_CLUSTER_ID,ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Current_Temperature,
				CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
			kZclClusterSetPermitReportInfo(channel_id, ZCL_TEMP_MEASUREMENT_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_TEMP_MEASUREMENT_CLUSTER_ID,ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,(uint8_t *)&real_temper,ZCL_INT16S_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.real_temperature = device_attr->real_temperature;
	}

	if(sDevice_attr_last.fan.system_type != device_attr->system_type)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
						emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
							CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_System_Mode,
				CLUSTER_MASK_SERVER,&device_attr->system_type,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.system_type = device_attr->system_type;
	}
	if(sDevice_attr_last.fan.wind_speed != device_attr->wind_speed)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
						CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Fan_Mode,
				CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);

			kZclClusterSetPermitReportInfo(channel_id, ZCL_FAN_CONTROL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_FAN_CONTROL_CLUSTER_ID,ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID,
									CLUSTER_MASK_SERVER,&device_attr->wind_speed,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.wind_speed = device_attr->wind_speed;
	}
	if(sDevice_attr_last.fan.error != device_attr->error)
	{
		if(channel_id == g_sDevice_Info.Device_Type)
		{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
						CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Error_Code,
				CLUSTER_MASK_SERVER,&device_attr->error,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.error = device_attr->error;
	}

	if(sDevice_attr_last.fan.lock_flage != device_attr->lock_flage)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
						CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Child_Lock,
				CLUSTER_MASK_SERVER,&device_attr->lock_flage,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.lock_flage = device_attr->lock_flage;
	}
	if(sDevice_attr_last.fan.power_off_time != device_attr->power_off_time)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
						CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Delay_Off,
				CLUSTER_MASK_SERVER,&device_attr->power_off_time,ZCL_INT8U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.power_off_time = device_attr->power_off_time;
	}
	if(sDevice_attr_last.fan.screen_save_time != device_attr->screen_save_time)
	{
		uint8_t screen_save = device_attr->screen_save_time;
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
						CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Screen_Saver_Time,
				CLUSTER_MASK_SERVER,&screen_save,ZCL_ENUM8_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.screen_save_time = device_attr->screen_save_time;
	}
	if(sDevice_attr_last.fan.filter_wash_time != device_attr->filter_wash_time)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
						CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Filter_Clean_Time,
				CLUSTER_MASK_SERVER,(uint8_t *)&device_attr->filter_wash_time,ZCL_INT16U_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.filter_wash_time = device_attr->filter_wash_time;
	}
	if(sDevice_attr_last.fan.correct_temperature != device_attr->correct_temperature)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
				CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, false, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_Calibration_Temperature,
				CLUSTER_MASK_SERVER,&device_attr->correct_temperature,ZCL_INT8S_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.correct_temperature = device_attr->correct_temperature;
	}
	if(sDevice_attr_last.fan.no_disturb_mode != device_attr->no_disturb_mode)
	{
		if(channel_id == g_sDevice_Info.Device_Type){
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, false);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
						CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		else{
			kZclClusterSetPermitReportInfo(channel_id, ZCL_OPT_TUNNEL_CLUSTER_ID,  true, false, true, true);
			emberAfWriteAttribute(channel_id,ZCL_OPT_TUNNEL_CLUSTER_ID,FCC0_ATTR_No_Disturb_Mode,
				CLUSTER_MASK_SERVER,&device_attr->no_disturb_mode,ZCL_BOOLEAN_ATTRIBUTE_TYPE);
		}
		sDevice_attr_last.fan.no_disturb_mode = device_attr->no_disturb_mode;
	}
	print_all_attr_vaule(channel_id);
}
extern void JoinCompleteCallback(NwkJoinCompltEnum nwkcomplt );


UMsgNodeSt 		g_sMsgNode  = {0};
DATA_FIELDED 	g_sData_Field = {0};

void Command_Process_Handler(DATA_FIELDED *Data_Field)
{
	iKonkeAfSelfPrint("###############Command_Process_Handler:\r\n");
	iKonkeAfSelfPrintBuffer((uint8_t*)Data_Field, Data_Field->ucData_Field_Len+1, true);
	uint8_t channel_id = Data_Field->ucChannel_ID ;
	uint16_t opcpde = BUILD_UINT16(HIGH_UINT16(Data_Field->uiOpcode),LOW_UINT16(Data_Field->uiOpcode));
	iKonkeAfSelfPrint("channel_id = %d,opcpde = %2x\r\n",channel_id,opcpde);
	switch(opcpde)
	{
		case CMD_NET_REQUEST:
		{
			uint8_t Net_cmd = Data_Field->uiPaload[0];
			if(Net_cmd)						//入网
			{
				kNwkFactoryReset(false);
				//steering timeout can be set
				iKonkeAfSelfPrint("#####Start Steering\r\n");
				kNwkJoiningStart(NWK_STEERING_TIMEOUT_MS, JoinCompleteCallback);
			}
			else
			{
				bool status = false;
				if (kNwkGetCurrentStatus() == ENS_ONLINE || kNwkGetCurrentStatus() == ENS_OFFLINE){
					status = true;
				}
				kNwkFactoryReset(status);
				iKonkeAfSelfPrint("Leave Network:\r\n");
			}
			Data_Field->uiPaload[1] = Data_Field->uiPaload[0];
			Data_Field->ucData_Field_Len+=1;
		}
			break;
		case CMD_NET_QUERY:
		{
			iKonkeAfSelfPrint("Operation Join Network:\r\n");
			if((kNwkGetCurrentStatus() == ENS_ONLINE)||(kNwkGetCurrentStatus() == ENS_OFFLINE))
				Data_Field->uiPaload[1] = 1;
			else
				Data_Field->uiPaload[1] = 0;

			Data_Field->ucData_Field_Len+=1;
		}
			break;
		case CMD_MCU_VERSION_QUERY:
		{
			iKonkeAfSelfPrint("Read MCU Version:\r\n");
			EmberEUI64 tmpEui64 = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
			Data_Field->uiPaload[1] = Read_Zigbee_Version();
			if(kNwkGetCurrentStatus() == ENS_LEAVED)
				Data_Field->uiPaload[2] = 0;
			else if(kNwkGetCurrentStatus() == ENS_ONLINE)
				Data_Field->uiPaload[2] = 1;
			else
				Data_Field->uiPaload[2] = 2;
			memcpy(&tmpEui64,&emberGetEui64(),sizeof(EmberEUI64) );
			SWAP_EUI64((uint8_t *)&tmpEui64);
			memcpy(&Data_Field->uiPaload[3],&tmpEui64,sizeof(EmberEUI64) );
			iKonkeAfSelfPrint("MAC =\r\n");
			iKonkeAfSelfPrintBuffer((uint8_t *)tmpEui64,8, true);
			Data_Field->ucData_Field_Len+=(2+8);
		}
			break;
		case OPCODE_GENERAL_MCU_DATA_QUERY:
		{
			g_sDevice_Info.mcu_software_version = Data_Field->uiPaload[1];
			g_sDevice_Info.mcu_hardware_version = Data_Field->uiPaload[2];
			g_sDevice_Info.Device_Type          = Data_Field->uiPaload[3];
			g_sDevice_Info.Device_subType       = Data_Field->uiPaload[4];
			//处理设备类型回调函数
			Process_Device_TypeCallback(g_sDevice_Info.Device_Type,g_sDevice_Info.Device_subType);

			if(channel_id == 1)
				AirAttributeChangedReceiveReport(channel_id,(AIR_ATTR_ST *)&Data_Field->uiPaload[5]);
			else if(channel_id == 2)
				FloorHeatingAttributeChangedReceiveReport(channel_id,(FLOOR_HEATING_ATTR *)&Data_Field->uiPaload[5]);
			else if(channel_id == 3)
				FanAttributeChangedReceiveReport(channel_id,(FAN_ATTR_ST *)&Data_Field->uiPaload[5]);
		}
			break;
		case OPCODE_GENERAL_REPORT_STATUS:
		{
			static  uint32_t  count = 0;
			iKonkeAfSelfPrint("####Test ,Receive Updata msg count =%d\r\n",count++);
			if(channel_id == 1)
				AirAttributeChangedReceiveReport(channel_id,(AIR_ATTR_ST *)Data_Field->uiPaload);
			else if(channel_id == 2)
				FloorHeatingAttributeChangedReceiveReport(channel_id,(FLOOR_HEATING_ATTR *)Data_Field->uiPaload);
			else if(channel_id == 3)
				FanAttributeChangedReceiveReport(channel_id,(FAN_ATTR_ST *)Data_Field->uiPaload);
			Data_Field->ucData_Field_Len = 4;
		}
			break;
		case OPCODE_GENERAL_LCD_OFF:
		{
			iKonkeAfSelfPrint("proximity control msg res\r\n");
			Data_Field->uiPaload[1] = Data_Field->uiPaload[0];
			Data_Field->ucData_Field_Len+=1;
		}
			break;
		case OPCODE_GENERAL_PROXIMITY_TRAGGER_REPORT:
		{
			uint8_t  res = 0;
			if(kNwkGetCurrentStatus() == ENS_ONLINE)
			{
				kOptTunnelWriteAttributeToGateway(0,0x34,&res,1);
			}
			iKonkeAfSelfPrint("report proximity tragger msg\r\n");
			Data_Field->uiPaload[1] = Data_Field->uiPaload[0];
			Data_Field->ucData_Field_Len+=1;
		}
			break;
		default:
			break;
	}
	Data_Field->uiPaload[0] = 0;
}

void Control_MCU(UMsgNodeSt *uMsgNode,uint8_t channel_id,CMD_TYPE Cmd_Type,uint16_t Data )
{
	uint8_t data[3]= {0};
	switch(Cmd_Type)
	{
		case CMD_ERROR_CODE:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_ERROR_CODE,data,1);
			break;
		}
		case CMD_CHILD_LOCK:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_CHILD_LOCK,data,1);
			break;
		}
		case CMD_DELAY_OFF:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_DELAY_OFF_TIME,data,1);
			break;
		}
		case CMD_WIND_SPEED:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_WIND_SPEED,data,1);
			break;
		}
		case CMD_WIND_DIRECT:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_SWING_MODE,data,1);
			break;
		}
		case CMD_SCREEN_SAVE:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_SCREEN_SAVE_TIME,data,1);
			break;
		}
		case CMD_FILTER_CLEAN:
		{
			data[0] = Data>>8;
			data[1] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_FILTER_CLEANING_TIME,data,2);
			break;
		}
		case CMD_SYSTEM:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_OPERATION_MODE,data,1);
			break;
		}
		case CMD_CURRENT_TEMPER:
		{
			data[0] = Data>>8;
			data[1] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_CURRENT_REAL_TEMPER,data,2);
			break;
		}
		case CMD_TARGET_TEMPER:
		{
			data[0] = Data>>8;
			data[1] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_TEMPERATURE,data,2);
			break;
		}
		case CMD_CALI_TEMPER:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_TEMPER_CALIBRATION,data,1);
			break;
		}
		case CMD_ON_OFF:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SWITCH,data,1);
			break;
		}
		case CMD_NO_DISTURB_MODE:
		{
			data[0] = Data&0xff;
			CMD_Control_Emplement(uMsgNode,channel_id,OPCODE_GENERAL_SET_NO_DISTURB_MODE,data,1);
			break;
		}
	}
}
void Push_Netwaork_Status(uint8_t network_status)
{
	uint8_t net_status = network_status;
	CMD_Control_Emplement(&g_sMsgNode,0,CMD_NET_NOTIFY,&net_status,1);
}
void Query_MCU_Info(void)
{
	uint8_t data = 0;
	CMD_Control_Emplement(&g_sMsgNode,g_sDevice_Info.Device_Type,OPCODE_GENERAL_MCU_DATA_QUERY,&data,1);
}

void  Binging_Info_Notify(uint8_t bind_or_unbind,uint8_t device_type)
{
	uint8_t data[2] = 0;
	data[0] = bind_or_unbind;
	data[1] = device_type;
	CMD_Control_Emplement(&g_sMsgNode,g_sDevice_Info.Device_Type,OPCODE_GENERAL_BING_DEVICE,data,2);
}
void Set_No_Disturb_Mode(uint8_t channel_id,uint8_t mode)
{
	Control_MCU(&g_sMsgNode,channel_id,CMD_NO_DISTURB_MODE,mode);
}
void Set_LCD_OFF(void)
{
	uint8_t off = 0;
	CMD_Control_Emplement(&g_sMsgNode,0,OPCODE_GENERAL_LCD_OFF,&off,1);
}
void Set_OTA_CMD(uint8_t OTA_Status)
{
	uint8_t status = OTA_Status;
	CMD_Control_Emplement(&g_sMsgNode,0,OPCODE_GENERAL_OTA_CONTROL,&OTA_Status,1);
}

void 	CMD_Control_Emplement(UMsgNodeSt *uMsgNode,uint8_t channel_id,uint16_t Opcode,uint8_t *Pload,uint8_t Pload_Len)
{
	DATA_FIELDED 	sData_Field = {0};
	sData_Field.ucData_Field_Len = Pload_Len+3;
	sData_Field.ucChannel_ID = channel_id;
	sData_Field.uiOpcode = Swap_16U_Data(Opcode);
	memcpy(sData_Field.uiPaload,Pload,Pload_Len);
	Uart_Send(uMsgNode,&sData_Field);
}
void  Ack(UMsgNodeSt *uMsgNode)
{
	uMsgNode->buffer[LENGTH_INDEX+1] = 0;
	Uart_Resp(uMsgNode,uMsgNode->buffer[SEQENCE_INDEX],(DATA_FIELDED *)&uMsgNode->buffer[SEQENCE_INDEX+1]);
}
uint8_t uart_send_data(UMsgNodeSt *uMsgNode,uint8_t ucControl_Field,uint8_t uiSeq, DATA_FIELDED *dataField,bool isGetResult)
{
	static  uint8_t  ucLocal_Seq =  0;

	uint8_t i = 0;
	uMsgNode->buffer[i++]	= MSG_HEAD_1;
	uMsgNode->buffer[i++]  	= MSG_HEAD_2;
	uMsgNode->buffer[i++]	= dataField->ucData_Field_Len+3;
	uMsgNode->buffer[i++]	= ucControl_Field;
	if(uiSeq == 0xff)
	{
		if(ucLocal_Seq == 0xff)
			ucLocal_Seq = 0;
		uMsgNode->buffer[i++]	= ucLocal_Seq++;
	}
	else
		uMsgNode->buffer[i++]	= uiSeq;

	memcpy(&uMsgNode->buffer[i], (uint8_t *)dataField, dataField->ucData_Field_Len+1);
	i += (dataField->ucData_Field_Len+1);


	uint16_t crc = check_sum(&uMsgNode->buffer[LENGTH_INDEX+1], dataField->ucData_Field_Len+3);
	uMsgNode->buffer[i++] = HIGH_UINT16(crc);
	uMsgNode->buffer[i++] = LOW_UINT16(crc);
	uMsgNode->length = i;

	// setting for matcher content.

	uMsgNode->matcher[0] = uMsgNode->buffer[SEQENCE_INDEX];						//seq
	uMsgNode->matcher_offset = 4;
	uMsgNode->matcher_n = 1;
	if(ucControl_Field &0x10)
		uMsgNode->sent_try = 2;
	else
		uMsgNode->sent_try = 0;
	if(isGetResult)
		uMsgNode->ack = uMsgNode->buffer;
	else
		uMsgNode->ack = NULL;
	uMsgNode->ack_length = 0;
	return kUartMsgSent(uMsgNode ,0);
}
uint16_t check_sum( uint8_t* msg, uint8_t len)
{
	uint16_t crc = 0xFFFF;
	uint16_t i, j = 0;

    for (i = 0; i < len; i++)
    {
        for (j = 0; j < 8; j++)
        {
        	uint8_t c15 = (uint8_t)((crc >> 15 & 1) == 1);
        	uint8_t bit = (uint8_t)((msg[i] >> (7 - j) & 1) == 1);

            crc <<= 1;

            if (c15 ^ bit)
            {
                crc ^= 0x1021;
            }
        }
    }
    return crc;
}
bool MsgCRC16(uint8_t *pdat, int length )
{
	uint16_t crc_data = 0;
	uint8_t  CRC_H = 0;
	uint8_t  CRC_L = 0;

	if((NULL == pdat) || (length < 9)){
		return false;
	}
	crc_data = check_sum(&pdat[3], pdat[2]);
	CRC_H = (crc_data>>8) & 0xff;
	CRC_L = crc_data & 0xff;
	if((pdat[length - 1] == CRC_L) && (pdat[length - 2]== CRC_H))
	{
		return true;
	}

	return false;
}
uint16_t Swap_16U_Data(uint16_t data)
{
	uint16_t retvalue;
	uint8_t high_byte = data>>8;
	uint8_t low_byte  = data&0xff;
	retvalue = (high_byte) | (low_byte<<8);
	return retvalue;
}
void SWAP_EUI64(uint8_t *ptr)
{
	uint8_t temp;
	for(uint8_t i = 0;i<4;i++)
	{
		temp     = ptr[7-i];
		ptr[7-i] = ptr[i];
		ptr[i]   = temp;
	}
}
