#ifndef __HOSTCOM
#define __HOSTCOM

#include "common.h"

#define HOST_COMMAND_OFFSET 0
#define HOST_PARAMETER_OFFSET 1

//Outgoing traffic
#define HOSTOUT_SEND_SCANNED_FPR_CMD	0xA0
#define HOSTOUT_SEND_ACTIVE_MODE_CMD	0xA1
#define HOSTOUT_SEND_KEY_PRESSED_CMD	0xA2
#define HOSTOUT_SEND_ACK				      0xAA
#define HOSTOUT_SEND_ERR              0xAE
#define HOSTOUT_SEND_CARD_READ			  0xA3
#define HOSTOUT_ECHO_REPLY_CMD			  0xA4
#define HOSTOUT_SEND_SCAN_PROGRESS		0xA5
#define HOSTOUT_SEND_PWRCHANGE			  0xA6

//Incoming traffic
#define HOSTIN_BOOTLOAD_RESET_CMD		0xB0
#define HOSTIN_FPR_SWITCH_CMD			0xB1
#define HOSTIN_FPR_SCAN_CMD				0xB2
#define HOSTIN_FPR_DOWNLOAD_CMD			0xB3
#define HOSTIN_FPR_DELETE_CMD			0xB4
#define HOSTIN_AMP_SWITCH_CMD			0xB5
#define HOSTIN_ECHO_REQUEST_CMD			0xB6
#define HOSTIN_KEYB_MODE_CMD			0xB7
#define HOSTIN_WRITE_BINARY 			0xB8
#define HOSTIN_READ_BINARY				0xB9

enum ScanProgress{SCANPROGRESS_PUT1,SCANPROGRESS_PROCESSING1,SCANPROGRESS_RELEASE1,SCANPROGRESS_PUT2,SCANPROGRESS_PROCESSING2,SCANPROGRESS_RELEASE2};
enum PwrSource{POWER_FROMBATTERY,POWER_FROMAC,POWER_BATTERY_LOW};

#define HOSTOUT_FPR_NOTFOUND			0xFFFF

#define HOST_MAX_PACKET_SIZE 290
#define HOST_COM_RECEIVED() Host_Com_Stat=1
#define HOST_COM_PACKERR() Host_Com_Stat=2
#define HOST_COM_CHECKSUMERR() Host_Com_Stat=4
#define HOST_COM_OVERFLOW() Host_Com_Stat=8

#define HOST_PACKET_PROCESSED() Host_Com_Stat = 0;

uint8_t Host_Com_Stat;

uint8_t Host_send(uint8_t* data, uint16_t length);
uint8_t Host_Send_ScannedFPR(uint16_t fpr_no);
uint8_t Host_Send_ScanProgress(uint8_t progress);
uint8_t Host_Send_PWRChange(uint8_t progress);
uint8_t Host_Send_ActiveMode(uint8_t state);
uint8_t Host_Send_PressedKey(uint8_t Key);
uint8_t Host_Send_ReadRFID(uint8_t* cardNo);
uint8_t Host_Send_Ack(uint8_t cmd);
uint8_t Host_Send_Err(uint8_t cmd,uint8_t errcode);
uint8_t Host_Send_Binary(uint8_t cmd);
uint8_t Host_Send_Echo(void);
int Host_Process(void);


#endif
