⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gprs-app.c

📁 How to control GRPS comm in GSM module under SZ platform
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 *	Copy rights:	Freescale Semiconductor, All rights reserved.
 *	File	:		Gprs-App.c
 *
 * 	Description :	This file contains PilotMain() and other  functions to 
 *					implement the basic GSM / GPRS dialer.
 *
 *	Designed, Coded and Tested  by:  	Lalan J. Mishra (R49281)
 *	Organization:	Motorola Inc.:		Austin, Texas, (U.S.A.)
 *
 *
 *****************************************************************************/

//------------------------------ 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)

#define extAppEudoraWeb 'QCwb'

//
//
//--------------------------------------------------------------------------


//-------------------  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.         //
//																		   //	
//                                                                         //
//-------------------------------------------------------------------------//
//
//
//

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); 
                    
      
        			
   	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 ();
}

//
//
//----------------------------------------------------------------------------// 






//----------------------------------------------------------------------------//
//                                                                            //
//                      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:

				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;
					

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -