📄 gprs.c
字号:
// //
// Function: AppEventLoop //
// Objective: //
// This routine is the event loop for this application. //
// //
// Called by: //
// StarterPalmMain(). //
// Parameters: None //
// Returned: None //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
static void AppEventLoop(void)
{
UInt16 error;
EventType event;
do
{
EvtGetEvent(&event, evtWaitForever);
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! AppHandleEvent(&event))
FrmDispatchEvent(&event);
}
while (event.eType != appStopEvent);
}
//
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function: AppHandleEvent //
// Objective: //
// This routine loads form resources and set the event handler for //
// the form loaded. //
// Called by: //
// AppEventLoop(). //
// Parameters: eventP - a pointer to an EventType structure //
// Returned: true if the event has handle and should not be passed to a //
// higher level handler. //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
static Boolean AppHandleEvent(EventPtr eventP)
{
UInt16 formId;
FormPtr frmP;
if (eventP->eType == frmLoadEvent)
{
// Load the form resource.
formId = eventP->data.frmLoad.formID;
frmP = FrmInitForm(formId);
FrmSetActiveForm(frmP);
// Set the event handler for the form. The handler of the currently
// active form is called by FrmHandleEvent each time it receives an
// event.
switch (formId)
{
case MainForm:
FrmSetEventHandler(frmP, MainFormHandleEvent);
break;
default:
// ErrFatalDisplay("Invalid Form Load Event");
break;
}
return true;
}
return false;
}
//
//
//----------------------------------------------------------------------------//
//-----------------------------------------------------------------------------//
// //
// Function : MainFormHandleEvent //
// //
// //
// Objective: //
// This function is the event handler for the MainForm of this //
// application. //
// Called by: //
// AppHandleEvent(). //
// //
// Parameters: eventP - a pointer to an EventType structure //
// Returned: true if the event has handled and should not be passed //
// to a higher level handler. //
// History: First created on Jan-12-2002. //
// //
//-----------------------------------------------------------------------------//
//
//
//
static Boolean MainFormHandleEvent(EventPtr eventP)
{
Boolean handled = false;
FormPtr frmP;
switch (eventP->eType)
{
case menuEvent:
return MainFormDoCommand(eventP->data.menu.itemID);
break;
case ctlSelectEvent:
frmP = FrmGetActiveForm();
handled = MainFormButtonHandler(frmP, eventP);
break;
case frmOpenEvent:
frmP = FrmGetActiveForm();
MainFormInit( frmP);
FrmDrawForm ( frmP);
handled = true;
break;
default:
break;
}
return handled;
}
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function : MainFormButtonHandler //
// //
// Objective: //
// This function processes the events generated by the buttons on //
// the MainForm when they are pressed. //
// //
// Called by: //
// This function is called by MainFormHandleEvent()when the Main_ //
// Form Event Handler (MainFormHandleEvent()) finds that a //
// button pressed event has occured. //
// //
//----------------------------------------------------------------------------//
//
//
//
static Boolean MainFormButtonHandler(FormPtr frmP, EventPtr eventP)
{
Boolean handled = false;
UInt16 cardNo;
MemPtr Eud;
LocalID dbID;
char url[]="www.motorola.com";
DmSearchStateType SearchState;
char Dial[]="ATD*99#";
UInt16 TxDelay=25;
UInt8 CarrRet[] = {0x0d, 0x0a};
UInt8 DbleCot[] = {0x22};
char Comma[]=",";
char OnHook[]="AT+CKPD=e"; // Count=9
char Talk[] = "AT+CKPD=s"; // Count=9
char NumZero[]="AT+CKPD=48"; // Count=10
char NumOne []="AT+CKPD=49"; // Count=10
char NumTwo []="AT+CKPD=50"; // Count=10
char NumThree[]="AT+CKPD=51"; // Count=10
char NumFour[]="AT+CKPD=52"; // Count=10
char NumFive[]="AT+CKPD=53"; // Count=10
char NumSix[]="AT+CKPD=54"; // Count=10
char NumSeven[]="AT+CKPD=55"; // Count=10
char NumEight[]="AT+CKPD=56"; // Count=10
char NumNine[]="AT+CKPD=57"; // Count=10
char GprsInitMsgOne[]="AT"; // Count=2
char GprsInitMsgTwo[]="AT+CGATT?"; // Count=9
char GprsInitMsgThree[]="ATE0"; // Count=4
char GprsInitMsgFourA[]= "AT+CGDCONT=1,"; // Count=13
char GprsInitMsgFourB[]= "IP"; // Count=2
char GprsInitMsgFourC[]= "internet2.voicestream.com"; // Count=25
char GprsInitMsgFourD[]= ",,0,0"; // Count=5
char GprsInitMsgFive[]="AT+CGQREQ=1,0,0,3,0,0"; //Count=21
char GprsInitMsgSix[]="AT+CGQMIN=1,0,0,3,0,0"; //Count=21
char GprsInitMsgSeven[]="AT+IPR=57600"; //Count=12
char GprsInitMsgEight[]="ATZ"; //Count=3
char GprsInitMsgNine[]="ATE1V1" ; //Count=6
char GprsInitMsgTen[]="AT+IFC=2,2"; //Count=10
char GprsInitMsgEleven[]="ATS0=0"; //Count=6
char GprsInitMsgTwelve[]="AT+CGQREQ=1,0,0,3,0,0"; //Count=21
// Finding which button was pressed.
switch (eventP->data.ctlEnter.controlID)
{
case MainPhoneOnHookGraphicButton: // Key "On_Hook"
SrmSend(portId, &OnHook, 9, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainPhoneOffHookGraphicButton: // Key "Talk"
SrmSend(portId, &Talk, 9, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyZeroButton: // Key #0
SrmSend(portId, &NumZero, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyOneButton: // Key #1
SrmSend(portId, &NumOne, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyTwoButton: // Key #2
SrmSend(portId, &NumTwo, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyThreeButton: // Key #3
SrmSend(portId, &NumThree, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyFourButton: // Key #4
SrmSend(portId, &NumFour, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyFiveButton: // Key #5
SrmSend(portId, &NumFive, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeySixButton: // Key #6
SrmSend(portId, &NumSix, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeySevenButton: // Key #7
SrmSend(portId, &NumSeven, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyEightButton: // Key #8
SrmSend(portId, &NumEight, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyNineButton: // Key #9
SrmSend(portId, &NumNine, 10, &err);
SrmSend(portId, &CarrRet, 2, &err);
break;
case MainKeyStarButton: // Key "*"
SndPlaySystemSound(7);
break;
case MainKeyHashButton: // Key "#"
SndPlaySystemSound(7);
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -