亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? at.c

?? AVR單片機系統開發經典實例部分源程序
?? C
字號:
// this bit takes care of the AT modem dialing etc

/*
 * Copyright (C) 2003-2004 by Clive Moss All rights reserved.
 *
 * Help & Contributions from D.J.Armstrong

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY CLIVE MOSS 'AS IS' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.
 * IN NO EVENT SHALL CLIVE MOSS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

//#ifdef CPU_eZ8
//	#pragma stkck									// enable stack checking
//#endif

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

#include "common.h"
#include "at.h"
#include "ppp.h"

//*************************************************************************************

#ifdef Debug
flash char	ATStageStr1[]	=	"\n*** AT Stage: ";
flash char	ATStageStr2[]	=	"Idle\n";
flash char	ATStageStr3[]	=	"Dial Init 1\n";
flash char	ATStageStr4[]	=	"Dial Init 2\n";
flash char	ATStageStr5[]	=	"Dial Init 3\n";
flash char	ATStageStr6[]	=	"Dialing\n";
flash char	ATStageStr7[]	=	"PPP\n";
flash char	ATStageStr8[]	=	"Disc 1\n";
flash char	ATStageStr9[]	=	"Disc 2\n";
flash char	ATStageStr10[]	=	"Unknown\n";
flash char	ATStageStr20[]	=	"*** AT Retry Fail\n";
flash char	ATDialTermStr[]	=	"AT\n";
#endif

T_AT		AT;

//*************************************************************************************

#ifdef Debug

bool AT_DisplayStage(void)
{
	if(!SendDebugRStr(ATStageStr1)) return false;
	switch (AT.Stage)
	{
		case AT_Idle		:	return SendDebugRStr(ATStageStr2);
		case AT_DialInit1	:	return SendDebugRStr(ATStageStr3);
		case AT_DialInit2	:	return SendDebugRStr(ATStageStr4);
		case AT_DialInit3	:	return SendDebugRStr(ATStageStr5);
		case AT_Dial		:	return SendDebugRStr(ATStageStr6);
		case AT_PPP			:	return SendDebugRStr(ATStageStr7);
		case AT_Disc1		:	return SendDebugRStr(ATStageStr8);
		case AT_Disc2		:	return SendDebugRStr(ATStageStr9);
		default				:	return SendDebugRStr(ATStageStr10);
	}
}

#endif

//*************************************************************************************

void AT_Stage(T_AT_Stage Stage)
{	// set the AT modem stage
	if (AT.Stage == Stage) return;	// no change
									//
	AT.Stage = Stage;				//
	AT.Retries = 0;					//
	u16_Put(&AT.Retry_Timer, 0);	// send next thing asap

	#ifdef Debug
		AT_DisplayStage();
	#endif
}

bool AT_Start(void)
{	// start a connection attempt
	// call this from the executive when you want to connect
	if (AT.Stage != AT_Idle) return false;				// already busy with the modem
	#ifdef WindowsPPP
		AT_Stage(AT_PPP);								//
		PPP_Start(PPP_Rom_Username, PPP_Rom_Password);	// start a PPP session
		return true;									//
	#else
		AT_Stage(AT_DialInit1);							//
														//
		MainBufferWr_Rx = 0;							//
		MainBufferWr_Tx = 0;							//
		UART1_RxBufferRd = 0;							//
		UART1_RxBufferWr = 0;							//
														//
		return true;									//
	#endif
}

void AT_End(void)
{	// terminate a connection
	if (PPP.Stage != PPPS_None)
	{	// terminate the PPP first
		PPP_End();
		return;
	}

	#ifdef WindowsPPP
		AT_Stage(AT_Idle);
	#else
		switch (AT.Stage)
		{
			case AT_Idle		:	break;
			case AT_DialInit1	:	AT_Stage(AT_Idle);
									break;
			case AT_DialInit2	:	AT_Stage(AT_Idle);
									break;
			case AT_DialInit3	:	AT_Stage(AT_Idle);
									break;
			case AT_Dial		:	AT_Stage(AT_Disc2);
									break;
			case AT_PPP			:	PPP_End();
									break;
			case AT_Disc1		:	break;				// already trying to disconnect
			case AT_Disc2		:	break;				// already trying to disconnect
			default				:	AT_Stage(AT_Idle);
									break;
		}
	#endif
}

//*************************************************************************************
// call this when we have a new byte received from the modem - call from the executive

void AT_AddNewRxByte(u8 c)
{
	#ifndef WindowsPPP
		bool	ok = false;
		bool	error = false;
		bool	ring = false;
		bool	failed = false;
		bool	connect = false;

		if (c != 13)
		{
			if (c < 32) return;											// ignore control charcters
			if (MainBufferWr_Rx >= (sizeof(MainBuffer) - 1)) return;	// buffer overflow - ignore character
			if (MainBufferWr_Rx < 0) MainBufferWr_Rx = 0;
			MainBuffer[MainBufferWr_Rx++] = tolower((char)c);
			MainBuffer[MainBufferWr_Rx] = 0;
			return;
		}

		// CR

		strtrim(MainBuffer, ' ');
		MainBufferWr_Rx = 0;

		if (MainBuffer[0] == 0) return;									// empty line

		#ifdef Debug
			SendDebugStr(MainBuffer);
			SendDebugStr("\n");
		#endif

		if (strcmp((char*)MainBuffer, "ok") == 0) ok = true;
		else
		if (strcmp((char*)MainBuffer, "error") == 0) error = true;
		else
		if (strcmp((char*)MainBuffer, "ring") == 0) ring = true;
		else
		if (strcmp((char*)MainBuffer, "busy") == 0) failed = true;
		else
		if (strcmp((char*)MainBuffer, "no dialtone") == 0) failed = true;
		else
		if (strcmp((char*)MainBuffer, "no answer") == 0) failed = true;
		else
		if (strcmp((char*)MainBuffer, "no carrier") == 0) failed = true;
		else
		if ((strlen((char*)MainBuffer) >= 7) && (strncmp((char*)MainBuffer, "connect", 7) == 0)) connect = true;

		memset(MainBuffer, 0, sizeof(MainBuffer));

		if ((AT.Stage != AT_Dial) && failed)
		{
			AT_Stage(AT_Idle);
			return;
		}

		switch (AT.Stage)
		{
			case AT_DialInit1	:	if (ok) AT_Stage(AT_DialInit2);
									break;
			case AT_DialInit2	:	if (ok) AT_Stage(AT_DialInit3);
									break;
			case AT_DialInit3	:	if (ok) AT_Stage(AT_Dial);
									break;
			case AT_Dial		:	if (failed || error)
									{
										u16_Put(&AT.Retry_Timer, AT_Dial_Retry_Time);				// try again in 6 seconds
										break;
									}
			case AT_Idle		:	if (connect)
									{
										AT_Stage(AT_PPP);
										PPP_Start(PPP_Rom_Username, PPP_Rom_Password);		// start a PPP session
									}
									break;
			case AT_PPP			:	break;													// PPP is using the modem
			case AT_Disc1		:	if (ok || error) AT_Stage(AT_Disc2);					// the modem has come out of data mode - we used the '+++' thingy
									break;
			case AT_Disc2		:	if (ok) AT_Stage(AT_Idle);								// the modem accepted the hangup command(s)
									break;
			default				:	AT_Stage(AT_Idle);
									break;
		}
	#endif
}

//*************************************************************************************
// call this every 10ms - say from a timer interrupt

void AT_10ms_Timer(void)
{	// call this every 10ms
	#ifndef WindowsPPP
		if (AT.Stage == AT_Idle) return;

		if (AT.Retry_Timer >= 10)
			AT.Retry_Timer -= 10;
		else
			AT.Retry_Timer = 0;
	#endif
}

//*************************************************************************************
// call this as often as possible from your executive loop - NOT from an interrupt
// it takes care of all the AT modem stuff for you

void AT_Process(void)
{
	u8	c;

	#ifdef WindowsPPP
															//
		if (PPP.Stage != PPPS_None) return;					//
															//
		if (!MainBufferWr_Tx)
		{
			while (UART1_RxBufferRd != UART1_RxBufferWr)
			{
				c = (u8)UART1_RxBuffer[UART1_RxBufferRd++];													// get rx'ed byte
				if (UART1_RxBufferRd >= sizeof(UART1_RxBuffer)) UART1_RxBufferRd -= sizeof(UART1_RxBuffer);	// wap awound
				AT_AddNewRxByte(c);																			// pass the byte onto the AT RX routine
			}
		}

		#ifdef ModemHandShaking
		HardwareFlowControl(ModemUart);									// tell em to hold it - if need be
		#endif
																		//
		AT_Stage(AT_Idle);												//
	#else
		if (PPP.Stage != PPPS_None)				//
		{										//
			AT.Retries = 0;						//
			u16_Put(&AT.Retry_Timer, 0);		//
			return;								// PPP is busy
		}										//

		// **********************************
		// get any new data from the PPP uart

		if (!MainBufferWr_Tx)
		{
			while (UART1_RxBufferRd != UART1_RxBufferWr)
			{
				c = (u8)UART1_RxBuffer[UART1_RxBufferRd++];													// get rx'ed byte
				if (UART1_RxBufferRd >= sizeof(UART1_RxBuffer)) UART1_RxBufferRd -= sizeof(UART1_RxBuffer);	// wap awound
				AT_AddNewRxByte(c);																			// pass the byte onto the AT RX routine
			}
		}

		#ifdef ModemHandShaking
		HardwareFlowControl(ModemUart);									// tell em to stop sending data if our buffer is full
		#endif

		// **********************************

		if (AT.Stage == AT_Idle) return;								//
																		//
		if (u16_Get(&AT.Retry_Timer)) return;							// not time to retry
																		//
		if (AT.Retries >= AT_Retries)									//
		{																//
			#ifdef Debug
				SendDebugRStr(ATStageStr20);
			#endif

			AT_Stage(AT_Idle);											//
			return;														//
		}

		switch (AT.Stage)
		{
			case AT_Idle		:	break;
			case AT_DialInit1	:	SendModemRStr(DialInit1);
									u16_Put(&AT.Retry_Timer, AT_Timeout);
									AT.Retries++;
									#ifdef Debug
										SendDebugRStr(DialInit1);
									#endif
									break;
			case AT_DialInit2	:	SendModemRStr(DialInit2);
									u16_Put(&AT.Retry_Timer, AT_Timeout);
									AT.Retries++;
									#ifdef Debug
										SendDebugRStr(DialInit2);
									#endif
									break;
			case AT_DialInit3	:	SendModemRStr(DialInit3);
									u16_Put(&AT.Retry_Timer, AT_Timeout);
									AT.Retries++;
									#ifdef Debug
										SendDebugRStr(DialInit3);
									#endif
									break;
			case AT_Dial		:	SendModemRStr(DialStr);
									u16_Put(&AT.Retry_Timer, AT_Dial_Timeout);
									AT.Retries++;
									#ifdef Debug
										SendDebugRStr(DialStr);
									#endif
									break;
			case AT_PPP			:	AT_Stage(AT_Disc1);							// start disconnect sequence
									u16_Put(&AT.Retry_Timer, 2000);				// 2 second wait
									break;
			case AT_Disc1		:	SendModemStr("+++");						// get modem in command mode
									u16_Put(&AT.Retry_Timer, AT_Timeout);		//
									AT.Retries++;								//
									#ifdef Debug
										SendDebugStr("+++\n");
									#endif
									break;
			case AT_Disc2		:	SendModemStr("ATH\n");						// tell modem to hang up
									u16_Put(&AT.Retry_Timer, AT_Timeout);		//
									AT.Retries++;								//
									#ifdef Debug
										SendDebugStr("ATH\n");
									#endif
									break;
			default				:	AT_Stage(AT_Idle);
									break;
		}
	#endif

	// **********************************
}

//*************************************************************************************

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
老司机午夜精品99久久| aaa亚洲精品| 亚洲色图在线看| 一本色道久久综合精品竹菊| 国产精品欧美经典| 在线免费不卡视频| 日韩激情av在线| 久久精品欧美一区二区三区麻豆| 国产精品自拍在线| 国产精品久久毛片a| 日本高清无吗v一区| 久久99久久精品欧美| 久久亚洲一区二区三区明星换脸 | 日韩精品久久理论片| 久久综合九色综合97婷婷女人| 国产成人午夜视频| 天天免费综合色| 国产亚洲精品久| 欧美精品免费视频| 成人看片黄a免费看在线| 亚洲高清一区二区三区| 国产欧美一区二区三区沐欲| 欧美日韩一区不卡| 色久优优欧美色久优优| 成人精品一区二区三区中文字幕| 久久99在线观看| 免费久久精品视频| 麻豆中文一区二区| 日本一不卡视频| 99re热这里只有精品视频| 99精品国产一区二区三区不卡| 99久久综合国产精品| 欧洲av一区二区嗯嗯嗯啊| 欧美一区二区在线看| 欧美成人一区二区| 欧美韩日一区二区三区四区| 国产精品午夜免费| 午夜精品福利一区二区三区av| 日本欧美一区二区| 国产福利一区在线| 97se亚洲国产综合在线| 欧美精品一卡二卡| 日韩欧美激情在线| 国产日产精品一区| 欧美韩国日本综合| 亚洲成人免费视| 成人性视频网站| 精品美女在线观看| 亚洲美女视频在线| 韩国精品久久久| 欧美精品久久一区| 日韩码欧中文字| 成人综合在线观看| 久久久综合视频| 午夜久久久久久| 成人美女视频在线观看18| 国产在线播放一区三区四| 91毛片在线观看| 精品国产髙清在线看国产毛片| 亚洲女子a中天字幕| 国产一区视频在线看| 91精品国产综合久久福利软件 | 美国毛片一区二区三区| 色婷婷综合视频在线观看| 国产精品黄色在线观看| 国产一区二区三区精品视频 | 久久午夜国产精品| 欧美xxxx在线观看| 亚洲精品乱码久久久久| 欧美日韩综合在线免费观看| 亚洲天堂精品在线观看| 春色校园综合激情亚洲| 日韩午夜激情免费电影| 蜜桃视频一区二区三区在线观看| 精品三级在线看| 国产经典欧美精品| 中文字幕第一区| 91老师片黄在线观看| 性久久久久久久久久久久| 精品国产区一区| 91影视在线播放| 老色鬼精品视频在线观看播放| 久久久久久麻豆| 欧美www视频| 亚洲成人av电影| 久久免费偷拍视频| 色综合天天综合| 国产精品77777| 天堂va蜜桃一区二区三区| 国产亚洲精品7777| 91小视频在线观看| 日韩 欧美一区二区三区| 国产日韩精品一区二区浪潮av | 国产精品欧美极品| 欧美专区亚洲专区| 国产黄色精品视频| 亚洲大型综合色站| 亚洲欧美偷拍另类a∨色屁股| 91精品国产综合久久精品性色 | 欧美国产日韩a欧美在线观看| 欧美剧情片在线观看| 北岛玲一区二区三区四区| 麻豆精品新av中文字幕| 日韩在线一区二区| 亚洲激情男女视频| 国产情人综合久久777777| 欧美精品久久久久久久多人混战| 欧美老年两性高潮| 精品久久久久久最新网址| 丁香亚洲综合激情啪啪综合| aaa欧美大片| 欧美一区二区三区四区在线观看| 日韩欧美成人激情| 亚洲免费资源在线播放| 日韩精品高清不卡| 不卡视频一二三四| 欧美一区二区日韩| 亚洲男人电影天堂| 国产成人免费高清| 日韩黄色在线观看| 成人精品鲁一区一区二区| 国产在线精品视频| 蜜臀va亚洲va欧美va天堂| 国产成人免费视频网站| 天涯成人国产亚洲精品一区av| 日韩欧美在线观看一区二区三区| 国产成人精品免费在线| 欧美一区二区三区成人| 亚洲精品第一国产综合野| 91蜜桃免费观看视频| 亚洲国产sm捆绑调教视频| 看片网站欧美日韩| 91麻豆国产福利精品| 久久久久一区二区三区四区| 国产精品女主播在线观看| 日本大胆欧美人术艺术动态| 国产高清一区日本| 久久综合精品国产一区二区三区| 亚洲欧洲三级电影| 国模娜娜一区二区三区| 欧美三级日韩在线| 亚洲电影你懂得| 91女神在线视频| 国产农村妇女精品| 亚洲123区在线观看| 成人一区二区三区在线观看| 日韩欧美一级二级三级久久久| 一区二区三区国产豹纹内裤在线| 97久久精品人人做人人爽| 久久久久亚洲蜜桃| 激情另类小说区图片区视频区| 欧美久久久久久久久久| 亚洲乱码国产乱码精品精小说| 激情文学综合丁香| 精品国产99国产精品| 99久久精品免费看| 日韩中文字幕不卡| 久久国产尿小便嘘嘘尿| 欧美日韩免费观看一区三区| 日日噜噜夜夜狠狠视频欧美人| 欧美区一区二区三区| 亚洲精选视频在线| 欧美日韩大陆在线| 国产综合色视频| 中文字幕一区二区三区乱码在线| 福利一区二区在线| 天堂久久一区二区三区| 欧美刺激午夜性久久久久久久| 丰满白嫩尤物一区二区| 亚洲成人一区在线| 国产精品美女一区二区在线观看| 色婷婷久久综合| 国产福利视频一区二区三区| 国产精品福利电影一区二区三区四区| 在线观看日韩高清av| 久久99精品一区二区三区| 亚洲精品国产品国语在线app| 日韩欧美一级片| 日本电影亚洲天堂一区| 丁香另类激情小说| 国产乱子伦视频一区二区三区| 伊人开心综合网| 国产精品天干天干在线综合| www国产精品av| 欧美日本在线一区| 99re这里只有精品视频首页| 尤物在线观看一区| 国产婷婷一区二区| 欧美日韩一区不卡| 国产乱对白刺激视频不卡| 亚洲一区二区在线免费看| 精品国产乱码久久久久久蜜臀| 日韩欧美区一区二| 国产精品视频线看| 亚洲最大的成人av| 天堂一区二区在线| aaa亚洲精品一二三区| 欧美猛男超大videosgay| 久久亚洲一区二区三区明星换脸| 国产午夜精品一区二区三区嫩草|