#ifndef _WIZFI210_H
#define _WIZFI210_H
/* ---------------------- Includes ------------------------------- */


/* ------------------ Test Macroses ----------------------------- */
#define COMAND_MODE_WIFI_TEST														  
/* ------------ Base types definitions -------------------------- */
typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned long int U32;
typedef char S8;
typedef short S16;
typedef int S32;
typedef unsigned char Bool;

extern U16 AP_Connect; 
extern U16 IP_Connect;
extern U32 SysCnt;
extern U32 NoConnCnt;
extern U16 SearchFlag;

#define TRUE 1
#define FALSE 0

/* --------------- PINSEL definitions ---------------------------- */
#define TXD1 																							0x40000000
#define RXD1 																							0x00000001
#define TXD0 																							0x00000010
#define RXD0 																							0x00000040

/* ---------------- UART definitions ----------------------------- */
#define DIVADDVAL1 																				0x00000005
#define MULVAL1 															 				 0x00000008<<4
#define DLM1 																							0x00000000
#define DLL1 																							0x00000004

/* -------------- WiZFi210 procedures ---------------------------- */
static U8 *AT[]={
"AT\r",									/*Check if we are in comand mode	 		  [0]*/
"ATE0\r", 							/*Input echo disable				 			 		  [1]*/
"ATE1\r", 							/*Input echo enable					 			 		  [2]*/
"ATV0\r", 							/*ASCII relpy disable				 			 		  [3]*/
"ATV1\r", 							/*ASCII relpy enable				 			 		  [4]*/		
};

static U8 *RestoreDefault[]={
"AT\r",
"AT&F\r",	/*Restore profile to factory default values  		 		  [1]*/
};

static U8 *TCP_Client[]={
"ATE0\r",		/*Input echo disable				 			 		  						[0]*/
"AT\r",			/*If we are in Command maode 												[1]*/
"AT+WD\r",	/*Disassociate WizFi210 from the current AP  		 		[2]*/
"AT+WM=0\r",	/*Infrastructure / Station								    		[3]*/
"AT+WAUTH=2\r",	/*Shared with WEP														 		[4]*/
"AT+WWEP1=1234567800\r", /*WEP security of AP where WizFi210 
																						will be connect			[5]*/
"AT+NDHCP=1\r",	/*Enable DHCP to produce dynamic IP							[6]*/
"AT+NAUTO=0,1,192.168.62.10,3000\r", /*Set network parameters for
																									Auto Connect	[7]*/
"AT+WAUTO=0,WizFiDemoAP,,6\r",	/*Sets WiFi parameters to be used for
																									 Auto Connect [8]*/
"AT+XAR=5\r",	/*																							 	[9]*/
"ATC1\r",	/*ATC1																							 [10]*/
"AT&Y0\r",	/*Set default configuration to Profile #0	 				 [11]*/
"AT&W0\r", /*Save Profile #0																	 [12]*/
"ATZ0\r",	/*Load Profile #0																		 [13]*/
	
"AT+WA=WizFiDemoAP\r",	/*Connect to AP with desired SIID				[14]*/
"ATA\r",	 /*Start Auto Connect including association						[15]*/
};

static U8 *ATSTimeouts[]={
"ATE0\r",		/*Input echo disable				 			 		  						[0]*/
"ATS0=100\r",		/*1s for Network connection Timeout	 						[1]*/
"ATS1=1\r",			/*10ms Auto Associate Timeout										[2]*/
"ATS2=1\r",	/*10ms TCP connection Timeout	 											[3]*/
"ATS4=10\r",	/*100ms Nagle Algorithm Wait Time						    	[4]*/
"ATS5=20\r",	/*20ms Scan Time											 						[5]*/
};


static U8 *TCP_ClientEstablish[]={
"AT+WA=WizFiDemoAP\r",	/*Connect to AP with desired SIID				[0]*/
"ATA\r",	 /*Start Auto Connect including association						[1]*/
"ATA2\r",	/*Start Auto Connect, using existing association			[2]*/	
};

static U8 *AutoStandBy[]={
"+++",						/*Leave Data mode					 										[0]*/
"AT+STORENWCONN\r"	/*Close all connactions											[1]*/
"AT+NCLOSEALL\r",	/*Close all connactions		 										[2]*/
"AT+PSSTBY=20000\r"	/*Set StandBy time interval									[3]*/
};



/* --------------- Functions prototypes -------------------------- */
/********************************************************************************
Name:    U32 WizFi_SendATcmd(U8 **str)                     
Purpose: Send specific command to WizFi210 module.
                                                           
Inputs: U8 **str - string command
Output(s): U32 - Return 0 if response is [OK], else return 1
********************************************************************************/
extern U32 WizFi_SendATcmd(U8 **str);
/********************************************************************************
Name:    void InitWizFi210_TCPClient(void)                     
Purpose: Send the full TCP_Client procedure to WizFi210 module, at ones.
                                                           
Inputs: 
Output(s): 
********************************************************************************/
extern void InitWizFi210_TCPClient(void);
/********************************************************************************
Name:    void InitWizFi210_Timeouts(void)                     
Purpose: Init WizFi210 timeouts values
                                                           
Inputs: 
Output(s): 
********************************************************************************/
extern void InitWizFi210_Timeouts(void);
/********************************************************************************
Name:    void Establish_AutoConnection(void)                     
Purpose: Establish connection to AP, which was founded.
                                                           
Inputs: 
Output(s): 
********************************************************************************/
extern void Establish_AutoConnection(void);
/********************************************************************************
Name:    void ConnectionStatus(void)                     
Purpose: Check the status of our WiFi and Network connection
                                                           
Inputs: 
Output(s): 
********************************************************************************/
extern void ConnectionStatus(void);
/********************************************************************************
Name:    void AutoMode(void)                     
Purpose: Manage WizFi210 behaviour.
                                                           
Inputs: 
Output(s): 
********************************************************************************/
extern void AutoMode(void);
#endif
