#ifndef TSGPS_PROCESS_H #define TSGPS_PROCESS_H /******************************************************************************/ #define TSGPS_PACK_HEAD 0x7e #define TSGPS_PACK_END 0x7e /***ÖÕ¶ËͨÓÃÓ¦´ð***/ #define TS_TERMINAL_UNIVERSAL_ANSWER 0x0001 //ƽ̨ͨÓÃÓ¦´ð #define TS_PLATFORM_UNIVERSAL_ANSWER 0x8001 //ÖÕ¶ËÐÄÌø #define TS_TERMINAL_HEARTBEAT 0x0002 //·Ö°ü #define TS_SUBCONTRACTPACKET 0x8003 //ÖÕ¶Ë×¢²á #define TS_TERMINAL_REGISTRATION 0X0100 //ÖÕ¶Ë×¢²áÓ¦´ð #define TS_TERMINAL_REGISTRATION_REPLY 0X8100 //ÖÕ¶Ë×¢Ïú #define TS_TERMINAL_CANCELLATION 0x0003 //Öն˼øȨ #define TS_TERMINAL_AUTHENTICATION 0x0102 //ÉèÖÃÖն˲ÎÊý #define TS_SETTING_TERMINAL_PARAMETERS 0x8103 //²éѯÖն˲ÎÊý #define TS_QUERY_TERMINAL_PARAMETERS 0x8104 //²éѯÖն˲ÎÊýÓ¦´ð #define TS_QUERY_PARAMETER_RESPONSE_TERMINAL 0x0104 //Öն˿ØÖÆ #define TS_TERMINAL_CONTROL 0x8105 //λÖÃÐÅÏ¢»ã±¨ #define TS_LOCATION_INFORMATION_REPORTING 0x0200 //λÖÃÐÅÏ¢²éѯ #define TS_LOCATION_INFORMATION_INQUIRY 0x8201 //λÖÃÐÅÏ¢²éѯӦ´ð #define TS_LOCATION_INFORMATION_INQUIRY_RESPONSE 0x0201 //ÁÙʱλÖøú×Ù¿ØÖÆ #define TS_PROVISIONAL_INFORMATION_TRACKING_CONTROL 0x8202 //Îı¾ÐÅϢϷ¢ #define TS_TEXT_INFORMATION_ISSUED 0x8300 //ʼþÉèÖà #define TS_EVENT_SETTINGS 0x8301 //ʼþ±¨¸æ #define TS_EVENT_REPORT 0x0301 //ÌáÎÊÏ·¢ #define TS_QUESTION_ISSUED 0x8302 //ÌáÎÊÓ¦´ð #define TS_QUESTION_ANSWER 0x0302 //ÐÅÏ¢µã²¥²Ëµ¥ÉèÖà #define TS_INFORMATION_ON_DEMAND_MENU_SETTINGS 0x8303 //ÐÅÏ¢µã²¥/È¡Ïû #define TS_INFORMATION_ON_DEMAND_CANCELLATIONS 0x0303 //ÐÅÏ¢·þÎñ #define TS_INFORMATION_SERVICES 0x8304 //µç»°»Ø²¦ #define TS_CALL_BACK 0x8400 //ÉèÖõ绰±¾ #define TS_SET_THE_PHONE_BOOK 0x8401 //³µÁ¾¿ØÖÆ #define TS_THE_VEHICLE_CONTROL 0x8500 //³µÁ¾¿ØÖÆÓ¦´ð #define TS_VEHICLE_CONTROL_RESPONSES 0x0500 //ÉèÖÃÔ²ÐÎÇøÓò #define TS_SET_CIRCULAR_AREA 0x8600 //ɾ³ýÔ²ÐÎÇøÓò #define TS_REMOVE_CIRCULAR_AREA 0x8601 //ÉèÖþØÐÎÇøÓò #define TS_SETTING_RECTANGULAR_AREA 0x8602 //ɾ³ý¾ØÐÎÇøÓò #define TS_DELETE_RECTANGULAR_AREA 0x8603 //ÉèÖöà±ßÐÎÇøÓò #define TS_SET_POLYGON_AREA 0x8604 //ɾ³ý¶à±ßÐÎÇøÓò #define TS_DELETE_POLYGON_AREA 0x8605 //ÉèÖÃÏß· #define TS_SET_LINE 0x8606 //ɾ³ýÏß· #define TS_DELETE_SET_LINE 0x8607 //ÐÐÊ»¼Ç¼Êý¾Ý²É¼¯ÃüÁî #define TS_WITH_RECORD_DATA_COLLECTION 0x8700 //ÐÐÊ»¼Ç¼Êý¾ÝÉÏ´« #define TS_WITH_RECORDING_DATA_UPLOAD 0x0700 //ÐÐÊ»¼Ç¼²ÎÊýÏ´« #define TS_WITH_RECORDING_DATA_DOWNLINK 0x8101 //µç×ÓÔ˵¥Éϱ¨ #define TS_ELECTRONIC_WAYBILL_REPORTED 0x0701 //¼ÝʻԱÉí·ÝÐÅÏ¢²É¼¯Éϱ¨ #define TS_DRIVER_IDENTITY_DATA_COLLECTION 0x0702 //¶àýÌåʼþÐÅÏ¢ÉÏ´« #define TS_MULTIMEDIA_EVENT_UPLOAD 0x0800 //¶àýÌåÊý¾ÝÉÏ´« #define TS_MULTIMEDIA_DATA_UPLOAD 0x0801 //¶àýÌåÊý¾ÝÉÏ´«Ó¦´ð #define TS_MULTIMEDIA_DATA_UPLOAD_REPLY 0x8800 //ÉãÏñÍ·Á¢¼´ÅÄÉãÃüÁî #define TS_CAMERA_IMMEDIATELY_SHOOTING_COMMAND 0x8801 //´æ´¢¶àýÌåÊý¾Ý¼ìË÷ #define TS_STORING_MULTIMEDIA_DATA_RETRIEVAL 0x8802 //´æ´¢¶àýÌåÊý¾Ý¼ìË÷Ó¦´ð #define TS_STORING_MULTIMEDIA_DATA_RETRIEVAL_RESPONSE 0x0802 //´æ´¢¶àýÌåÊý¾ÝÉÏ´«ÃüÁî #define TS_STORING_MULTIMEDIA_DATA_UPLOAD_COMMAND 0x8803 //¼Òô¿ªÊ¼ÃüÁî #define TS_RECORDING_START_COMMAND 0x8804 //Êý¾ÝÏÂÐÐ͸´« #define TS_DOWNLINK_DATA_PASSTHROUGH 0x8900 //Êý¾ÝÉÏÐÐ͸´« #define TS_UPLINK_DATA_PASSTHROUGH 0x0900 //Êý¾ÝѹËõÉϱ¨ #define TS_DATA_COMPRESSION_REPORTING 0x0901 //ƽ̨RSA¹«Ô¿ #define TS_PLATFORM_RSA_PUBLIC_KEY 0x8A00 //ÖÕ¶ËRSA¹«Ô¿ #define TS_TERMINAL_RSA_PUBLIC_KEY 0x0A00 //±£Áô×Ô¶¨Òå //ÖÕ¶ËÉÏ´«SOSÏûÏ¢ #define TS_SEND_SOS_SMS 0x0F01 #define TS_TERMINAL_REQTIME 0x0F02 #define TS_PROID 0x44//Ê¡IDÈ¡Ç°Á½Î» 440000 #define TS_CITYID 0x0300//ÊÐIDÈ¡ºóËÄλ440300 #define PLATE 0x0100000000000000 #define MANUFACTURERS 3431303030 /*********************************** *typedef unsigned int (*Xingan_process_packet)(unsigned char *p_buf,unsigned short size); typedef struct XinganCmd_struct { unsigned int cmd; Xingan_process_packet process_packet; }XinganCmd_struct; ************************************/ typedef unsigned int (*TSGPS_process_packet)(unsigned char *p_buf,unsigned short size); typedef struct TSCmd_struct { unsigned int cmd; TSGPS_process_packet process_packet; }TSCmd_struct; /*************************************************************** 7E ±êʾλ 0100 ÏûÏ¢id 002D ÏûÏ¢ÊôÐÔ 015512341234 ÊÖ»úºÅ 0001 002C 01303431303030323031 3430 3400 0000000000 0000000000000000 30303030313131 01 ³µÅÆÑÕÉ« GBK ²ÉÓÃË«×Ó½Ú D4C1423738583134 ³µÅƺŠ3A УÑéÂë 7E ±êʾλ ****************************************************************/ typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned long DWORD; typedef unsigned int BOOL; //¶ÔÓ¦stringÀàÐÍ typedef struct STRING{ BYTE number[64]; short size; }STRING; //Êý¾Ý°ü·â×°Ïî typedef struct msgPacket{ WORD msgTotalCount;//×ÜÊý 16byte WORD msgPacketID; //°üÐòºÅ16byte }MSG_PACKET; typedef enum ENCRYPTYPE1{NO_ENCRYP=0,RSA=1}ENCRYPTYPE; typedef struct msgBodyAttrib{ BOOL bSepartePack;//ÊÇ·ñ·Ö°ü ENCRYPTYPE EncrypType; //¼ÓÃÜ int msgBodyLength; //ÏûÏ¢³¤¶È }AVL_MSG_BODY_ATTRIB; typedef struct msgHead{ WORD msgID;//ID 16byte WORD msgBodyAttrib; //ÏûÏ¢ÌåÊôÐÔ16byte WORD msgSimCard[6]; //µç»°ºÅÂë WORD msgNum; //ÏûÏ¢Á÷Ë®ºÅ WORD msgPacket; //·â°üÏî °ü·â×° }MSG_HEAD; /****************************** *3431303030ÖÆ×÷ÉÌID 3230313430340000000000000000000000000000ÖÕ¶ËÐͺŠ30303030313131 ÖÕ¶ËID ÑÕÉ«£º 1 À¶ 4 °× 2 »Æ 9 ÆäËû 3 ºÚ *********************************/ typedef struct registration{ WORD proID;//Ê¡ÓòID 16byte WORD CityID; //ÊÐÓòID16byte BYTE Manufacturers[5]; //ÖÆÔìÉÌ BYTE TerMod[20]; //ÖÕ¶ËÐͺŠ²»×ã²¹0x00 BYTE TerID[7]; //ÖÕ¶ËID ²»×ã²¹0x00 ±¾À´7¸ö×Ö½Ú ÎªÁ˸úÐÇ°²Ò»Ö ȡ4¸ö×Ö½Ú BYTE PlateColor; //³µÅÆÑÕÉ« δÉÏÅÆȡֵΪ0 // STRING Plate; //³µÅÆ BYTE Plate[8];//WORD 8 }REGISTRATION; //¼øȨ //ÓиöÎÊÌâ Èç¹ûÊÕµ½Êý¾ÝÀïÃæÓÐ7E»òÕß7DÊý¾Ý»áÏàÓ¦±ß³¤µ«ÊÇÐÒÔ˵ÄÊǼøȨ¶¼ÊÇÈÕÆÚʱ¼ä typedef struct Auth{ BYTE auth[7]; }AUTH; //SIM¿¨ºÅ typedef struct Sim{ BYTE SIM[6]; }SIM; //¶¨Î»ÏûÏ¢IDÊÇ0x0200 //Æðʼ×Ö½Ú ×ֶΠÊý¾Ý¸ñʽ ÃèÊö //0 ±¨¾¯±êÖ¾ DWORD //1 ״̬ DWORD //8 γ¶È DWORD ÒÔ¶ÈΪµ¥Î»µÄγ¶È³ËÒÔ10µÄ6´Î·½ ¾«È·µ½°ÙÍò·ÖÖ®Ò»¶¶È //12 ¾­¶È DWORD ͬγ¶È //16 ¸ß³Ì WORD º£°Î¸ß¶È£¬µ¥Î»(m) //18 ËÙ¶È WORD 1/10km/h //20 ·½Ïò WORD 0-359, 0, //21 ʱ¼ä BCD[6] YY-MM-DD-hh-mm-ss(GMT+8 ʱ¼ä ) //Ïêϸ²Î¿¼Îĵµ22Ò³ typedef struct SUT_GPS_SEND_DATA{ // unsigned int St;//±¨¾¯ int // unsigned int status; //״̬ int // unsigned int WWWW;//4 // unsigned int JJJJ;//¾­Î³¶È4 // unsigned short Mileag;//¸ß¶È Àï³Ì 2 // unsigned char SSFF;//ËÙ¶È ·½Î»½Ç 2 ×öÔÚÒ»Æð // unsigned char Acpect;//ËÙ¶È ·½Î»½Ç 1 ×öÔÚÒ»Æð // unsigned char Time[6];// ʱ¼ä unsigned int St; unsigned int status; unsigned char WWWW[4]; unsigned char JJJJ[4]; unsigned short Mileag; unsigned short SSFF; unsigned short Acpect; unsigned char Time[6]; }__attribute__((packed)) SUT_GPS_SEND_DATA;//__attribute__((packed)) typedef struct SUT_LCDGPS_SEND_DATA { unsigned char WWWW[4]; unsigned char JJJJ[4]; unsigned int W; unsigned int j; }SUT_LCDGPS_SEND_DATA; extern MSG_PACKET msgPacket; extern AVL_MSG_BODY_ATTRIB msgBodyAttrib; extern MSG_HEAD msghead; extern REGISTRATION Regist; extern SUT_GPS_SEND_DATA sutGpsSendData; extern SUT_LCDGPS_SEND_DATA sutLcdGpsSendData; void TSGpsDataInit(void); void TSGPS_GPRMC_Alysis(char *RMC_Data); void TSMakeGpsSendData(void); void TSGpsServerConect(void); void TSGpsSendData(void); int TSGpsPacket(unsigned char *Buffer,unsigned long PSN,unsigned short ID,unsigned char *pData,int DataLen); unsigned char TSGpsServerCheckPack(unsigned char *data,unsigned short DataLen); void TSGpsTimingSendPos(void); unsigned char TSGpsServerProcess(unsigned char *data, unsigned short DataLen); int reduce(unsigned char *pData,int DataLen); int escapse(unsigned char *pData,int DataLen); void Registration(void); void RegistrationLogout(void); void Authentication(void); int DectoBCD(int Dec, unsigned char *Bcd, int length); void getData(void); void TSRegData(void); void SIMReg(void); void TS_SendHeartTick(void); void TS_SendSOSMessage(void); void TS_ReqRealTime(void); void TSGpsSendPosition(void); /********************************************************************************/ #endif // GPS_STRUCT_H