Hello,
I did it, but the fastrack is reset several times, it is programmed to print the fix each minute, sometimes works for an hour, other times woks for three hours, but finish for reset.
any idea?
here is the code
/********************************************************************************************/
/* 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"
#include "wip.h"
#include "wip_atcmd.h"
#include "adl_rtc.h"
#include "adl_wd.h"
/* Macros */
#define APP_ATCMD_UART ADL_PORT_UART1
#define APP_GPS_UART ADL_PORT_UART2
adl_tmr_t *timer1, *timer2, *timer3, *timer4, *timer5, *timer6;
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 4096*3;
/***************************************************************************/
/* 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, 600, 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;
}
}
void SimHandler(u8 Event){
switch (Event)
{
case ADL_SIM_EVENT_REMOVED:
// adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_REMOVED\r\n");
break;
case ADL_SIM_EVENT_INSERTED:
// adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_INSERTED \r\n");
break;
case ADL_SIM_EVENT_FULL_INIT:
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_FULL_INIT\r\n");
AppInitCoreGps (AppCbGpsHandler, APP_GPS_UART);
break;
case ADL_SIM_EVENT_PIN_ERROR:
// adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_PIN_ERROR\r\n");
break;
case ADL_SIM_EVENT_PIN_OK:
// adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_PIN_OK\r\n");
break;
case ADL_SIM_EVENT_PIN_WAIT:
// adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "ADL_SIM_EVENT_PIN_WAIT\r\n");
break;
}
}
void gpio8_set(u8 gpio_config, void * Context)
{
adl_atCmdSend("at+wiom=1,\"GPIO8\",1,0","*",NULL);
adl_atSendResponsePort ( ADL_AT_RSP, APP_ATCMD_UART, "\r\nGPIO8 CONFIGURADO\r\n");
}
/***************************************************************************/
/* 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__ ));
timer2=adl_tmrSubscribe ( FALSE, 10, ADL_TMR_TYPE_100MS, gpio8_set );
/*subscripcion a comandos wip (libreria wipsoft)*/
wip_ATCmdSubscribe();
/*esperar a que suceda la inicializacion completa de la sim*/
ascii * PinCode = "NULL";
adl_simSubscribe( SimHandler, PinCode );
adl_wdDeActiveAppWd ();
}