#ifndef __BLV_485_DEV_FRESHAIRFUN_H
#define __BLV_485_DEV_FRESHAIRFUN_H
#include "BLV_Dev_Action.h"
#include "BLV_All_Dev_Init.h"

#define FRESHAIR_ON_OFF_FUNCTION				0x01	//开关机功能
#define FRESHAIR_WIND_VELOCITY_FUNCTION			0x04	//风速功能
#define FRESHAIR_READ_REGISTER_FUNCTION			0x06	//读寄存器功能
#define FRESHAIR_WRITE_REGISTER_FUNCTION		0x07	//写寄存器功能

#define FRESHAIR_ON								0x01	//新风开机
#define FRESHAIR_OFF							0x00	//新风关机

/* 新风没有自动风 */
#define WIND_VELOCITY_HIGH						0x01	//风速高速
#define WIND_VELOCITY_MID						0x02	//风速中速
#define WIND_VELOCITY_LOW						0x03	//风速低速

#define REGISTER0								0x00	//寄存器0
#define REGISTER1								0x01	//寄存器1
#define REGISTER2								0x02	//寄存器2
#define REGISTER3								0x03	//寄存器3
#define REGISTER4								0x04	//寄存器4
#define REGISTER5								0x05	//寄存器5
#define REGISTER6								0x06	//寄存器6
#define REGISTER7								0x07	//寄存器7
#define REGISTER8								0x08	//寄存器8
#define REGISTER9								0x09	//寄存器9
#define REGISTER10								0x0A	//寄存器10

typedef struct 
{
	uint8_t on_off:			2;	//开关机标志或计数
	uint8_t wind_velocity:	2;	//风速标志或计数
	uint8_t read_register:	2;	//读寄存器标志或计数
	uint8_t write_register:	2;	//写寄存器标志或计数
}__attribute__ ((__packed__))FreshAir_Ctrl_Struct;	//485新风控制结构体

typedef struct 
{
	uint8_t on_off;	//开关机
	uint8_t wind_velocity;	//风速
	uint8_t indoor_oc;	//室内温度
	uint8_t read_register;	//要读寄存器的起始地址
	uint8_t write_register;	//要写寄存器的起始地址
	uint8_t register_num;	//要读或写的寄存器数量
	uint8_t write_data;	//要写入寄存器的数据
}__attribute__ ((__packed__))FreshAir_Content_Struct;	//485新风控制内容结构体

typedef struct 
{
	BLV_COMM_RECORD_G comm_record;	//通讯记录
	FreshAir_Ctrl_Struct ctrl_flag;	//新风控制标志位
	FreshAir_Ctrl_Struct ctrl_cnt;	//新风控制次数
	FreshAir_Content_Struct ctrl_content;	//新风控制内容
	FreshAir_Content_Struct ctrl_content_last;	//新风上一次控制内容
	FreshAir_Content_Struct new_state;	//新风当前状态
	FreshAir_Content_Struct last_state;	
	uint8_t DevSendCnt;	//发送次数
	uint8_t DevOffline;	//设备离线状态
	uint8_t DevOfflineLast;	//上一次设备离线状态
	uint32_t inquire_tick;	//询问时间戳
}__attribute__ ((__packed__))RS485_FreshAir_INFO;	//485新风设备私有属性

void BLW_RS485_FreshAirFun_Init(uint16_t len, uint8_t *data);	//初始化新风设备数据
void BLW_RS485_FreshAirFun_Logic_Init(LOGICFILE_DEVICE_INFO *dev_info,uint8_t *data,uint16_t data_len);	//配置文件初始化新风设备数据
#endif
