#ifndef LOG_API_H_
#define LOG_API_H_

#include "stdint.h"

#define LogType_Enable				1				//LOG使能

/*日志存储类型定义*/
#define LogType_Launcher			0x01			//Launcher信息记录
#define LogType_SYS_Record			0x02			//系统运行信息记录
#define LogType_Device_COMM			0x03			//设备通讯记录
#define LogType_Device_Online		0x04			//设备通讯状态记录
#define LogType_Global_Parameters	0x05			//所有设备状态定期记录
#define LogType_Net_COMM			0x06			//网络通讯记录
#define LogType_Logic_Record		0x07			//逻辑处理记录

/*日志存储开关 - 初始状态*/
#define LogType_Launcher_SWITCH					1		
#define LogType_SYS_Record_SWITCH				1		
#define LogType_Device_COMM_SWITCH				1		
#define LogType_Device_Online_SWITCH			1			
#define LogType_Global_Parameters_SWITCH		1		
#define LogType_Net_COMM_SWITCH					1			
#define LogType_Logic_Record_SWITCH				1	

/*日志存储控制位*/
#define LogType_Launcher_bit					0		
#define LogType_SYS_Record_bit					1		
#define LogType_Device_COMM_bit					2		
#define LogType_Device_Online_bit				3			
#define LogType_Global_Parameters_bit			4		
#define LogType_Net_COMM_bit					5			
#define LogType_Logic_Record_bit				6

extern uint32_t  SYS_Log_Switch;

/*日志相关参数*/
#define LogInfo_Device_Online		0x01	//设备在线
#define LogInfo_Device_Offline		0x02	//设备离线

typedef enum{
	LLauncher_App_Check = 0x01,		//校验APP
	LLauncher_Read_App,				//读取APP，并将APP数据写入到MCU FLash中
	LLauncher_Write_Flash,			//写Flash
	LLauncher_Factory_Reset,		//恢复出厂设置
	LLauncher_Reset_Source,			//复位源
	LLauncher_RCUKey_State,			//RCU按键事件记录
}LOGTYPE_Launcher_E;

typedef enum {
	LSYS_PHY_Change = 0x01,			//PHY状态变化记录
	LSYS_DevInfo_Error,				//设备链表信息错误
	LSYS_API_State,					//升级状态
	LSYS_NET_ARGC,					//网络初始化参数
	LSYS_MQTT_ARGC,					//MQTT参数
	LSYS_Server_Comm_State,			//云端通讯状态记录
	LSYS_NET_DefaultARGC,			//网络默认参数
	LSYS_RCUKey_State,				//RCU按键事件记录
}LOGTYPR_SYSRecord;

typedef enum {
	LCOMM_ASK_TO_Reply = 0x01,		//轮询回复数据
	LCOMM_Send_Control,				//RCU下发控制数据
	LCOMM_Control_Reply,			//RCU控制回复数据
	LCOMM_Adjust_Baud,				//设备调整波特率
}LOGTYPE_DEV_COMM;

typedef enum {
	LGlobal_Para = 0x01,			//参数数据
	LGlobal_Dev,					//设备数据
}LOGTYPE_Global_E;

typedef enum {
	LNetComm_Send = 0x01,			//网络发送数据
	LNetComm_Recv,					//网络接收数据
}LOGTYPE_NET_COMM_E;

typedef enum {
	LLogic_DebugString = 0x01,		//逻辑处理 - 字符串调试信息

}LOGTYPE_LOGICRecord_E;

/*Launcher信息记录相关API*/
void LOG_Launcher_APP_Check_Record(uint8_t state);
void LOG_Launcher_Read_App_Record(uint8_t state);
void LOG_Launcher_Write_Flash_Record(uint32_t addr,uint16_t len);
void LOG_Launcher_Factory_Reset_Record(void);
/*系统运行信息记录相关API*/
void LOG_SYS_PHY_Change_Record(uint8_t state);
void LOG_SYS_DevInfo_Error_Record(uint8_t dev,uint8_t addr,uint32_t info_addr);
void LOG_SYS_API_State_Record(uint8_t API_way,uint8_t state);
void LOG_SYS_NET_Argc_Record(uint8_t *IP,uint8_t *MAC,uint8_t *DNS_IP1,uint8_t *DNS_IP2,uint8_t *DNS_IP3);
void LOG_SYS_MQTT_Argc_Record(uint8_t *productkey,uint8_t *devname,uint8_t *devsecret,uint8_t *publish,uint8_t *sublish);
void LOG_SYS_Server_Comm_State_Record(uint8_t state);
void LOG_SYS_NET_Argc_Init_Record(uint8_t *IP,uint8_t *Gateway,uint8_t *IP_Mask,uint8_t *DNS_Add,uint8_t ArgcFlag,uint8_t DHCPFlag,uint8_t ServerFlag);
void LOG_SYS_RCUKey_State_Record(uint8_t state);
/*设备通讯记录相关API*/
void LOG_Device_COMM_ASK_TO_Reply_Record(uint8_t port,uint32_t baud,uint32_t data_tick,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_ASK_TO_Reply_Record2(uint32_t port_addr,uint32_t baud_addr,uint32_t data_tick,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_Send_Control_Record(uint8_t port,uint32_t baud,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_Send_Control_Record2(uint32_t port_addr,uint32_t baud_addr,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_Control_Reply_Record(uint8_t port,uint32_t baud,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_Control_Reply_Record2(uint32_t port_addr,uint32_t baud_addr,uint8_t *buff,uint16_t len);
void LOG_Device_COMM_Control_Reply_Record3(uint32_t port_addr,uint32_t baud_addr,uint32_t buff_addr,uint16_t len);
void LOG_Device_COMM_Adjust_Baud_Record(uint8_t dev_type,uint8_t dev_addr,uint32_t baud,uint8_t way,uint8_t fail_num,uint8_t sum,uint8_t num);
void LOG_Device_COMM_Adjust_Baud_Record2(uint32_t dev_type,uint32_t dev_addr,uint32_t baud_addr);
/*设备通讯状态记录相关API*/
void LOG_Device_Online_Record(uint8_t dev,uint8_t addr,uint8_t state);
/*所有设备状态定期记录相关API*/
void LOG_Global_ParaInfo_Record(uint8_t *buff,uint16_t len);
void LOG_Global_DevInfo_Record(uint8_t *buff,uint16_t len);
/*网络通讯记录相关API*/
void LOG_NET_COMM_Send_Record(uint8_t SocketId,uint8_t *ip,uint16_t port,uint8_t *buff,uint16_t len);
void LOG_NET_COMM_Recv_Record(uint8_t SocketId,uint8_t *ip,uint16_t port,uint8_t *buff,uint16_t len);
/*逻辑处理记录相关API*/
void LOG_LogicInfo_DebugRecord(char *fmt,...);



#endif
