//
/* appli.c - Copyright Wavecom S.A. © 2006 /
/ /
/ /
/ DISCLAIMER OF WARRANTY /
/ ====================== /
/ This Software is provided free of charge on an ‘as is’ basis. No warranty is given /
/ by Wavecom S.A. in relation to the Software of the uses to which it may be put by you, /
/ the user, or its merchantability, fitness or suitability for any particular purpose /
/ or conditions; and/or that the use of the Software and all documentation relating /
/ thereto by the Licensee will not infringe any third party copyright or other /
/ intellectual property rights. Wavecom S.A. shall furthermore be under no obligation /
/ to provide support of any nature for the Software and the Documentation. /
/ /
/ LIMIT OF LIABILITY /
/ ================== /
/ In no event shall Wavecom S.A. be liable for any loss or damages whatsoever or howsoever /
/ caused arising directly or indirectly in connection with this licence, the Software, /
/ its use or otherwise except to the extent that such liability may not be lawfully /
/ excluded. Notwithstanding the generality of the foregoing, Wavecom S.A. expressly /
/ excludes liability for indirect, special, incidental or consequential loss or damage /
/ which may arise in respect of the Software or its use, or in respect of other equipment /
/ or property, or for loss of profit, business, revenue, goodwill or anticipated savings. /
/ */
//
//
/* File : Appli.c /
/------------------------------------------------------------------------------------------/
/ Object : File containing code related to main application /
/ -----------------------------------------------------------------------------------------/
/ Date | Author | Revision | Description /
/ ----------±----------±---------------±------------------------------------------------/
/ 09.02.07 | Wavecom P | 1.0 | /
/ | | | /
/ | | | /
/ | | | /
/-----------|-----------|----------------|-------------------------------------------------*/
//
/* Headers */
#include “adl_global.h”
#include “CGpsCore.h”
#include “math.h”
/* Macros */
#define APP_ATCMD_UART ADL_PORT_UART1
#define APP_GPS_UART ADL_PORT_UART2
/***********************************************************************/
/ Mandatory variables /
/-------------------------------------------------------------------------/
/ wm_apmCustomStackSize /
/-------------------------------------------------------------------------/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 4096;
/*******************************************************************/
/ Function : PrintCurrentFix /
/-------------------------------------------------------------------------/
/ Object : Get and print the current Fix /
/ /
/-------------------------------------------------------------------------/
/ Variable Name |IN |OUT|GLB| Utilisation /
/--------------------±–±--±–±---------------------------------------/
/ | | | | /
/--------------------±–±--±–±---------------------------------------/
/***************************************************************************/
void PrintCurrentFix()
{
app_GpsPosition_t CurPosition;
s8 sRet;
ascii RspBuffer[100];
/* Get the current position */
sRet = GetCurrentFix(&CurPosition);
if (sRet < 0)
{
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPS Sample: GPS Fix not obtained yet\r\n");
return;
}
/* Print the position on serial port */
/* Format==> Decimal degree */
wm_sprintf(RspBuffer, "\r\nGPS Sample: %0.06f %c, %0.06f %c\r\n",
fabs(CurPosition.Longitude),
CurPosition.dir[1],
fabs(CurPosition.Latitude),
CurPosition.dir[0]);
/* Send the buffer on serial */
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, RspBuffer);
}
/*******************************************************************/
/ Function : appTimerhdl /
/-------------------------------------------------------------------------/
/ Object : Timer handler /
/ /
/-------------------------------------------------------------------------/
/ Variable Name |IN |OUT|GLB| Utilisation /
/--------------------±–±--±–±---------------------------------------/
/ | | | | /
/--------------------±–±--±–±---------------------------------------/
/***************************************************************************/
void appTimerhdl(u8 TimerId)
{
PrintCurrentFix();
}
/*******************************************************************/
/ Function : AppCbGpsHandler /
/-------------------------------------------------------------------------/
/ Object : Callback related to GPS related events /
/ /
/-------------------------------------------------------------------------/
/ Variable Name |IN |OUT|GLB| Utilisation /
/--------------------±–±--±–±---------------------------------------/
/ | | | | /
/--------------------±–±--±–±---------------------------------------/
/***************************************************************************/
void AppCbGpsHandler(u8 Event)
{
switch(Event)
{
case APP_CGPS_INIT_DONE:
/* GPS init complete */
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPS Sample: GPS Core Initialisation Success\r\n");
/* Get and print the Fix */
PrintCurrentFix();
/* Start a timer to print the current Fix every 1 second */
adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, appTimerhdl );
break;
case APP_CGPS_INIT_FAILED:
/* GPS init failed, send the same to user */
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPS Sample: GPS Core Initialisation Failed\r\n");
break;
case APP_CGPS_FEATURE_NOT_ACTIVATED:
/* Feature not activated, inform the same to user */
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPS Sample: CGPS Feature not activated\r\n");
break;
}
}
/*******************************************************************/
/ Function : adl_main /
/-------------------------------------------------------------------------/
/ Object : Customer application initialisation /
/ /
/-------------------------------------------------------------------------/
/ Variable Name |IN |OUT|GLB| Utilisation /
/--------------------±–±--±–±---------------------------------------/
/ InitType | | | | Application start mode reason /
/--------------------±–±--±–±---------------------------------------/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE(( 2, “OAT_API_VERSION = %d”, OAT_API_VERSION ));
/* Init CGPS layer */
AppInitCoreGps (AppCbGpsHandler, APP_GPS_UART);
/* Send a response on AT command as other UART is dedicated to GPS */
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPS Sample: Application Started\r\n");
}