#ifndef __GPS_DATA_H_
#define __GPS_DATA_H_

#include "stdint.h"
#include "pt.h"
#include "message.h"

#define GPS_PWREN_PIN 	GPIO_Pin_1
#define GPS_PWREN_PORT	GPIOB
#define GPS_PWREN_HIGH	GPS_PWREN_PORT->BSRR = GPS_PWREN_PIN
#define GPS_PWREN_LOW	  GPS_PWREN_PORT->BRR = GPS_PWREN_PIN
	
typedef struct SUT_GPS_INF
{
	unsigned char isGpsWork:1;//GPSģ�鹤����־
	unsigned char isGpsValid:1;//GPS��λ��־  0 GPSδ��λ  1 GPS�Ѷ�λ
	unsigned char isServerLogin:1;	 //GPS ���������ӳɹ���־
	unsigned char isAutoSend:1;//�Զ����ͱ�־
	unsigned char isGpsAuthOk:1;//GPS�Ƿ��Ȩ�ɹ�
//	unsigned char isFirstLocationSend:1;//is location package send and get ack or not after ath ok
  unsigned char GpsInactiveCt;//����û��Ӧ������ �������ڽ��յ���Ϣ������ ���������ʱ�䳤����λģ��
	
	unsigned char HostCmd;//�����·�������
	//unsigned short SendTime;//���͵���������ʱ���� ��Ϊ��λ
	//unsigned short GPSSendTime;
	unsigned int GPS_SecondCnt;
	unsigned short GPS_UploadTime;
	unsigned char GPS_TimeIndexBackup;
	
	unsigned char year;
	unsigned char month;
	unsigned char day;
	unsigned char hour;
	unsigned char minu;
	unsigned char sec;
	
	uint32_t longitue;//����
	uint32_t latitue;//�
	
	uint32_t speed;//�ٶ�
	uint32_t aspect;//��λ

	uint32_t AvgSpeed;//ƽ���ٶ�
	uint32_t speedbuf[5];

	uint32_t StatisticsMile ;//����ͳ��
//----------
	unsigned char Status;
	unsigned char Location[16];
	unsigned char Speed[8];
	unsigned char Time[8];		
	
	uint32_t testJD;
	uint32_t testWD;
	
	char NSFlag;//N ��γ S ��γ
	char EWFlag;//E ���� W ����
//	unsigned char reAthCnt;//resend ath time max 5
}SUT_GPS_INF;

#define GPS_TABLE_NUM 8

/****************************************************
�˴�����ij��Ⱥ���Ҫ��������Ȳ�����Message����ij���һ�»���ֶ��Ŵ���ʾȫ0��״̬�����Ӳ������ŵ�״̬
*****************************************************/
typedef struct SUT_MESS{
	unsigned char Update;
	unsigned char forcePullGroupOn;//ǿ����������
	unsigned char startCntFlag;
	unsigned char skipCnt;
	unsigned char GBKMess1[SMS_SIGNAL_LEN+1];//���һ������������β
	unsigned short len;
	unsigned char codeType;
}SUT_MESS;

extern SUT_MESS sutMess;
extern SUT_GPS_INF sutGpsInfo;
extern const unsigned short GPS_TimeTable[GPS_TABLE_NUM];
void GPSRestart(void);
void GPSStop(void);
void process_gps_data(char *buf,uint32_t size);
void GpsInternalChange();
PT_THREAD (ptGpsTask(struct pt *pt));
#endif