123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- #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
- // 终端属性上报
- #define TS_TERMINAL_ATTRIBUTEINFO_ANSWER 0x0107
- // 平台主动查询终端属性
- #define TS_PLATFORM_ATTRIBUTEINFO_ANSWER 0x8107
- //保留自定义
- //终端上传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 buBiaoICCID(unsigned char socketID);
- /********************************************************************************/
- #endif // GPS_STRUCT_H
|