#ifndef		__POS_Connect_H_
#define		__POS_Connect_H_
/*H******************************************************************************
* NAME:         POS_Connect.h
*********************************************************************************/

#define POSConnect_Cloud             GPIO_ResetBits(GPIOB,GPIO_Pin_5);
#define POSConnect_Station           GPIO_SetBits(GPIOB,GPIO_Pin_5);

#define POS_NET        GPIOAin(0)
#define POS_LinkB      GPIOAin(1)
#define POS_LinkA      GPIOAin(2)

/*********************蓝天协议指令集************************/
#define POSConnect_Authorize              0xA1  //
#define POSConnect_ChangePrice            0xA2  //
#define POSConnect_Config                 0xA3  //
#define POSConnect_DisAuthorize           0xA4  //
#define POSConnect_Preset                 0xA5  //
#define POSConnect_Heartbeat              0x0A  //
#define POSConnect_SynchronizationTime    0x0B  //
#define POSConnect_TankAPCDownload        0x0C  //
#define POSConnect_BoxROMownload          0x0D  //
#define POSConnect_BoxVersion             0x0E  //
#define POSConnect_PREXDATAUp             0x1F  //
#define	POSConnect_FuelData 			        0x10	//
#define	POSConnect_DeviceVersion 			    0x11	//
#define	POSConnect_DeviceROMownload 		  0x12	//
#define	POSConnect_PrintfInfo 		        0x14	//
#define	POSConnect_Print 		              0x15	//
#define	POSConnect_WhiteList 		          0x16	//
#define	POSConnect_WritePriceTag 		      0x18	//

//硬件定义
#define	POS_ConnectUsart USART1
#define	POS_Connect_DMA	DMA1

#define POS_Connect_TX_DMALenSet(x) (DMA2_Stream7->NDTR = x)   //设置发送DMA长度
#define POS_Connect_TX_DMAStart()    DMA_Cmd(DMA2_Stream7,ENABLE) //开启发送DMA
#define POS_Connect_TX_DMAStop()     DMA_Cmd(DMA2_Stream7,DISABLE) //开启发送DMA

#define POS_Connect_RX_DMALenSet(x) (DMA2_Stream5->NDTR = x)   //设置DMA长度
#define POS_Connect_RX_DMAStart()    DMA_Cmd(DMA2_Stream5,ENABLE) //开启DMA
#define POS_Connect_RX_DMAStop()     DMA_Cmd(DMA2_Stream5,DISABLE) //开启DMA
                            
//缓冲数定义
#define	C_POS_Connect_TX_Buff    100  //发送缓存大小
#define	C_POS_Connect_RX_Buff    100  //接收缓存大小

typedef enum
{
	USRK3_ENTM,
	USRK3_Model_Set_1,
	USRK3_Model_Set_2,
	USRK3_Rec,
	USRK3_DHCP,
	USRK3_GetIP,
	USRK3_SOCKET,
	USRK3_GetLinkState,
	USRK3_RST,
	
}USRK3_Item;
typedef enum
{
	WIFI_ATRec,
	WIFI_WifiWSSSID,
	WIFI_WifiRSSI,
	WIFI_WifiSOCKET,
	WIFI_WifiRST,
	WIFI_WMODE,
}WIFICMD_Item;
typedef enum
{
	GM5_ENTM,
	GM5_Model_Set_1,
	GM5_Model_Set_2,
	GM5_Rec,
	GM5_HEARTEN,
	GM5_UARTFL,
	GM5_APN,
	GM5_LinkMode,
	GM5_GetIMEI,
	GM5_GetICCID,
	GM5_SOCKET,
	GM5_CSQ,
	GM5_Save,
	GM5_RESET,
	
}GM5_Item;
typedef enum
{
	L510_ATRec,
  L510_IMEI,
	L510_SetGPSMode,
  L510_ICPIN,
  L510_ICCID,
  L510_RSSI,
  L510_Model_NET,
  L510_APN,
  L510_NETOPEN,
  L510_SOCKET,
  L510_GetLinkState,
	L510_AT,
	L510_RESET,
	L510_GetGPS,
}L510CMD_Item;
//******************************************************************************
//*-------------- 变量声名 -----------------------------------------------------
//******************************************************************************
extern volatile u8 POS_Connect_TX_Flag;                    //接收任务可以运行标志
extern const char TsatURL[];
extern volatile u8 MD_Set_Flag_pGun;		
extern volatile u8 MD_POS_Flag_pGun;		
extern volatile u8 POS2MD_Buff[2000];//pos的回复转接到wifi从机
//******************************************************************************
//*-------------- 函数声名 -----------------------------------------------------
//******************************************************************************
extern  void POS_Connect_Init(void);             //POS_Connect卡键盘任务初始化
extern  void POS_Network_Init(void);
extern	void POS_Connect_DMARX_IRQHandler(void);    //POS_Connect卡键盘接收中断服务函数
extern	void POS_Connect_DMATX_IRQHandler(void); //DMA发送中断服务函数
extern  u64 POS_Connect_u64ToBCD(u64 Dat);       //整型转换成BCD码
extern  u64 POS_Connect_BCDTou64(u64 Dat);       //BCD码转换成整型
extern  void POS_ConnectRXTask(void);            //数据接收任务
extern  u16 POS_ConnectTXTask(u8 POS_Connect_Typ,u8 GunNum,u8 POS_Connect_Com);//数据发送任务
extern  u8 Encrypt_Data(u8 Data,u8 Type,u8 Bit);
extern  u8 Decode_Data(u8 Data,u8 Type,u8 Bit);
extern  u16 DartCRC16(u8 *puchMsg, u16 usDataLen) ;
extern u8 SUMCRC(u8 *puchMsg, u16 usDataLen) ;
extern  void InitQueue(MessageQueue_Type *Queue) ;
extern  void EnQueue(MessageQueue_Type *Queue, u8 Content,u8 Priority);
extern  Message_Type *DeQueue(MessageQueue_Type *Queue) ;
//查询队列中是不是包含特定消息
extern u8 FindMessage(MessageQueue_Type *Queue,u8 Content);
extern u16 CRC_Check(u8 *puchMsg, u16 usDataLen) ;
void POS_Network_APN_Set(void);
#endif	//#ifndef		
