GPS Demo
```langua
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "sdk_api.h"
#undef ASSERT
#define ASSERT(cOND) {if (!(cOND)) {utilsAssertFail(#cOND, __FILE__, (short)__LINE__, 1);}}
#define sdk_uart_printf(fmt, args...) do { fatal_printf("[sdk]"fmt, ##args); } while(0)
#define sleep(x) OSATaskSleep((x) * 200)//second
#define _TASK_STACK_SIZE 1280
static UINT32 _task_stack[_TASK_STACK_SIZE/sizeof(UINT32)];
#define GPS_MSGQ_MSG_SIZE (sizeof(msgGPSDataParam))
#define GPS_MSGQ_QUEUE_SIZE (8)
static OSTaskRef _task_ref = NULL;
static OSATimerRef _timer_ref = NULL;
static void _timer_callback(UINT32 tmrId);
static void _task(void *ptr);
extern OSMsgQRef GpsDataMsgQ;
// Device bootup hook before Phase1Inits.
// If you have some work to be init, you may implete it here.
// ex: you may start your task here. or do some initialize here.
extern void Phase1Inits_enter(void);
// Device bootup hook after Phase1Inits.
// If you have some work to be init, you may implete it here.
// ex: you may start your task here. or do some initialize here.
extern void Phase1Inits_exit(void);
// Device bootup hook before Phase2Inits.
// If you have some work to be init, you may implete it here.
// ex: you may start your task here. or do some initialize here.
extern void Phase2Inits_enter(void);
// Device bootup hook after Phase2Inits.
// If you have some work to be init, you may implete it here.
// ex: you may start your task here. or do some initialize here.
extern void Phase2Inits_exit(void);
void Phase1Inits_enter(void)
{
}
void Phase1Inits_exit(void)
{
}
void Phase2Inits_enter(void)
{
}
void Phase2Inits_exit(void)
{
int ret;
ret = OSATimerCreate(&_timer_ref);
ASSERT(ret == OS_SUCCESS);
ret = OSAMsgQCreate(&GpsDataMsgQ, "gpsDataMsgQ", GPS_MSGQ_MSG_SIZE, GPS_MSGQ_QUEUE_SIZE, OS_FIFO);
ASSERT(ret == OS_SUCCESS);
ret = OSATaskCreate(&_task_ref, _task_stack, _TASK_STACK_SIZE, 80, "gps-task", _task, NULL);
ASSERT(ret == OS_SUCCESS);
OSATimerStart(_timer_ref, 6 * 200, 0, _timer_callback, 0); // 6 seconds timer
}
static void _timer_callback(UINT32 tmrId)
{
sdk_uart_printf("GPS Start!\n");
SDK_GPS_ON();
//SDK_GPS_OFF();
}
static void _task(void *ptr)
{
OSA_STATUS status;
UINT32 flag_value;
msgGPSDataParam gps_msg = {0, NULL};
char *gps_ptr = NULL;
while(1) {
status = OSAMsgQRecv(GpsDataMsgQ, (void *)&gps_msg, GPS_MSGQ_MSG_SIZE, OSA_SUSPEND);
ASSERT(status == OS_SUCCESS);
//sdk_uart_printf("_task gps_msg.len %d\n", gps_msg.len);
if (gps_msg.len){
gps_ptr = (char *)gps_msg.UArgs;
fatal_printf("%s", gps_ptr);
}
if (gps_msg.UArgs)
free(gps_msg.UArgs);
}
}
```