Example #1
0
/************************************光标在备注处菜单**********************************************/
static char PhoneHandleBeiZhu(char *msg)
{
	FILE *fp;
	u8 dispbuff[30];
	int numPhone;

	clear_lcd();
	fp=fopen("PhoneBook","rb");
	if(fp!=NULL){		//如果有记录,则先把记录读到phonebuff 。
		#ifdef DEBUG_PRINTF
		printf("open PhoneBook success!!\n");
		#endif
		fread(dispbuff,10,1,fp);
	}else{
		text_out_to_row_x_Language2(2,40,"没有记录","没有记录");
		goto tuichu;
	}

	numPhone=*msg;		//如果msg==NULL,则会引起segmentation  fault。
	fseek(fp,10+numPhone*98+12+18+18+20,SEEK_SET);
	fread(dispbuff,sizeof(dispbuff),1,fp);
	fclose(fp);
	
	text_out_to_row_x_Language2(0,40,"【备注】","【备注】");
	my_DisplayBuff(dispbuff,1,2);

	tuichu:
	SetBLOverTime(10);
	SetAutoExitTime(10);
	WaitkeyAndAutoExit(10);
	return 0;
}
char Reset_WiFi(char *msg)
{
//	unsigned char retval;
	
	clear_lcd();
	DrawTitle_to_row_Language2(2,"ÇëµÈ´ý...","Pls wait...");

	kmy_EnableDisableTime3(0);

	if(rak_get_net_status()==RUN_OK)
	{
		rak_disconnect();
	}
	
	Reset_Target();
	//while(!ReadINTPin());
	msleep(1000);
	rak_sys_init(&uCmdRspFrame);
	printf("%s\r\n",uCmdRspFrame.initResponse.strdata);
	if(rak_get_version()!=RUN_OK)
	{
		clear_lcd();
		DrawTitle_to_row_Language2(2,"ʧ°Ü!","failure!");
	}
	else
	{
		printf("%s\r\n",uCmdRspFrame.initResponse.strdata);
		clear_lcd();
	    DrawTitle_to_row_Language2(2,"³É¹¦!","Success!");
	}
	memset(SSID,0,sizeof(SSID));
	kmy_EnableDisableTime3(1);
	return (WaitkeyAndAutoExit(5));
}
Example #3
0
/******************************全部删除************************************/
static char PhoneDeleteAll(char *msg)
{
	char retval;

	clear_lcd();
	DrawTitle_to_row_Language2(2,"确定全部删除吗","Confirm Delete");
	retval=WaitkeyAndAutoExit(10);
	if(retval==KEY_Enter){
		//system("rm PhoneBook");
		EepromFile_Delete(file_phonebook);
		clear_lcd();
		DrawTitle_to_row_Language2(2,"删除成功","Deleted");
		retval=WaitkeyAndAutoExit(10);
	}

	return retval;
}
char WPManage(char *msg)
{
	unsigned char buff[40];
	unsigned char retval;
	abcABC123PYWuBiArgument argAa1;

	clear_lcd();
	strcpy((s8*)buff,(sc8*)WLANWP);
	DrawTitle_to_row_Language2(0,"¡¾µ±Ç°ÍøÂçÃÜÔ¿¡¿","Current Password");
	text_out_to_row_Language2(1,buff,buff);

	abcABC123PYWuBiArgDeInit(&argAa1,buff,30);
	argAa1.srfFlag=SRF_123|SRF_ABC|SRF_abc|SRF_PY|SRF_BiHua;
	argAa1.LocalTitle="¡¾ÊäÈëÍøÂçÃÜÔ¿¡¿";
	argAa1.OtherTitle="Input Password" ;
	argAa1.HaveoldFlag=1;
	retval=GetString_abcABC123PYWuBi2(&argAa1);
	if(retval!=KEY_Enter)return retval;

	
	if(strlen((sc8*)buff)>30)
	{
	    clear_lcd();
		DrawTitle_to_row_Language2(2,"´íÎó:ÃÜÔ¿³¤¶È²»¶Ô!","Password length error!");
	}
	else
	{
		memset(WLANWP,0,sizeof(WLANWP));
		strcpy((s8*)WLANWP,(sc8*)buff);
		if(!StorageVariable())
		{
		    clear_lcd();
			DrawTitle_to_row_Language2(2,"ʧ°Ü!","failure!");
			WaitkeyAndAutoExit(3);
			return KEY_ReturnPrevious;
		}
		else
	    {
			strcpy(rak_strapi.uPskFrame.psk,(char*)WLANWP);
			printf("rak_strapi.uPskFrame.psk:<%s>\r\n",rak_strapi.uPskFrame.psk);
        	if(rak_set_psk(&rak_strapi.uPskFrame)!=RUN_OK)return retval;
		}
	}
	return (WaitkeyAndAutoExit(1));
}
char DisplayVersion (char *msg)
{
	char buff[60];
	char buffother[60];
	strcpy (  buff,  VersionString);
	strcpy (  buffother,  VersionString);
	clear_lcd();
	DrawTitle_to_row_Language2 (0, "软件版本", "Software Ver");
	text_out_to_row_Language2 (1, (unsigned char*)buff, (unsigned char*)buffother);
	text_out_to_row_Language2 (2,(unsigned char*)VersionDate,(unsigned char*)VersionDate);
	text_out_to_row_Language2 (3, "硬件版本:20130809", "HardVer:20130809");
	text_out_to_row_Language2 (4, "备注:KMY801D3", "Mark:KMY801D3");
	return (WaitkeyAndAutoExit (15) );
}
Example #6
0
static char PhoneHandleNameDelete(char *msg)
{
	char temp;

	#ifdef DEBUG_PRINTF
	printf("msg=%d\n",*msg);
	#endif

	temp=PhoneDeleteARecord(*msg);
	clear_lcd();
	if(temp==RIGHT_return){
		text_out_to_row_x_Language2(2,46,"已删除","Deleted");
	}else{
		text_out_to_row_x_Language2(2,40,"删除失败","Delete failure");
	}

	return (WaitkeyAndAutoExit(10));
}
Example #7
0
static char PhoneHandleSendmassage(char *msg)
{
	#if 1
	return(abeyant(NULL));
	#else
	char receive[60];

	GetString_abcABC123PYWuBi_Language2("短信输入","Msg input",SRF_123|SRF_BiHua|SRF_ABC|SRF_abc|SRF_PY,SRF_BiHua,receive,sizeof(receive),0);

	clear_lcd();
	DrawTitle_to_row_Language2(2,"正在发送短信","Sending message");
	if(SendMessage(receive,"15112475662")==Sim900B_ProccessOK){
		DrawTitle_to_row_Language2(3,"短信已成功发送","Sended");
	}else{
		DrawTitle_to_row_Language2(3,"短信发送失败","Send failure");
	}

	return WaitkeyAndAutoExit(10);
	#endif
}
Example #8
0
char set_apn (void)
{
	char Regist[200];
	char retval;
	char cnt = 0;

	clear_lcd();
	DrawTitle_to_row_Language2 (2, "正在设置APN", "Setting APN");
again:
	memset ( (char*) Regist, 0, sizeof (Regist) );
	strcat ( (char*) Regist, "AT+QICSGP=1,\"");
	strcat ( (char*) Regist, (char*) ApnApn);
	strcat ( (char*) Regist, "\",\"");
	strcat ( (char*) Regist, (char*) ApnUsername);
	strcat ( (char*) Regist, "\",\"");
	strcat ( (char*) Regist, (char*) ApnPassword);
	strcat ( (char*) Regist, "\"\r");
	retval = send_at_cmd_and_return ( (const unsigned char*) Regist, 3000, "OK", "ERROR");

	if (retval == TCP_OK)return retval;

	retval = GetKeyValue();

	if (retval == KEY_ReturnInitInterface || retval == KEY_ReturnPrevious) return TCP_ERROR;

	if (cnt++ > 7) return retval;

	retval = send_at_cmd_and_return ("AT+QIDEACT\r", 2000, "OK", "ERROR");

	if (retval == TCP_OK || retval == TCP_ERROR)
	{
		retval = WaitkeyAndAutoExit (3);

		if (retval == KEY_ReturnInitInterface || retval == KEY_ReturnPrevious) return TCP_ERROR;
	}

	goto again;
}
Example #9
0
//static char PhoneSearch(char *msg)
char PhoneSearch(char *msg)
{
	EFILE efile;
	u8 receive[12];
	u8 tempbuff[50];
	u8 dispbuff[50];
	int i;
	struct OperateDisplay disp={0,0, 0,0,MaxRowOneScr ,1};
	unsigned char retval;
	unsigned char keyval;

	retval=GetString_abcABC123PYWuBi_Language2("【输入姓名】","Input name",SRF_PY|SRF_BiHua|SRF_abc|SRF_ABC|SRF_123,SRF_abc,receive,sizeof(receive),0);
	if(retval!=KEY_Enter)return retval;
	if(strlen((sc8*)receive)==0)goto tuichu;

	loop:
	clear_lcd();
	//fp=fopen("PhoneBook","rb");
	retval=EepromFile_Open(file_phonebook,&efile);
	retval=EepromFile_ReadData(tempbuff,10,file_phonebook);
	if(retval==EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		disp.MenuTotal=atoi((sc8*)tempbuff);
	}else{
		DrawTitle_to_row_Language2(2,"没有记录","No record");
		goto tuichu;
	}

	retval=EepromFile_Open(file_phonebook,&efile);
	for(i=0;i<disp.MenuTotal;i++){
		EepromFile_Seek(&efile,10+i*98,EepromFile_SEEK_SET);
		EepromFile_read(dispbuff,12,&efile);
		if(my_FFstrstr((sc8*)dispbuff,(sc8*)receive)==1){
			disp.Menucnt=i;
			if(disp.Menucnt<disp.EndLine-disp.StartLine){
				disp.curFlashRow+=disp.Menucnt;
			}else{
				disp.curFlashRow=disp.EndLine-1;
			}
			break;
		}
	}

	if(i>=disp.MenuTotal){DrawTitle_to_row_Language2(2,"找不到此记录","Can't find record");goto tuichu;}

	while(1){
		if(disp.flashflag){
			disp.flashflag=0;

			for(i=disp.StartLine;i<disp.EndLine&&i<disp.MenuTotal+disp.StartLine;i++){
				//fseek(fp,10+(disp.Menucnt-disp.curFlashRow+i)*98,SEEK_SET);
				//fread(dispbuff,12,1,fp);
				EepromFile_Seek(&efile,10+(disp.Menucnt-disp.curFlashRow+i)*98,EepromFile_SEEK_SET);
				EepromFile_read(dispbuff,12,&efile);
				steaddraw_pic_to_row_x(PhoneNameIco,0,i,12,12);
				text_out_to_row_x_fillSpace(i,16,dispbuff);
			}

			DispHighLightRow_to_x(16,disp.curFlashRow);			//高亮
		}

		keyval=GetKeyValue();
		if(keyval == KEY_NONE) continue;
		KeyEventPost();

		switch(keyval){ 
			case KEY_UP:
			my_OperateDisplay_KEY_UP(&disp);
			break;

			case KEY_DOWN:
			my_OperateDisplay_KEY_DOWN(&disp);
			break;

			case KEY_Enter:
			case KEY_RIGHT:
			if(HandlePhoneSelection(disp.Menucnt)==KEY_ReturnInitInterface){
				//fclose(fp);
				return KEY_ReturnInitInterface;
			}
			disp.flashflag=1;
			disp.curFlashRow=0;
			//fclose(fp);
			goto loop;

			case KEY_ReturnPrevious:
			case KEY_ReturnInitInterface:
			case KEY_WaitTimeout:
			//fclose(fp);
			return keyval;
		}

	}

	tuichu:
	WaitkeyAndAutoExit(10);
	return 0;
}
Example #10
0
static char PhoneExplorer(char *msg)
{
	EFILE efile;
	u8 dispbuff[50];
	int i;
	struct OperateDisplay disp={0,0, 0,0,MaxRowOneScr ,1};
	unsigned char keyval;

	loop:
	clear_lcd();
	keyval=EepromFile_ReadData(dispbuff,10,file_phonebook);
	if(keyval==EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		disp.MenuTotal=atoi((sc8*)dispbuff);
		if(disp.MenuTotal==0){
			text_out_to_row_x_Language2(40,2,"没有记录","No record");
			goto tuichu;
		}
	}else{
		text_out_to_row_x_Language2(2,40,"没有记录","No record");
		goto tuichu;
	}

	keyval=EepromFile_Open(file_phonebook,&efile);

	while(1){
		if(disp.flashflag){
			disp.flashflag=0;
			
			for(i=disp.StartLine;i<disp.EndLine&&i<disp.MenuTotal+disp.StartLine;i++){
				EepromFile_Seek(&efile,10+(disp.Menucnt-disp.curFlashRow+i)*98,EepromFile_SEEK_SET);
				EepromFile_read(dispbuff,12,&efile);
				steaddraw_pic_to_row_x(PhoneNameIco,0,i,12,12);
				text_out_to_row_x_fillSpace(i,16,dispbuff);
			}

			DispHighLightRow_to_x(16,disp.curFlashRow);			//高亮
		}

		keyval=GetKeyValue();
		if(keyval == KEY_NONE) continue;

		KeyEventPost();
		switch(keyval){ 
			case KEY_UP:
			my_OperateDisplay_KEY_UP(&disp);
			break;

			case KEY_DOWN:
			my_OperateDisplay_KEY_DOWN(&disp);
			break;

			case KEY_Enter:
			case KEY_RIGHT:
			if(HandlePhoneSelection(disp.Menucnt)==KEY_ReturnInitInterface){return KEY_ReturnInitInterface;}
			disp.flashflag=1;
			//fclose(fp);
			goto loop;

			case KEY_ReturnPrevious:
			case KEY_ReturnInitInterface:
			case KEY_WaitTimeout:
			//fclose(fp);
			return keyval;
		}

	}

	tuichu:
	return (WaitkeyAndAutoExit(10));
}
Example #11
0
/************************************记录详情**********************************************/
static char HandlePhoneSelection(char numPhone)
{
	static u8 PhoneNumber[18],PhoneName[12],PhoneZuoJi[18],PhoneEmail[20],PhoneBeiZhu[30];

	EFILE efile;
	char dispbuff[11];
	u8 retval;
	static struct FunctionMenuAddIco2 Menu[5]={
		{PhoneNameIco,	PhoneName,	PhoneHandleName},
		{PhoneNumberIco,PhoneNumber,PhoneHandleNumber},
		{PhoneZuoJiIco,	PhoneZuoJi,	PhoneHandleZuoJi},
		{PhoneEmailIco,	PhoneEmail,	PhoneHandleEmail},
		{PhoneBeiZhuIco,PhoneBeiZhu,PhoneHandleBeiZhu},
	};
	struct OperateAddIco2 MenuOp={Menu,5,0 ,0,0,MaxRowOneScr, 1,0,0};

	if(Language[0]==LOCAL_LANGUAGE){
		strcpy((char *)PhoneNumber,(const char *)con_Chinese_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_Chinese_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_Chinese_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_Chinese_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_Chinese_PhoneBeiZhu);
		//strcpy((char *)PhoneSave,(const char *)con_Chinese_PhoneSave);
	}
	else{
		strcpy((char *)PhoneNumber,(const char *)con_English_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_English_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_English_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_English_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_English_PhoneBeiZhu);
		//strcpy((char *)PhoneSave,(const char *)con_English_PhoneSave);
	}

	loop:
	retval=EepromFile_ReadData((unsigned char *)dispbuff,10,file_phonebook);
	if(retval!=EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		clear_lcd();
		text_out_to_row_x_Language2(2,40,"没有记录","No record");
		return WaitkeyAndAutoExit(10);
	}

	retval=EepromFile_Open(file_phonebook,&efile);

	EepromFile_Seek(&efile,10+numPhone*98,EepromFile_SEEK_SET);
	EepromFile_read(PhoneName,PhoneNameSize,&efile);
	EepromFile_read(PhoneNumber,PhoneNumberSize,&efile);
	EepromFile_read(PhoneZuoJi,PhoneZuoJiSize,&efile);
	EepromFile_read(PhoneEmail,PhoneEmailSize,&efile);
	EepromFile_read(PhoneBeiZhu,PhoneBeiZhuSize,&efile);

	while(1){
		MenuHandler_AddIco2(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(&numPhone);
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;}  
			else{
				clear_lcd();
				MenuOp.flashflag=1;
				goto loop;
			}
		}else{
			return MenuOp.RetVal;
		}
	}

	#undef PhoneNumber
	#undef PhoneName
	#undef PhoneZuoJi
	#undef PhoneEmail
	#undef PhoneBeiZhu
	//#undef PhoneSave
}
Example #12
0
//按拼音排序保存一个记录
static u8 PhoneAddSave(u8 *receive,u16 size)
{
	char phonebuff[4096],*pphonebuff,*endphonebuff;
	char bufftemp[100];
	struct FunctionMenuAddIco *MenuPhoneAdd;
	int num;
	int i;

	clear_lcd();
	DrawTitle_to_row_Language2(2,"正在保存...","saving...");
	MenuPhoneAdd=(struct FunctionMenuAddIco *)receive;

	EepromFile_ReadData((unsigned char *)phonebuff,sizeof(phonebuff)-1,file_phonebook);

	pphonebuff=phonebuff;
	memset(bufftemp,0,sizeof(bufftemp));
	memcpy(bufftemp,pphonebuff,10);
	pphonebuff+=10;
	num=atoi((sc8*)bufftemp);
	endphonebuff=pphonebuff+num*98;	//endphonebuff  指向最后一条记录后面的空白处
	if(endphonebuff>&phonebuff[sizeof(phonebuff)-200]){
		text_out_to_row_x_Language2(3,40,"电话本已满","Phone book full");
		goto tuichu;
	}

	memset(bufftemp,0,50);	//按拼音次序找到要写入记录的位置
	for(i=0;i<num;i++){
		memcpy(bufftemp,pphonebuff,12);
		if(strcmp(bufftemp,(sc8*)MenuPhoneAdd->MenuStr)>0)break;
		pphonebuff+=98;
	}

	while(endphonebuff>pphonebuff){		//把要写入记录位置处的所有记录向后移一个记录的位置
		memcpy(bufftemp,endphonebuff-98,98);
		memcpy(endphonebuff,bufftemp,98);
		endphonebuff-=98;
	}

	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,12);	//读入要写入记录的信息
	MenuPhoneAdd++;pphonebuff+=12;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,18);
	MenuPhoneAdd++;pphonebuff+=18;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,18);
	MenuPhoneAdd++;pphonebuff+=18;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,20);
	MenuPhoneAdd++;pphonebuff+=20;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,30);

	num++;
	memset(bufftemp,0,10);
	sprintf(bufftemp,"%d",num);
	memcpy(phonebuff,bufftemp,10);

	i=EepromFile_WriteData((unsigned char*)phonebuff,num*99+100,file_phonebook);
	if(i==EepromFile_WriteOk){
		DrawTitle_to_row_Language2(3,"电话记录保存成功","save success");
	}else{
		DrawTitle_to_row_Language2(3,"电话记录保存失败","save failure");
	}

	tuichu:
	return (WaitkeyAndAutoExit(10));
}
Example #13
0
char SyncTime(char *msg)
{
	unsigned char buff[100]={0};
	unsigned char timezone;
        unsigned int year = 0;
        unsigned char year_H= 20;
        unsigned char year_L= 0;
        unsigned char month = 0;
        unsigned char day = 0;
        unsigned char hour = 0;
        unsigned char minute = 0;
        unsigned char second = 0;
	char YearofMonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
	char *p=NULL;

	clear_lcd();
	DrawTitle_to_row_Language2(2,"同步时间中","Sync time"); 		
	DrawTitle_to_row_Language2(3,"请稍等...","Please wait...");

    sprintf((char*)buff,"AT+QNTP=\"%s\",123\r",TimeServer);
	printf("buff:<%s>\r\n",buff);
	kmy_USART2SendString(buff);
	memset(buff,0,sizeof(buff));
	if(tcp_receive(buff,sizeof(buff),"+QNTP:",180)!=TCP_ReceiveOK) goto FailExit;
	if(strstr((char*)buff,"+QNTP: 0")==NULL) goto FailExit;
	
	kmy_USART2SendString("AT+CCLK?\r");
	printf("AT+CCLK?\r");
	if(tcp_receive(buff,sizeof(buff),"+CCLK:",10)!=TCP_ReceiveOK) goto FailExit;
	printf("buff:<%s>\r\n",buff);

//+CCLK: "14/05/30,09:36:29+00"	
        p=(char*)buff;
	p=strchr(p,'"');
	if(p==NULL)goto FailExit;
	p++;
	year_L=atoi(p);
	printf("year_L:<%d>\r\n",year_L);
	
	p=strchr(p,'/');
	if(p==NULL)goto FailExit;
	p++;
	month=atoi(p);
	printf("month:<%d>\r\n",month);

	p=strchr(p,'/');
	if(p==NULL)goto FailExit;
	p++;
	day=atoi(p);
	printf("day:<%d>\r\n",day);

	p=strchr(p,',');
	if(p==NULL)goto FailExit;
	p++;
	hour =atoi(p);
	printf("hour:<%d>\r\n",hour);

	p=strchr(p,':');
	if(p==NULL)goto FailExit;
	p++;
	minute=atoi(p);
	printf("minute:<%d>\r\n",minute);

	p=strchr(p,':');
	if(p==NULL)goto FailExit;
	p++;
	second=atoi(p);
	printf("second:<%d>\r\n",second);

	if(strchr((char*)TimeZone,'+'))
	{
		p=strchr((char*)TimeZone,'+');
		if(p!=NULL)
		{
			p++;
			timezone=atoi(p);
			hour+=timezone;
		}
		if(hour>=24)
		{
			hour-=24;
			day++;
		}
		
		year=year_H*100+year_L;
		
		if(day>YearofMonth[month])
		{
			 if(month==2)
			 {
				   if(year%4==0&&year%100!=0||year%400==0)
				   {
					   if(day>29)month++;
					   day=1;
				   }
				   else
				   {
					   month++;
					   day=1;
				   }
			 }
			 else
			 {
				   month++;
				   day=1;
			 }
		}
		
		if(month>12)
		{
			month=1;
			year++;
		}
	}
	else
	{
		p=strchr((char*)TimeZone,'-');
		if(p!=NULL)
		{
			p++;
			timezone=atoi(p);
			if(hour>=timezone)hour-=timezone;
			else
			{
				hour=24-(timezone-hour);
				day--;
			}
		}

		year=year_H*100+year_L;
		if(day==0)
		{
			month--;
			if(month==0)
			{
				month=12;
				year--;
			}	
			if(month==2)
			{
				   if(year%4==0&&year%100!=0||year%400==0)
				   {
					   day=29;
				   }
				   else
				   {
					   day=YearofMonth[month];
				   }
			 }
			 else
			 {
				   day=YearofMonth[month];
			 }
		}
	}	

	printf("Time:%4d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,minute,second);
	kmy_TimeSetTime (year, month, day, hour, minute, second);
	clear_lcd();
	DrawTitle_to_row_Language2(2,"同步时间成功!","Sync time success"); 
	return WaitkeyAndAutoExit(5);	
		
FailExit:	
	printf("buff:<%s>\r\n",buff);
	clear_lcd();
	DrawTitle_to_row_Language2(2,"同步时间失败!","Sync time fail"); 
	return WaitkeyAndAutoExit(5);
}
char Search_Wifi(char* msg)
{
	int retval=0;
	int WiFi_num=0;
//	char gateway[5]={0};

    clear_lcd();
    DrawTitle_to_row_Language2(2,"¡¾ÕýÔÚËÑË÷ÍøÂç...¡¿","Searching WiFi...");			

	kmy_EnableDisableTime3(0);

	if(rak_get_net_status()==RUN_OK)
	{
		memset(SSID,0,sizeof(SSID));
		if(rak_disconnect()!=RUN_OK)goto FAIL;
	}

    if(rak_uscan(&rak_strapi.uScanFrame)!=RUN_OK)goto FAIL;
	
	WiFi_num=uCmdRspFrame.scanResponse.ap_num;
	printf("WiFi_num:%d\r\n",WiFi_num);
	if(WiFi_num>RAK_GETSCAN_NUM)WiFi_num=RAK_GETSCAN_NUM;
	
	if(rak_getscan(&rak_strapi.uGetscan)!=RUN_OK)goto FAIL;

	retval = DisplayNetwork(WiFi_num);
	if((retval==KEY_ReturnInitInterface)||(retval==KEY_ReturnPrevious))
	{
		memset(SSID,0,sizeof(SSID));
		kmy_EnableDisableTime3(1);
		return retval;
	}

	retval = WPManage(NULL);	
	if((retval==KEY_ReturnInitInterface)||(retval==KEY_ReturnPrevious))
	{
		memset(SSID,0,sizeof(SSID));
		kmy_EnableDisableTime3(1);
		return retval;
	}

	clear_lcd();
	DrawTitle_to_row_Language2(2,"¡¾ÕýÔÚÁ¬½ÓÍøÂç...¡¿","Connecting WiFi...");

	strcpy(rak_strapi.uConnFrame.ssid,(char*)SSID);
	if(rak_connect(&rak_strapi.uConnFrame)!=RUN_OK)goto FAIL;
	
	if(rak_get_net_status()!=RUN_OK)goto FAIL;

	if(strchr((char*)dhcpclient,'1'))
	{
		if(rak_ipconfig_dhcp(RAK_DHCP_CLENT_ENABLE)!=RUN_OK)goto FAIL;		
		memcpy(&rak_strapi.uPingFrame.hostaddr,uCmdRspFrame.ipparamFrameRcv.gateway,4);
	}
	else
	{
		rak_asciiDotAddressTouint32((uint8 *)&rak_strapi.uIpstaticFrame.addr, (int8_t*)LocalIpPortBuf);
		rak_asciiDotAddressTouint32((uint8 *)&rak_strapi.uIpstaticFrame.mask, (int8_t*)MaskBuff);
		rak_asciiDotAddressTouint32((uint8 *)&rak_strapi.uIpstaticFrame.gw, (int8_t*)GatewayBuff);
		rak_asciiDotAddressTouint32((uint8 *)&rak_strapi.uIpstaticFrame.dns1, (int8_t*)DNSBuff);
		if(rak_set_ipstatic(&rak_strapi.uIpstaticFrame)!=RUN_OK)goto FAIL;		
		rak_strapi.uPingFrame.hostaddr=rak_strapi.uIpstaticFrame.gw;
	}
	
	if(rak_ping(&rak_strapi.uPingFrame)!=RUN_OK)goto FAIL;//ping geteway  

	if(rak_store_config()!=RUN_OK)goto FAIL;    	
	
	clear_lcd();
	DrawTitle_to_row_Language2(2,"³É¹¦!","Success!");
	
    rak_get_storeconfig();//get config infor
	printf("%s\r\n",uCmdRspFrame.paramFrame.rak_param.ssid);
	printf("%s\r\n",uCmdRspFrame.paramFrame.rak_param.psk);
    printf("Connect Success\r\n");
	FirstGetSSID=0;
	kmy_EnableDisableTime3(1);
    return WaitkeyAndAutoExit(5);
	
FAIL:
    //rak_get_socket_status();
    printf("Connect Fail\r\n");
	memset(SSID,0,sizeof(SSID));
	kmy_EnableDisableTime3(1);
    clear_lcd();
	DrawTitle_to_row_Language2(2,"ʧ°Ü!","Fail!");
    return WaitkeyAndAutoExit(10);
}