📄 gprs.c
字号:
/******************************************************************************
* File : Gprs.c
*
* Description : This file contains PilotMain() and other functions to
* implement the basic GSM / GPRS dialer.
*
* Designed by: Lalan J. Mishra (R49281)
* Coded by: Lalan J. Mishra
* Tested by: Lalan J. Mishra
* Organization: Freescale Semiconductor, Austin, Texas, (U.S.A.)
*
*
* Copy rights: Freescale Semiconductor, All rights reserved.
*
*
* History:
* Jan-12-2002 : Basic program with serial port communication readay.
* The prograams is now able to intiate and close data
* calls using the modem AT-commannds.
*
*****************************************************************************/
//------------------------------ Header File(s) Inclusion -------------------//
//
//
#include <PalmOS.h>
#include <SerialMgr.h>
#include "StarterRsc.h"
//
//
//--------------------------------------------------------------------------//
//----------------------------- Internal Structures ------------------------//
//
//
typedef struct
{
UInt8 replaceme;
} StarterPreferenceType;
typedef struct
{
UInt8 replaceme;
} StarterAppInfoType;
typedef StarterAppInfoType* StarterAppInfoPtr;
//
//
//----------------------------------------------------------------------------//
//--------------------- Global Variables Follow -----------------------------//
//
//
Err err;
UInt16 portId;
//LocalID dbID;
//
//
//---------------------------------------------------------------------------//
//----------------------------- Internal Constants -------------------------
//
//
#define appFileCreator 'STRT'
#define appVersionNum 0x01
#define appPrefID 0x00
#define appPrefVersionNum 0x01
// Define the minimum OS version we
// support (2.0 for now).
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
//
//
//--------------------------------------------------------------------------
//------------------- Internal Functions Prototypes -----------------------//
//
//
//
static void AppStop(void);
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags);
static void * GetObjectPtr(UInt16 objectID);
static Boolean MainFormDoCommand(UInt16 command);
static void MainFormInit(FormPtr);
static Err AppStart(void);
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr, UInt16 launchFlags);
static void AppEventLoop(void);
static Boolean AppHandleEvent(EventPtr eventP);
static Boolean MainFormHandleEvent(EventPtr eventP);
static Boolean MainFormButtonHandler(FormPtr frmP, EventPtr eventP);
//
//
//--------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function: PilotMain //
// Objective: //
// This is the MAIN ENTRY POINT for this application. //
// //
// Called by: //
// None. The application execution begins here. //
// Parameters: cmd - word value specifying the launch code. //
// cmdPBP - pointer to a structure that is associated with the //
// launch code. //
// launchFlags - word value providing extra information about //
// the launch. //
// Returned: Result of launch //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
return StarterPalmMain(cmd, cmdPBP, launchFlags);
}
//
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function: StarterPalmMain //
// Objective: //
// This is the ENTRY POINT for this application. //
// //
// Called by: //
// PilotMain(). //
// Parameters: cmd - word value specifying the launch code. //
// cmdPB - pointer to a structure that is associated with the //
// launch code. //
// launchFlags - word value providing extra information about //
// the launch. //
// Returned: Result of launch //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags)
{
Err error;
error = RomVersionCompatible (ourMinVersion, launchFlags);
if (error) return (error);
switch (cmd)
{
case sysAppLaunchCmdNormalLaunch:
error = AppStart();
if (error)
return error;
FrmGotoForm(MainForm);
AppEventLoop();
AppStop();
break;
default:
break;
}
return errNone;
}
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function: AppStart //
// Objective: //
// Get the current application's preferences. //
// //
// Called by: //
// StarterPalmMain(). //
// Parameters: None //
// Returned: Error value = 0 if nothing went wrong. //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
static Err AppStart(void)
{
StarterPreferenceType prefs;
UInt16 prefsSize;
Boolean serPortOpened = false;
// Read the saved preferences / saved-state information.
prefsSize = sizeof(StarterPreferenceType);
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
noPreferenceFound)
{
}
//FrmAlert(GPRSInitAlert);
err = SrmOpen (serPortCradlePort /* port */, 57600, /* baud */ &portId);
/* switch(err){
case errNone:
FrmAlert(CommNoErrAlert);
break;
case serErrAlreadyOpen:
FrmAlert (CommAlreadyOpenAlert);
break;
} */
return errNone;
}
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// //
// Function: AppStop //
// Objective: //
// Save the current state of the application and exit. //
// //
// Called by: //
// StarterPalmMain(). //
// Parameters: None //
// Returned: None //
// History: First created on Jan-12-2002 //
// //
//----------------------------------------------------------------------------//
//
//
//
static void AppStop(void)
{
StarterPreferenceType prefs;
// Write the saved preferences / saved-state information. This data
// will be backed up during a HotSync.
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
&prefs, sizeof (prefs), true);
// Close all the open forms.
SrmClose(portId);
FrmCloseAllForms ();
}
//
//
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -