#ifndef __CONSOLE_HK_RS232_H_
#define __CONSOLE_HK_RS232_H_

#include "types.h"
#include "al_basictypes.h"
#include "app_event.h"
#include "al_console.h"
#include "al_console_customer.h"


#define CR 		"\x0d"
#define SP  	"\x20"
#define QS  	"\x3f"

//define cmd
#define RespOK ("OK" CR)
#define RespERR ("ERR" CR)
#define RespDataInvalid ("DataInvalid" CR)


#define HKCMD_HEADER 		0x8080

#define HKCMD_TYPE_0000 	0x0000
#define HKCMD_TYPE_1F40 	0x1f40
#define HKCMD_TYPE_2328 	0x2328
#define HKCMD_TYPE_0BB8 	0x0bb8
#define HKCMD_TYPE_0FA0 	0x0fa0
#define HKCMD_TYPE_1388 	0x1388
#define HKCMD_TYPE_1B58 	0x1b58

typedef struct _HkPacket
{
	UINT16	Header;// 2 0x8080
	UINT16	CmdType;// 2
	UINT16	Command;// 2
	UINT16	Reserve;// 2
	UINT8 CheckSum;// 1
} HkPacket;

typedef struct _HkPacketEventMapping
{
	UINT16 cmdEvent;
	HkPacket cmdPacket;
} HkPacketEventMapping;



typedef enum{
	HKCMD_CMD_ExitFactory 		= 0x1,
	HKCMD_CMD_EnterBurnning 	= 0x2,
	HKCMD_CMD_ExitBurnning  	= 0x3,
	HKCMD_CMD_GetHeatRunTime,
	HKCMD_CMD_DCPowerOff,
	HKCMD_CMD_DCPowerOn,
	HKCMD_CMD_ChangeSrcToATV,
	HKCMD_CMD_ChangeSrcToDVBT,
	HKCMD_CMD_ChangeSrcToDVBC,
	HKCMD_CMD_ChangeSrcToDVBS,
	HKCMD_CMD_ChangeSrcToAir,
	HKCMD_CMD_ChangeSrcToCable,
	HKCMD_CMD_ChangeSrcToHDMI1,
	HKCMD_CMD_ChangeSrcToHDMI2,
	HKCMD_CMD_ChangeSrcToHDMI3,
	HKCMD_CMD_ChangeSrcToHDMI4,
	HKCMD_CMD_ChangeSrcToVideo1,
	HKCMD_CMD_ChangeSrcToVideo2,
	HKCMD_CMD_ChangeSrcToYpbpr1,
	HKCMD_CMD_ChangeSrcToYpbpr2,
	HKCMD_CMD_ChangeSrcToVGA1,
	HKCMD_CMD_ChangeSrcToVGA2,
	HKCMD_CMD_ChangeSrcToUSB1,
	HKCMD_CMD_ChangeSrcToUSB2,
	HKCMD_CMD_ChangeSrcToUSB3,
	HKCMD_CMD_ChangeSrcToNetflix,
	HKCMD_CMD_ChangeSrcToYouTube,
	HKCMD_CMD_ChangeSrcToHome,
	HKCMD_CMD_GetCurrentInput,
	HKCMD_CMD_MACAddressTest,
	HKCMD_CMD_WifiUSBSpeed,
	HKCMD_CMD_AutoDetectCheckATV,
	HKCMD_CMD_AutoDetectCheckDVBT,
	HKCMD_CMD_AutoDetectCheckDVBC,
	HKCMD_CMD_AutoDetectCheckDVBS,
	HKCMD_CMD_AutoDetectCheckAir,
	HKCMD_CMD_AutoDetectCheckCable,
	HKCMD_CMD_AutoDetectCheckAV1,
	HKCMD_CMD_AutoDetectCheckComponent1,
	HKCMD_CMD_AutoDetectCheckHDMI1,
	HKCMD_CMD_AutoDetectCheckHDMI2,
	HKCMD_CMD_AutoDetectCheckHDMI3,
	HKCMD_CMD_AutoDetectCheckHDMI4,
	HKCMD_CMD_AutoDetectCheckVGA,
	HKCMD_CMD_AutoDetectCheckUSB1,
	HKCMD_CMD_AutoDetectCheckUSB2,
	HKCMD_CMD_AutoDetectCheckUSB3,
	HKCMD_CMD_AutoDetectCheckHeadPhone,
	HKCMD_CMD_USB1DeviceConnection,
	HKCMD_CMD_USB2DeviceConnection,
	HKCMD_CMD_USB3DeviceConnection,
	HKCMD_CMD_WiFiSearchResult,
	HKCMD_CMD_MagicSearchResult,
	HKCMD_CMD_CISlotCheck,
	HKCMD_CMD_SpeakerVolume,
	HKCMD_CMD_AudioVolumeControl,
	HKCMD_CMD_AudioEQOff,
	HKCMD_CMD_AudioEQOn,
	HKCMD_CMD_HeadPhoneOn,
	HKCMD_CMD_HeadPhoneOff,
	HKCMD_CMD_MacAddressWriteKey,
	HKCMD_CMD_CIPlusWriteKey,
	HKCMD_CMD_CIECPWriteKey,
	HKCMD_CMD_SNWriteKey,
	HKCMD_CMD_WidevineWriteKey,
	HKCMD_CMD_HDCP20WriteKey,
	HKCMD_CMD_HDCP14WriteKey,
	HKCMD_CMD_DTCP4WriteKey,
	HKCMD_CMD_MFIWriteKey,
	HKCMD_CMD_HDCPRx20KeyCheck,
	HKCMD_CMD_HDCPRx14KeyCheck,
	HKCMD_CMD_DTCPRxKeyCheck,
	HKCMD_CMD_MFIKeyCheck,
	HKCMD_CMD_CIPlusAPKeyCheck,
	HKCMD_CMD_CIPlusECPKeyCheck,
	HKCMD_CMD_ESNKeyCheck,
	HKCMD_CMD_WidevineKeyCheck,
	HKCMD_CMD_UHDCPKeyCheck,
	HKCMD_CMD_MACAddressRead,
	HKCMD_CMD_WifiMACAddressRead,
	HKCMD_CMD_WriteModelName,
	HKCMD_CMD_ReadModelName,
	HKCMD_CMD_WriteSerialNumberName,
	HKCMD_CMD_ReadSerialNumberName,
	HKCMD_CMD_ReadMacAddressKey,
	HKCMD_CMD_ReadSNKey,
	HKCMD_CMD_ReadCIPlusKey,
	HKCMD_CMD_ReadWidevineKey,
	HKCMD_CMD_ReadHDCP20Key,
	HKCMD_CMD_ReadHDCP14Key,
	HKCMD_CMD_7KeypadCheck,
	HKCMD_CMD_5KeypadCheck,
	HKCMD_CMD_1KeypadCheck,
	HKCMD_CMD_SendIRKeyCode,
	HKCMD_CMD_GetIRKeyCode,
	HKCMD_CMD_GetMainSWVersion,
	HKCMD_CMD_GetSubMicomVersion,
	HKCMD_CMD_OTPkeyEmbedded,
	HKCMD_CMD_CheckLocalKeyTestResult,
	HKCMD_CMD_ClearWifiMagicResult,
	HKCMD_CMD_ClearLocalKeyReset,
	HKCMD_CMD_AutoTestCheck,
	HKCMD_CMD_SystemReset,
	HKCMD_CMD_FastReset,
	HKCMD_CMD_FactoryTestResultReset,
	HKCMD_CMD_UserMenuReset,
	HKCMD_CMD_CusReset,
	HKCMD_CMD_MAX,
}eHkCmdEvent;


typedef enum{
	HkRsp_State_OK 		= 0x1,
	HkRsp_State_ERR 	= 0x2,
	HkRsp_Data  		= 0x3,
	HkRsp_Data_Invalid 	= 0x4,
	HkRsp_Need_App_Resp	= 0x5,
}eHkRspType;


typedef int (*HkRs232_autotest_Cbk_pf)(pCON_DEV pcon, UINT8 *msg);

typedef struct HkRs232_autoest_Cbk_t_
{
	HkRs232_autotest_Cbk_pf		pfCallBack;
} HkRs232_autotest_Cbk_t;

void al_hkrs232_autotest_init(HkRs232_autotest_Cbk_t *pConsole_autotest_Cfg);

UINT8 con_hkRs232_CheckSyncAndValid(UINT8 sync,UINT8 len);
bool con_HkRs232_AutoTest_parser(pCON_DEV pcon, UINT8 *data);

extern const HkPacketEventMapping hkCmdTable[];
extern const UINT16 g_hkCmdTableLen;
extern const UINT16 DynamicAllocationSizeTable[];
extern const UINT16 g_DynamicAllocationTableSize;


#endif
