コード例 #1
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));
}
コード例 #2
0
static char PhoneHandleCall(char *msg)
{
	u8 phonebuff[20];
	u8 atcmd[50];
	EFILE efile;
	struct phoneleixing *ph;

	ph=(struct phoneleixing *)msg;

	clear_lcd();

	phonebuff[0]=EepromFile_Open(file_phonebook,&efile);

	memset(phonebuff,0,sizeof(phonebuff));

	if(ph->leixin==0)EepromFile_Seek(&efile,10+ph->numPhone*98+12,EepromFile_SEEK_SET);
	else EepromFile_Seek(&efile,10+ph->numPhone*98+12+18,EepromFile_SEEK_SET);
	EepromFile_read(phonebuff,18,&efile);

	DrawTitle_to_row_Language2(2,"正在拨号...","Dialing...");
	strcpy((char *)atcmd,"ATD");
	strcat((char *)atcmd,(const char *)phonebuff);
	strcat((char *)atcmd,";\r");
	send_at_cmd(atcmd);
	//text_out_to_row_x_Language2(1,25,phonebuff,phonebuff);
	phonebuff[0]=Waitkey_TillKeyPress();

	send_at_cmd("ATH\r");

	return phonebuff[0];
}
コード例 #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;
}
コード例 #4
0
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));
}
コード例 #5
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
}
コード例 #6
0
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) );
}
コード例 #7
0
/************************************光标在手机处菜单**********************************************/
static char PhoneHandleCall(char *msg)
{
	u8 phonebuff[20];
	u8 atcmd[50];
	EFILE efile;
	struct phoneleixing *ph;

	ph=(struct phoneleixing *)msg;

	clear_lcd();
	/*fp=fopen("PhoneBook","rb");
	if(fp!=NULL){		//如果有记录,则先把记录读到phonebuff 。
	#ifdef DEBUG_PRINTF
	printf("open PhoneBook success!!\n");
	#endif
	}else{
	#ifdef DEBUG_PRINTF
	printf("open PhoneBook failure!!\n");
	#endif
	return KEY_ReturnPrevious;
	}*/
	phonebuff[0]=EepromFile_Open(file_phonebook,&efile);

	memset(phonebuff,0,sizeof(phonebuff));
	/*if(ph->leixin==0)fseek(fp,10+ph->numPhone*98+12,SEEK_SET);
	else fseek(fp,10+ph->numPhone*98+12+18,SEEK_SET);
	fread(phonebuff,18,1,fp);*/
	if(ph->leixin==0)EepromFile_Seek(&efile,10+ph->numPhone*98+12,EepromFile_SEEK_SET);
	else EepromFile_Seek(&efile,10+ph->numPhone*98+12+18,EepromFile_SEEK_SET);
	EepromFile_read(phonebuff,18,&efile);

	DrawTitle_to_row_Language2(2,"正在拨号...","Dialing...");
	strcpy((char *)atcmd,"ATD");
	strcat((char *)atcmd,(const char *)phonebuff);
	strcat((char *)atcmd,";\r");
	send_at_cmd(atcmd);
	//text_out_to_row_x_Language2(1,25,phonebuff,phonebuff);
	phonebuff[0]=Waitkey_TillKeyPress();

	send_at_cmd("ATH\r");

	return phonebuff[0];
}
コード例 #8
0
ファイル: gprs.c プロジェクト: Weslen/First_Project
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;
}
コード例 #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;
}
コード例 #10
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));
}
コード例 #11
0
ファイル: SyncTime.c プロジェクト: Weslen/First_Project
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);
}
コード例 #12
0
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);
}
コード例 #13
0
ファイル: gprs.c プロジェクト: Weslen/First_Project
void PUK_Required(void)
{
	char ret,PinTimes[2],PukTimes[3];
	unsigned char CmdBuff[1024];
	unsigned char PUKin[20];
	unsigned char NewPin[7];
	unsigned char NewPin2[7];
	PasswordInputArgument arg;

	Again:
	ret=ReadPINPUKTimes((unsigned char *)PinTimes,(unsigned char *)PukTimes);
	if(ret==0)
	{
		clear_lcd();
		DrawTitle_to_row_Language2(0,"Input PUK","Input PUK");
		strcpy((char *)CmdBuff,"remain times:");
		
		strcat((char *)CmdBuff,PukTimes);
		DrawTitle_to_row_Language2(1,CmdBuff,CmdBuff);

		arg.clearlcdflag=0;
		arg.DiplayRow=2;
		arg.LocalTitle=NULL;
		arg.OtherTitle=NULL;
		arg.keyval=KEY_NONE;
		arg.receive=PUKin;
		arg.recSize=9;
		arg.xingflag=1;
		ret=PassWordInput(&arg);
		if(ret!=KEY_Enter)goto Again;
		if(strlen((char const*)PUKin)!=8)
		{
			clear_lcd();
			DrawTitle_to_row_Language2(2,"length error","length error");
			sleep(2);
			goto Again;
		}

		arg.clearlcdflag=1;
		arg.DiplayRow=2;
		arg.LocalTitle="Input New PIN";
		arg.OtherTitle="Input New PIN";
		arg.keyval=KEY_NONE;
		arg.receive=NewPin;
		arg.recSize=5;
		arg.xingflag=1;
		ret=PassWordInput(&arg);
		
		if(ret!=KEY_Enter)goto Again;
		if(strlen((char const*)NewPin)!=4)
		{
			clear_lcd();
			DrawTitle_to_row_Language2(1,"length error","length error");
			sleep(2);
			return;
		}

		arg.clearlcdflag=1;
		arg.DiplayRow=2;
		arg.LocalTitle="Again New PIN";
		arg.OtherTitle="Again New PIN";
		arg.keyval=KEY_NONE;
		arg.receive=NewPin2;
		arg.recSize=5;
		arg.xingflag=1;
		ret=PassWordInput(&arg);
		if(ret!=KEY_Enter)goto Again;
		if(strlen((char const*)NewPin)!=4)
		{
			clear_lcd();
			DrawTitle_to_row_Language2(1,"length error","length error");
			sleep(2);
			return;
		}
		if(strcmp((char const*)NewPin,(char const*)NewPin2)!=0)
		{
			clear_lcd();
			DrawTitle_to_row_Language2(2,"Two times input",NULL);
			DrawTitle_to_row_Language2(3,"is not same","takie same");
			sleep(2);
			goto Again;
		}

		strcpy((char *)CmdBuff,"AT+CPIN=\"");		//AT+CPIN="66612458","0907"
		strcat((char *)CmdBuff,(char const*)PUKin);
		strcat((char *)CmdBuff,"\",\"");
		strcat((char *)CmdBuff,(char const*)NewPin);
		strcat((char *)CmdBuff,"\"\r");
		ret=send_at_cmd_and_receive(CmdBuff,sizeof(CmdBuff),3000,"OK\r");
		if(ret!=TCP_OK)
		{
			clear_lcd();
			DrawTitle_to_row_Language2(2,"PUK Error","PUK Error");
			goto Again;
		}
		else
		{
			clear_lcd();
			DrawTitle_to_row_Language2(2,"PUK Right","PUK Right");
			sleep(2);
			return;
		}
	}
	else
	{
		goto Again;
	}
}