#ifndef _BLV_485_DEV_XIAOBAOFUN_H_
#define _BLV_485_DEV_XIAOBAOFUN_H_

#include "BLV_485_Protocol.h"
#include "BLV_All_Dev_Init.h"

#define DEV_XiaoBao_Type		0x13		//用于设备列表中的设备类型
#define XiaoBao_BUFF_Size			25    //一包数据最大长度
#define XiaoBao_BUFF_NUM      3     //可缓存的包数量

#define XIAOBAO_CONTROL_TONE_PAIR_START      0X00    //进入无线配对模式
#define XIAOBAO_CONTROL_TONE_PAIR_SUCCESS    0X01    //无线配对模式成功
#define XIAOBAO_CONTROL_TONE_PAIR_FAIL       0X02    //无线配对模式失败

/*小宝控制数据的场景类型*/
#define XIAOBAO_SCENE_TYPE     0X00       //场景类型
/*场景地址编码*/
#define XIAOBAO_SCENE_RECEPTION   			0x01    //会客模式（白）
#define XIAOBAO_SCENE_SLEEP       			0x02    //睡眠模式（黑）
#define XIAOBAO_SCENE_GENERAL_CONTROL   0x03    //总控
#define XIAOBAO_SCENE_LEISURE    				0x04    //休闲（灰）
#define XIAOBAO_SCENE_BUSINESS    		 0x05    //商务
#define XIAOBAO_SCENE_READ    		     0x06    //阅读
#define XIAOBAO_SCENE_WELCOME    		   0x07    //欢迎
#define XIAOBAO_SCENE_ROMANTIC    		 0x08    //浪漫
#define XIAOBAO_SCENE_WATCHING    		 0x09    //观影
#define XIAOBAO_SCENE_WARM    		     0x0A    //温馨
#define XIAOBAO_SCENE_ATMOSPHERE    	 0x0B    //氛围
#define XIAOBAO_SCENE_BRIGHT    	     0x0C    //明亮
#define XIAOBAO_SCENE_PARLOUR_BRIGHT   0x0D    //客厅明亮
#define XIAOBAO_SCENE_ALL_LIGHTS       0x0E    //所有灯
#define XIAOBAO_SCENE_SOFT             0x0F    //柔和
#define XIAOBAO_SCENE_WAKE_UP          0x10    //起夜
#define XIAOBAO_SCENE_GET_UP           0x11    //起床
#define XIAOBAO_SCENE_BATHROOM         0x12    //卫浴
#define XIAOBAO_SCENE_TOILET           0x13    //如厕
#define XIAOBAO_SCENE_WASH_UP          0x14    //洗漱
#define XIAOBAO_SCENE_TV               0x15    //电视
#define XIAOBAO_SCENE_MEETING          0x16    //会议
#define XIAOBAO_SCENE_PLAYLOL          0x16    //电竞
#define XIAOBAO_SCENE_Hypnotic         0x17    //助眠

/*小宝控制数据的继电器类型*/
#define XIAOBAO_RELAY_TYPE     0X01       //继电器类型
/*继电器地址编码*/
#define XIAOBAO_RELAY_BATHROOM_LIGHT  		0x01    //卫浴灯
#define XIAOBAO_RELAY_SHOWERSROOM_LIGHT  	0x02    //浴室灯
#define XIAOBAO_RELAY_MIRROR_LIGHT  		  0x03    //镜前灯
#define XIAOBAO_RELAY_EXHAUST_FAN			  	0x04    //排气扇
#define XIAOBAO_RELAY_CORRIDOR_LIGHT  		0x05    //廊灯
#define XIAOBAO_RELAY_BAR_LIGHT  		      0x06    //吧台灯
#define XIAOBAO_RELAY_TV_LIGHT  		      0x07    //电视灯
#define XIAOBAO_RELAY_LEFT_BEDSIDE_LIGHT  0x08    //左床头灯，左阅读灯
#define XIAOBAO_RELAY_RIGHT_BEDSIDE_LIGHT 0x09    //右床头灯，右阅读灯
#define XIAOBAO_RELAY_DESK_LIGHT  		    0x0A    //书桌灯
#define XIAOBAO_RELAY_PARLOUR_LIGHT  		  0x0B    //客厅灯
#define XIAOBAO_RELAY_PENDANT_LIGHT  		  0x0C    //吊灯
#define XIAOBAO_RELAY_MASTER_LIGHT  		  0x0D    //主灯
#define XIAOBAO_RELAY_TOP_LIGHT  		      0x0E    //顶灯
#define XIAOBAO_RELAY_DOWNLIGHT  		      0x0F    //筒灯
#define XIAOBAO_RELAY_AISLE_LIGHT  		    0x10    //过道灯
#define XIAOBAO_RELAY_SPOTLIGHT  		      0x11    //射灯
#define XIAOBAO_RELAY_BACKGROUND_LIGHT  	0x12    //背景灯
#define XIAOBAO_RELAY_NIGHT_LIGHT  		    0x13    //夜灯
#define XIAOBAO_RELAY_SHOWERS_LIGHT  		  0x14    //沐浴灯
#define XIAOBAO_RELAY_WASH_UP_LIGHT  		  0x15    //洗漱灯
#define XIAOBAO_RELAY_BALCONY_LIGHT  		  0x16    //阳台灯
#define XIAOBAO_RELAY_LEISURE_LIGHT  		  0x17    //休闲灯
#define XIAOBAO_RELAY_READ_LIGHT  		    0x18    //阅读灯
#define XIAOBAO_RELAY_WALL_LIGHT  		    0x19    //壁灯
#define XIAOBAO_RELAY_WARDROBE_LIGHT  		0x1A    //衣柜灯
#define XIAOBAO_RELAY_ROOM_LIGHT  		    0x1B    //房灯
#define XIAOBAO_RELAY_VENTILATOR			    0x1C    //换气扇
#define XIAOBAO_RELAY_BACKLIGHT  		      0x1D    //背光
#define XIAOBAO_RELAY_APERTURE  		      0x1E    //光圈
#define XIAOBAO_RELAY_BEDSIDE_LIGHT  		  0x1F    //床头灯
#define XIAOBAO_RELAY_ATMOSPHERE_LIGHT  	0x20    //氛围灯
#define XIAOBAO_RELAY_PORCH_LIGHT  		    0x21    //玄关灯
#define XIAOBAO_RELAY_LEFT_WALL_LIGHT  		0x22    //左壁灯
#define XIAOBAO_RELAY_RIGHT_WALL_LIGHT  	0x23    //右壁灯
#define XIAOBAO_RELAY_TOILET_LIGHT  		  0x24    //卫生间灯

/*小宝控制数据的服务类型*/
#define XIAOBAO_SERVICE_TYPE     0X04      //服务类型
/*服务地址编码*/
#define XIAOBAO_SERVICE_CLEAR             0X01      //清理
#define XIAOBAO_SERVICE_DO_NOT_DISTURB    0X02      //勿扰
#define XIAOBAO_SERVICE_LATER             0X03      //稍后
#define XIAOBAO_SERVICE_CHECK_OIT         0X04      //退房
#define XIAOBAO_SERVICE_TOOTHPASTE        0X05      //送牙膏
#define XIAOBAO_SERVICE_SLIPPER           0X06      //送拖鞋
#define XIAOBAO_SERVICE_CONDITIONER       0X07      //护发素
#define XIAOBAO_SERVICE_SHAMPOO           0X08      //洗发水
#define XIAOBAO_SERVICE_SHOWER_GEL        0X09      //沐浴露
#define XIAOBAO_SERVICE_LOTION            0X0A      //润肤乳
#define XIAOBAO_SERVICE_SOAP              0X0B      //香皂
#define XIAOBAO_SERVICE_BATH_CAP          0X0C      //浴帽
#define XIAOBAO_SERVICE_COMB              0X0D      //送一把梳子
#define XIAOBAO_SERVICE_COTTON_STICK      0X0E      //棉棒
#define XIAOBAO_SERVICE_HAIR_DRIER        0X0F      //吹风机
#define XIAOBAO_SERVICE_kETTLE            0X10      //热水壶
#define XIAOBAO_SERVICE_KLEENEX           0X11      //面巾纸
#define XIAOBAO_SERVICE_PEN               0X12      //笔
#define XIAOBAO_SERVICE_CHARGER           0X13      //充电器数据线
#define XIAOBAO_SERVICE_CALL_WAITER       0X14      //呼叫服务员
#define XIAOBAO_SERVICE_TOOTHBRUSH        0X15      //牙刷
#define XIAOBAO_SERVICE_WATER             0X16      //送瓶水

/*小宝控制数据的窗帘类型*/
#define XIAOBAO_CURTAINS_TYPE     0X05     //窗帘类型
/*窗帘地址编码*/
#define XIAOBAO_CURTAINS_PARLOUR_CURTAINS                 0X01      //厅窗帘
#define XIAOBAO_CURTAINS_PARLOUR_WINDOW_SCREENING         0X02      //厅窗纱
#define XIAOBAO_CURTAINS_BEDROOM_CURTAINS                 0X03      //卧窗帘
#define XIAOBAO_CURTAINS_BEDROOM_WINDOW_SCREENING         0X04      //卧窗纱
#define XIAOBAO_CURTAINS_SECOND_BEDROOM_CURTAINS          0X05      //次卧窗帘
#define XIAOBAO_CURTAINS_SECOND_BEDROOM_WINDOW_SCREENING   0X06      //次卧窗纱
#define XIAOBAO_CURTAINS_ROLLER_SHUTTER                   0X07      //卷帘

/*小宝控制数据的空调类型*/
#define XIAOBAO_TEMP_TYPE     		0X07      //空调类型
/*空调地址编码*/
#define XIAOBAO_TEMP_PARLOUR       				 0x01        //客厅空调
#define XIAOBAO_TEMP_BEDROOM        			 0x02        //卧室空调
#define XIAOBAO_TEMP_SECOND_BEDROOM        0x03        //次卧空调

/*小宝控制数据的电视类型*/
#define XIAOBAO_IR_TYPE          0x0F        //红外转发类型
#define XIAOBAO_IR_PARLOUR       0x01        //客厅电视

/*小宝控制数据的调光类型*/
#define XIAOBAO_DIMMING_TYPE     0X10       //调光类型
/*调光地址编码*/
#define XIAOBAO_DIMMING_BATHROOM_LIGHT      0x01    //卫浴灯
#define XIAOBAO_DIMMING_SHOWERSROOM_LIGHT  	0x02    //浴室灯
#define XIAOBAO_DIMMING_MIRROR_LIGHT  		  0x03    //镜前灯
#define XIAOBAO_DIMMING_CORRIDOR_LIGHT  		0x04    //廊灯
#define XIAOBAO_DIMMING_BAR_LIGHT  		      0x05    //吧台灯
#define XIAOBAO_DIMMING_TV_LIGHT  		      0x06    //电视灯
#define XIAOBAO_DIMMING_LEFT_BEDSIDE_LIGHT  0x07    //左床头灯，左阅读灯
#define XIAOBAO_DIMMING_RIGHT_BEDSIDE_LIGHT 0x08    //右床头灯，右阅读灯
#define XIAOBAO_DIMMING_DESK_LIGHT  		    0x09    //书桌灯
#define XIAOBAO_DIMMING_PARLOUR_LIGHT  		  0x0A    //客厅灯
#define XIAOBAO_DIMMING_LEISURE_LIGHT  		  0x0B    //休闲灯
#define XIAOBAO_DIMMING_LEISURE_LIGHT2  		0x0C    //休闲灯
#define XIAOBAO_DIMMING_MASTER_LIGHT  		  0x0D    //主灯
#define XIAOBAO_DIMMING_TOP_LIGHT  		      0x0E    //顶灯
#define XIAOBAO_DIMMING_DOWNLIGHT  		      0x0F    //筒灯
#define XIAOBAO_DIMMING_AISLE_LIGHT  		    0x10    //过道灯
#define XIAOBAO_DIMMING_SPOTLIGHT  		      0x11    //射灯
#define XIAOBAO_DIMMING_BACKGROUND_LIGHT  	0x12    //背景灯
#define XIAOBAO_DIMMING_NIGHT_LIGHT  		    0x13    //夜灯
#define XIAOBAO_DIMMING_SHOWERS_LIGHT  		  0x14    //沐浴灯
#define XIAOBAO_DIMMING_WASH_UP_LIGHT  		  0x15    //洗漱灯
#define XIAOBAO_DIMMING_BALCONY_LIGHT  		  0x16    //阳台灯
#define XIAOBAO_DIMMING_LEISURE_LIGHT3  		0x17    //休闲灯
#define XIAOBAO_DIMMING_READ_LIGHT  		    0x18    //阅读灯
#define XIAOBAO_DIMMING_WALL_LIGHT  		    0x19    //壁灯
#define XIAOBAO_DIMMING_WARDROBE_LIGHT  		0x1A    //衣柜灯
#define XIAOBAO_DIMMING_ROOM_LIGHT  		    0x1B    //房灯
#define XIAOBAO_DIMMING_VENTILATOR_LIGHT    0x1C    //换气扇
#define XIAOBAO_DIMMING_BACKLIGHT  		      0x1D    //背光
#define XIAOBAO_DIMMING_APERTURE  		      0x1E    //光圈
#define XIAOBAO_DIMMING_BEDSIDE_LIGHT  		  0x1F    //床头灯

/*小宝控制数据的灯带类型*/
#define XIAOBAO_LIGHT_BELT_TYPE     0X12    //灯带类型
/*灯带地址编码*/
#define XIAOBAO_LIGHT_BELT_BEDSIDE        0x01    //床头灯带
#define XIAOBAO_LIGHT_BELT_TV             0x02    //电视灯带
#define XIAOBAO_LIGHT_BELT_WINDOW         0x03    //窗灯带
#define XIAOBAO_LIGHT_BELT_PARLOUR_R      0x04    //厅灯带红
#define XIAOBAO_LIGHT_BELT_PARLOUR_G      0x05    //厅灯带绿
#define XIAOBAO_LIGHT_BELT_PARLOUR_B      0x06    //厅灯带蓝
#define XIAOBAO_LIGHT_BELT_BEDROOM_R      0x07    //卧灯带红
#define XIAOBAO_LIGHT_BELT_BEDROOM_G      0x08    //卧灯带绿
#define XIAOBAO_LIGHT_BELT_BEDROOM_B      0x09    //卧灯带蓝
#define XIAOBAO_LIGHT_BELT_TOILET_R       0x0A    //卫灯带红
#define XIAOBAO_LIGHT_BELT_TOILET_G       0x0B    //卫灯带绿
#define XIAOBAO_LIGHT_BELT_TOILET_B       0x0C    //卫灯带蓝

/*小宝控制数据的背景音乐类型*/
#define XIAOBAO_MUSIC_TYPE         0X15    //背景音乐类型
/*灯带地址编码*/
#define XIAOBAO_MUSIC_PARLOUR      0x01    //客厅背景音乐
#define XIAOBAO_MUSIC_TOILET       0x02    //卫生间背景音乐
#define XIAOBAO_MUSIC_BEDROOM      0x03    //卧室背景音乐



typedef enum
{
	CMD_PLAY_WELCOME = 0,    //播放欢迎词
	CMD_PLAY_DOORBELL,       //播放门铃
	CMD_DISTINGUISH_OFF,     //关闭语音识别
	CMD_DISTINGUISH_ON,     //开启语音识别
	CMD_VOLUME_UP,          //音量加
	CMD_VOLUME_DOWN,         //音量减
	CMD_SET_VOLUME,         //设置音量
	CMD_QUERY_CONFIG,       //查询配置参数
	CMD_SET_ADDR,          //设置地址
	CMD_READ_ADDR,         //读取地址
	CMD_TONE_OFF,          //关闭提示音（反馈音）
	CMD_TONE_ON,          //开启提示音（反馈音）
}XIAOBAO_CONFIG_CMD_E;

typedef struct
{
	BLV_COMM_RECORD_G comm_record;		//通讯记录
	
	uint8_t DevSendBuf[XiaoBao_BUFF_NUM][XiaoBao_BUFF_Size]; 			//发送数组，
	uint8_t Write_Id;           //写下标
	uint8_t Read_Id;            //读下标
//	uint8_t* Write_Addr;      //写地址
//	uint8_t* Read_Addr;       //读地址
	
	uint8_t Ctrl_Buf[XiaoBao_BUFF_Size];    //小宝控制参数
	
	uint8_t DevAddr;          //设备地址
	uint8_t mode;             //识别模式、非识别模式
	uint8_t vol;             //音量0~30
	uint8_t tone;             //反馈音状态
	uint8_t version;          //词条版本
	
	uint8_t DevCtrlFlag;      //控制标志
	uint8_t Dev_Addr_CtrlFlag;      //设置地址控制标志

	uint8_t DevSendCnt;     	//设备发送计数   计数达到重发次数都没有回复，判为离线
	uint8_t DevOffline;       	//设备离线标志 1，设备离线   0，设备在线
	uint8_t DevOfflineLast;   	//设备离线标志 1，设备离线   0，设备在线
	
	uint8_t DevConfigSN;									//配置命令SN号

}__attribute__ ((__packed__))RS485_XIAOBAO_INFO;						//小宝的数据与函数

void BLV_485_Dev_XiaoBao_Init(uint8_t devaddr);
void BLV_485_Dev_XiaoBao_Logic_Init(LOGICFILE_DEVICE_INFO *dev_info,uint8_t *data,uint16_t data_len);
uint8_t BLV_Rs485_Dev_XiaoBao_CycleDis(uint32_t DevAdd);  
uint8_t BLV_Rs485_Dev_XiaoBao_Check(uint32_t DevAdd ,uint32_t Data_addr, uint16_t DataLen);
void Voice_Map_Dev_Add(uint8_t *DevBuf);

void BLV_Rs485_Dev_XiaoBao_Control_Pair_Feedback_Tone(uint32_t dev_addr, uint8_t start);   //播放无线配对反馈音
void BLV_Rs485_Dev_XiaoBao_Control_Config(uint32_t dev_addr, XIAOBAO_CONFIG_CMD_E cmd, uint8_t start); //小宝 配置相关控制函数
#endif
