|
@@ -5,13 +5,11 @@
|
|
#include <time.h>
|
|
#include <time.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
+#include "rtc.h"
|
|
//*整型
|
|
//*整型
|
|
int rlt;
|
|
int rlt;
|
|
-uint8_t xxtnewlength=0;
|
|
|
|
uint16_t uploadtime=0; //上传时间
|
|
uint16_t uploadtime=0; //上传时间
|
|
uint16_t hccd = 0;//ascii个数(*2)
|
|
uint16_t hccd = 0;//ascii个数(*2)
|
|
-uint8_t xxtfzData[100]; //放入封装后数据
|
|
|
|
-uint8_t tcppacket[100]; //消息数据
|
|
|
|
uint8_t header[12]; //处理头部
|
|
uint8_t header[12]; //处理头部
|
|
uint8_t index_2c = 0;
|
|
uint8_t index_2c = 0;
|
|
uint8_t MIPurc[100]; //接收平台数据
|
|
uint8_t MIPurc[100]; //接收平台数据
|
|
@@ -21,12 +19,14 @@ uint8_t speedBegin=0;
|
|
uint8_t speedEnd=0;
|
|
uint8_t speedEnd=0;
|
|
uint8_t speed[10]; //处理头部
|
|
uint8_t speed[10]; //处理头部
|
|
double dSpeed=0;
|
|
double dSpeed=0;
|
|
-double dWd=0;
|
|
|
|
-double dJd=0;
|
|
|
|
|
|
+double dlatitude=0;
|
|
|
|
+double dlongitude=0;
|
|
char cSpeed[10];
|
|
char cSpeed[10];
|
|
-char wd[15];
|
|
|
|
-char jd[15];
|
|
|
|
|
|
+char clatitude[15];
|
|
|
|
+char clongitude[15];
|
|
|
|
+char csatellitesNum[5];
|
|
char MGNSSLOC[100]; //接收定位数据
|
|
char MGNSSLOC[100]; //接收定位数据
|
|
|
|
+char CSQ[12]; //接收定位数据
|
|
|
|
|
|
char MGNSSLOC_time[6]; //接收定位数据
|
|
char MGNSSLOC_time[6]; //接收定位数据
|
|
uint32_t Stamp =0;
|
|
uint32_t Stamp =0;
|
|
@@ -36,21 +36,25 @@ TT808 tt808;
|
|
extern TipsFlag tipsflag;
|
|
extern TipsFlag tipsflag;
|
|
extern Menu_table menu;
|
|
extern Menu_table menu;
|
|
extern bool refresh;
|
|
extern bool refresh;
|
|
-extern Database db;
|
|
|
|
//*布尔
|
|
//*布尔
|
|
bool ZDJQflag = false;
|
|
bool ZDJQflag = false;
|
|
bool GnssFlag = false;
|
|
bool GnssFlag = false;
|
|
|
|
|
|
-void chuli(uint16_t XXID)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+uint8_t Messagetemp_length=0;
|
|
|
|
+uint8_t MessageHandleData[100]; //放入封装后数据
|
|
|
|
+uint8_t tcppacket[100]; //消息数据
|
|
|
|
+void MessageHandle(uint16_t MessageID)
|
|
{
|
|
{
|
|
|
|
|
|
- uint16_t XXTSXdata = xxtnewlength;
|
|
|
|
- XXTSXdata |= ( xxtnewlength | (TCPJMFSNULL<<10)); // 将长度左移3位后和加密方式进行按位或操作(001 RSA ,000 无加密)
|
|
|
|
|
|
+ uint16_t MessageAttributeData = Messagetemp_length;
|
|
|
|
+ MessageAttributeData |= ( Messagetemp_length | (TCPJMFSNULL<<10)); // 将长度左移3位后和加密方式进行按位或操作(001 RSA ,000 无加密)
|
|
|
|
|
|
- header[0] = ((XXID>>8)&0xff);
|
|
|
|
- header[1] = (XXID&0xff); //消息ID
|
|
|
|
- header[2] = ((XXTSXdata>>8)&0xff);
|
|
|
|
- header[3] = (XXTSXdata&0xff); //消息属性
|
|
|
|
|
|
+ header[0] = ((MessageID>>8)&0xff);
|
|
|
|
+ header[1] = (MessageID&0xff); //消息ID
|
|
|
|
+ header[2] = ((MessageAttributeData>>8)&0xff);
|
|
|
|
+ header[3] = (MessageAttributeData&0xff); //消息属性
|
|
header[4] = 0x00;
|
|
header[4] = 0x00;
|
|
header[5] = 0x00;
|
|
header[5] = 0x00;
|
|
header[6] = 0x16;
|
|
header[6] = 0x16;
|
|
@@ -69,10 +73,10 @@ void chuli(uint16_t XXID)
|
|
tcppacket[index++] = header[i];
|
|
tcppacket[index++] = header[i];
|
|
}
|
|
}
|
|
// Copy message body to packet
|
|
// Copy message body to packet
|
|
- for (size_t i = 0; i < xxtnewlength; i++) {
|
|
|
|
- tcppacket[index++] = xxtfzData[i];
|
|
|
|
|
|
+ for (size_t i = 0; i < Messagetemp_length; i++) {
|
|
|
|
+ tcppacket[index++] = MessageHandleData[i];
|
|
}
|
|
}
|
|
- tcppacket[index++] = xorBytes(&tcppacket[1],12+xxtnewlength);; // Set the checksum
|
|
|
|
|
|
+ tcppacket[index++] = xorBytes(&tcppacket[1],12+Messagetemp_length);; // Set the checksum
|
|
tcppacket[index++] = TT808FLAG; // Set the flag at the end
|
|
tcppacket[index++] = TT808FLAG; // Set the flag at the end
|
|
|
|
|
|
|
|
|
|
@@ -99,89 +103,93 @@ void chuli(uint16_t XXID)
|
|
|
|
|
|
/**
|
|
/**
|
|
* @breaf 消息体封装
|
|
* @breaf 消息体封装
|
|
- * xxt[] 消息数据; xxtlength 消息数据长度; outXxt[] 封装后消息数据; XXID 消息ID
|
|
|
|
|
|
+ * Message[] 消息数据; length 消息数据长度; outMessage[] 封装后消息数据; MessageID 消息ID
|
|
*/
|
|
*/
|
|
-uint8_t xxtFZ(uint8_t xxt[], uint8_t xxtlength, uint8_t outXxt[],uint16_t XXID)
|
|
|
|
|
|
+uint8_t Message_bodydata(uint8_t *Message, uint8_t length, uint8_t outMessage[],uint16_t MessageID)
|
|
{
|
|
{
|
|
int index = 0;
|
|
int index = 0;
|
|
- uint8_t newlength = 0;//加首尾 25/23/crc
|
|
|
|
|
|
+ uint8_t temp_length = 0;//加首尾 25/23/crc
|
|
|
|
|
|
- if(XXID==XXID_zdjq || XXID==XXID_zdxt)//不加头尾(鉴权、心跳)
|
|
|
|
|
|
+ if(MessageID==MessageID_authentication || MessageID==MessageID_heartbeat)//不加头尾(鉴权、心跳)
|
|
{
|
|
{
|
|
- newlength = xxtlength;//不加首尾
|
|
|
|
- uint8_t newXxt[newlength];
|
|
|
|
|
|
+ temp_length = length;//不加首尾
|
|
|
|
+ uint8_t temp_Message[temp_length];
|
|
|
|
|
|
- for (int i = 0; i < xxtlength; i++) {
|
|
|
|
- newXxt[index++] = xxt[i]; // 将消息头拷贝到报文中
|
|
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
|
+ temp_Message[index++] = Message[i]; // 将消息头拷贝到报文中
|
|
}
|
|
}
|
|
|
|
|
|
- newlength = index;
|
|
|
|
|
|
+ temp_length = index;
|
|
|
|
|
|
- for(int i =0;i<newlength;i++)
|
|
|
|
|
|
+ for(int i =0;i<temp_length;i++)
|
|
{
|
|
{
|
|
- outXxt[i]=newXxt[i];
|
|
|
|
|
|
+ outMessage[i]=temp_Message[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if(XXID==XXID_zddz) //终端地址
|
|
|
|
|
|
+ else if(MessageID==MessageID_location)//终端地址0200 有附加信息
|
|
{
|
|
{
|
|
|
|
|
|
- newlength = xxtlength;//不加首尾
|
|
|
|
- uint8_t newXxt[newlength];
|
|
|
|
|
|
+ temp_length = length+6;//不加首尾
|
|
|
|
+ uint8_t temp_Message[temp_length];
|
|
|
|
|
|
- for (int i = 0; i < xxtlength; i++) {
|
|
|
|
- newXxt[index++] = xxt[i]; // 将消息头拷贝到报文中
|
|
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
|
+ temp_Message[index++] = Message[i]; // 将消息头拷贝到报文中
|
|
}
|
|
}
|
|
//*begin
|
|
//*begin
|
|
- newXxt[index++] = 0xEB;
|
|
|
|
- //待添加
|
|
|
|
-
|
|
|
|
- //*end
|
|
|
|
- newlength = index;
|
|
|
|
|
|
+ temp_Message[index++] = 0x30;//信号强度关键字
|
|
|
|
+ temp_Message[index++] = 0x01;//信号强度数据长度
|
|
|
|
+ temp_Message[index++] = dblocptr->location.CSQ;//信号强度值
|
|
|
|
+ temp_Message[index++] = 0x31;//信号强度关键字
|
|
|
|
+ temp_Message[index++] = 0x01;//信号强度数据长度
|
|
|
|
+ temp_Message[index++] = dblocptr->location.satellitesNum;//卫星数量
|
|
|
|
|
|
- for(int i =0;i<newlength;i++)
|
|
|
|
|
|
+ for(int i =0;i<temp_length;i++)
|
|
{
|
|
{
|
|
- outXxt[i]=newXxt[i];
|
|
|
|
|
|
+ outMessage[i]=temp_Message[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else//加首尾
|
|
else//加首尾
|
|
{
|
|
{
|
|
- newlength = xxtlength+3;//加首尾 25/23/crc
|
|
|
|
- uint8_t newXxt[newlength];
|
|
|
|
|
|
+ temp_length = length+3;//加首尾 25/23/crc
|
|
|
|
+ uint8_t temp_Message[temp_length];
|
|
|
|
|
|
- newXxt[index++]=newlength;
|
|
|
|
- newXxt[index++]=0x2A;
|
|
|
|
- for (int i = 0; i < xxtlength; i++) {
|
|
|
|
- newXxt[index++] = xxt[i]; // 将消息头拷贝到报文中
|
|
|
|
|
|
+ temp_Message[index++]=temp_length;
|
|
|
|
+ temp_Message[index++]=0x2A;
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
|
+ temp_Message[index++] = Message[i]; // 将消息头拷贝到报文中
|
|
}
|
|
}
|
|
- newXxt[index++]=0x23;
|
|
|
|
- newXxt[index++]=xorBytes(&newXxt[1],newlength-1);
|
|
|
|
- newlength = index;
|
|
|
|
|
|
+ temp_Message[index++]=0x23;
|
|
|
|
+ temp_Message[index++]=xorBytes(&temp_Message[1],temp_length-1);
|
|
|
|
+ temp_length = index;
|
|
|
|
|
|
- for(int i =0;i<newlength;i++)
|
|
|
|
|
|
+ for(int i =0;i<temp_length;i++)
|
|
{
|
|
{
|
|
- outXxt[i]=newXxt[i];
|
|
|
|
|
|
+ outMessage[i]=temp_Message[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//test
|
|
//test
|
|
-// for (int i = 0; i < newlength; i++) {
|
|
|
|
-// printf("%02X ", newXxt[i]); // 以十六进制格式打印每个元素
|
|
|
|
|
|
+// for (int i = 0; i < temp_length; i++) {
|
|
|
|
+// printf("%02X ", temp_Message[i]); // 以十六进制格式打印每个元素
|
|
// }
|
|
// }
|
|
- return newlength;
|
|
|
|
|
|
+ return temp_length;
|
|
}
|
|
}
|
|
|
|
|
|
-/*需要传入消息体长度sizeof(xxt)/sizeof(xxt[0]);*/
|
|
|
|
-void tt808FsFunc(uint8_t xxt[], uint8_t xxtlength, uint16_t XXID)
|
|
|
|
|
|
+/*需要传入消息体长度sizeof(Message)/sizeof(Message[0]);*/
|
|
|
|
+void tt808FsFunc(uint8_t* Message, uint8_t length, uint16_t MessageID)
|
|
{
|
|
{
|
|
HAL_Delay(200);
|
|
HAL_Delay(200);
|
|
- xxtnewlength = xxtFZ(xxt, xxtlength, xxtfzData, XXID);
|
|
|
|
- chuli(XXID);
|
|
|
|
|
|
+ Messagetemp_length = Message_bodydata(Message, length, MessageHandleData, MessageID);
|
|
|
|
+ MessageHandle(MessageID);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+void printBytes(uint8_t *data, size_t length) {
|
|
|
|
+ for (size_t i = 0; i < length; i++) {
|
|
|
|
+ printf("%02x ", data[i]);
|
|
|
|
+ }
|
|
|
|
+ printf("\n");
|
|
|
|
+}
|
|
// 函数用于提取第7到第8个逗号之间的字符串
|
|
// 函数用于提取第7到第8个逗号之间的字符串
|
|
void extractString(char* receiveStr, char* result, uint8_t start, uint16_t end)
|
|
void extractString(char* receiveStr, char* result, uint8_t start, uint16_t end)
|
|
{
|
|
{
|
|
@@ -228,9 +236,18 @@ void extractString(char* receiveStr, char* result, uint8_t start, uint16_t end)
|
|
}
|
|
}
|
|
|
|
|
|
double convertToDouble(char* str) {
|
|
double convertToDouble(char* str) {
|
|
- double result;
|
|
|
|
- sscanf(str, "%lf", &result);
|
|
|
|
- return result;
|
|
|
|
|
|
+ if(str == csatellitesNum)
|
|
|
|
+ {
|
|
|
|
+ uint8_t result;
|
|
|
|
+ sscanf(str, "%hhu", &result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ double result;
|
|
|
|
+ sscanf(str, "%lf", &result);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
char hex2asc(const char *hex)
|
|
char hex2asc(const char *hex)
|
|
@@ -243,6 +260,11 @@ char hex2asc(const char *hex)
|
|
}
|
|
}
|
|
return asc;
|
|
return asc;
|
|
}
|
|
}
|
|
|
|
+uint8_t testHex2Asc(const char *hex) {
|
|
|
|
+ char asc = hex2asc(hex);
|
|
|
|
+ printf("Hex: %s\tASC: %d\n", hex, asc);
|
|
|
|
+ return asc;
|
|
|
|
+}
|
|
|
|
|
|
char *bin2hex(char *hex, const unsigned char *bin, int size)
|
|
char *bin2hex(char *hex, const unsigned char *bin, int size)
|
|
{
|
|
{
|
|
@@ -268,11 +290,24 @@ int hex2bin(unsigned char *bin, const char *hex)
|
|
return rlt;//长度
|
|
return rlt;//长度
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 将单个十六进制数转换为 BCD 码
|
|
|
|
+uint8_t hexToBcd(uint8_t hex) {
|
|
|
|
+ return ((hex / 10) << 4) | (hex % 10);
|
|
|
|
+}
|
|
|
|
+// 将整数数组中的所有十六进制数转换为 BCD 码
|
|
|
|
+void hexArrayToBcd(uint8_t* array, size_t length, uint8_t* out) {
|
|
|
|
+ array[3]+=8;
|
|
|
|
+ for (size_t i = 0; i < length; i++) {
|
|
|
|
+ out[i] = hexToBcd(array[i]);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//MgnssFlag = true;
|
|
void ReMIPURC(void)
|
|
void ReMIPURC(void)
|
|
{
|
|
{
|
|
//4D 49 50 55 52 43
|
|
//4D 49 50 55 52 43
|
|
if(U4_4GrecvBuff[1]==0x4D && U4_4GrecvBuff[2]==0x49 && U4_4GrecvBuff[3]==0x50 \
|
|
if(U4_4GrecvBuff[1]==0x4D && U4_4GrecvBuff[2]==0x49 && U4_4GrecvBuff[3]==0x50 \
|
|
- && U4_4GrecvBuff[4]==0x55 && U4_4GrecvBuff[5]==0x52 && U4_4GrecvBuff[6]==0x43 ) //监测平台回复+MIPURC:
|
|
|
|
|
|
+ && U4_4GrecvBuff[4]==0x55 && U4_4GrecvBuff[5]==0x52 && U4_4GrecvBuff[6]==0x43 && U4_4GrecvBuff[10] != 0x64) //监测平台回复+MIPURC:
|
|
{
|
|
{
|
|
uint8_t high_byte = (U4_4GrecvBuff[18]&0x0f) *10;
|
|
uint8_t high_byte = (U4_4GrecvBuff[18]&0x0f) *10;
|
|
uint8_t low_byte = U4_4GrecvBuff[19]&0x0f;
|
|
uint8_t low_byte = U4_4GrecvBuff[19]&0x0f;
|
|
@@ -289,7 +324,15 @@ void ReMIPURC(void)
|
|
memset(MIPurc1,0,100);
|
|
memset(MIPurc1,0,100);
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ //64 69 73 63 6f 6e 6e 22 2c 31 2c 31 "disconn"
|
|
|
|
+ else if(U4_4GrecvBuff[10]== 0x64 && U4_4GrecvBuff[11]== 0x69 && U4_4GrecvBuff[12]== 0x73 && U4_4GrecvBuff[13]== 0x63 && U4_4GrecvBuff[14]== 0x6f \
|
|
|
|
+ && U4_4GrecvBuff[15]== 0x6e && U4_4GrecvBuff[16]== 0x6e && U4_4GrecvBuff[17]== 0x22 \
|
|
|
|
+ && U4_4GrecvBuff[18]== 0x2c && U4_4GrecvBuff[19]== 0x31 && U4_4GrecvBuff[20]== 0x2c && U4_4GrecvBuff[21]== 0x31)
|
|
|
|
+ {
|
|
|
|
+ ML307AReset();
|
|
|
|
+ memset(U4_4GrecvBuff,0,BUFFER_SIZE);
|
|
|
|
+ }
|
|
|
|
+
|
|
//时间 纬度(北纬) 经度(东经) 水平精度因子 海拔高度 定位类型(1无,2 2d,3 3d) 运动角度 水平运动速度(KM/h) 水平运动速度(Knots) 日月年 卫星数量 差分定位标识(1单点,2差分)
|
|
//时间 纬度(北纬) 经度(东经) 水平精度因子 海拔高度 定位类型(1无,2 2d,3 3d) 运动角度 水平运动速度(KM/h) 水平运动速度(Knots) 日月年 卫星数量 差分定位标识(1单点,2差分)
|
|
//eg.+MGNSSLOC: 015032.301,3014.8605N,12001.9250E,1.8, 17.6, 3, 0.00, 3.6, 1.9, 080424, 12, 1
|
|
//eg.+MGNSSLOC: 015032.301,3014.8605N,12001.9250E,1.8, 17.6, 3, 0.00, 3.6, 1.9, 080424, 12, 1
|
|
else if((U4_4GrecvBuff[2]==0x47 || (U4_4GrecvBuff[0]==0x4F && U4_4GrecvBuff[1]==0x4B)) && MgnssFlag) //监测平台回复+MGNSSLOC OK4f4b
|
|
else if((U4_4GrecvBuff[2]==0x47 || (U4_4GrecvBuff[0]==0x4F && U4_4GrecvBuff[1]==0x4B)) && MgnssFlag) //监测平台回复+MGNSSLOC OK4f4b
|
|
@@ -303,8 +346,8 @@ void ReMIPURC(void)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- else if(U5_BTrecvBuff[0]==0x66 && U5_BTrecvBuff[1]==0x00 && U5_BTrecvBuff[2]==0x02 && U5_BTrecvBuff[3]==0x01)//解封接收
|
|
|
|
- {
|
|
|
|
|
|
+ else if(U5_BTrecvBuff[0]==0x66 && U5_BTrecvBuff[1]==0x00 && U5_BTrecvBuff[2]==0x02 && U5_BTrecvBuff[3]==0x01)//解封接收
|
|
|
|
+ {
|
|
if(U5_BTrecvBuff[4]==0x01)
|
|
if(U5_BTrecvBuff[4]==0x01)
|
|
{//接收完成
|
|
{//接收完成
|
|
tipsflag = FinshOK;
|
|
tipsflag = FinshOK;
|
|
@@ -333,9 +376,9 @@ void ReMIPURC(void)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
- else if(U5_BTrecvBuff[0]==0x66 && U5_BTrecvBuff[1]==0x00 && U5_BTrecvBuff[2]==0x03 && U5_BTrecvBuff[3]==0x01)//解封接收
|
|
|
|
- {
|
|
|
|
- if(U5_BTrecvBuff[4]==0x01)
|
|
|
|
|
|
+ else if(U5_BTrecvBuff[0]==0x66 && U5_BTrecvBuff[1]==0x00 && U5_BTrecvBuff[2]==0x03 && U5_BTrecvBuff[3]==0x01)//解封接收
|
|
|
|
+ {
|
|
|
|
+ if(U5_BTrecvBuff[4]==0x01)
|
|
{//接收完成
|
|
{//接收完成
|
|
tipsflag = FinshOK;
|
|
tipsflag = FinshOK;
|
|
HAL_Delay(1000);
|
|
HAL_Delay(1000);
|
|
@@ -365,11 +408,25 @@ void ReMIPURC(void)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- else if(U5_BTrecvBuff[0]==0x2B && U5_BTrecvBuff[1]==0x43 && U5_BTrecvBuff[2]==0x50 && U5_BTrecvBuff[3]==0x49 && U5_BTrecvBuff[4]==0x4E && \
|
|
|
|
|
|
+ else if(U5_BTrecvBuff[0]==0x2B && U5_BTrecvBuff[1]==0x43 && U5_BTrecvBuff[2]==0x50 && U5_BTrecvBuff[3]==0x49 && U5_BTrecvBuff[4]==0x4E && \
|
|
U5_BTrecvBuff[5]==0x3A && U5_BTrecvBuff[6]==0x20 && U5_BTrecvBuff[7]==0x53 && U5_BTrecvBuff[8]==0x49 && U5_BTrecvBuff[9]==0x4D && U5_BTrecvBuff[10]==0x20 && U5_BTrecvBuff[11]==0x52)//+CPIN: SIM R
|
|
U5_BTrecvBuff[5]==0x3A && U5_BTrecvBuff[6]==0x20 && U5_BTrecvBuff[7]==0x53 && U5_BTrecvBuff[8]==0x49 && U5_BTrecvBuff[9]==0x4D && U5_BTrecvBuff[10]==0x20 && U5_BTrecvBuff[11]==0x52)//+CPIN: SIM R
|
|
- {
|
|
|
|
|
|
+ {
|
|
reset4Gmodule = true;
|
|
reset4Gmodule = true;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ else if(U4_4GrecvBuff[1]== 0x4D && U4_4GrecvBuff[2]== 0x47 && U4_4GrecvBuff[3]== 0x4E && U4_4GrecvBuff[4]== 0x53 && U4_4GrecvBuff[5]== 0x53 \
|
|
|
|
+ && U4_4GrecvBuff[6]== 0x55 && U4_4GrecvBuff[7]== 0x52 && U4_4GrecvBuff[8]== 0x43 \
|
|
|
|
+ && U4_4GrecvBuff[9]== 0x3A && U4_4GrecvBuff[10]== 0x20 && U4_4GrecvBuff[11]== 0x22 && U4_4GrecvBuff[12]== 0x73 \
|
|
|
|
+ && U4_4GrecvBuff[19]== 0x31 )
|
|
|
|
+ {
|
|
|
|
+ MgnssFlag = true;
|
|
|
|
+ }
|
|
|
|
+ else if(U4_4GrecvBuff[1]== 0x43 && U4_4GrecvBuff[2]== 0x53 && U4_4GrecvBuff[3]== 0x51)//CSQ 信号
|
|
|
|
+ {
|
|
|
|
+ memcpy(CSQ,U4_4GrecvBuff,U4_4GrecvLength);
|
|
|
|
+ tt808.CSQ = (CSQ[6]&0xf*10)+(CSQ[7]&0xf);
|
|
|
|
+ memset(CSQ,0,12);
|
|
|
|
+ memset(U4_4GrecvBuff,0,BUFFER_SIZE);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -385,7 +442,7 @@ void MIPURCHandle(void)
|
|
if(PTXXID==XXID_pttyyd) //收到平台通用应答0x8001
|
|
if(PTXXID==XXID_pttyyd) //收到平台通用应答0x8001
|
|
{
|
|
{
|
|
|
|
|
|
- if(xxRE == XXID_zdjq)//回复鉴权ID
|
|
|
|
|
|
+ if(xxRE == MessageID_authentication)//回复鉴权ID
|
|
{
|
|
{
|
|
if(YESorNO==YES)
|
|
if(YESorNO==YES)
|
|
{
|
|
{
|
|
@@ -398,7 +455,7 @@ void MIPURCHandle(void)
|
|
}
|
|
}
|
|
memset(MIPurc,0,rlt);//rlt下发长度
|
|
memset(MIPurc,0,rlt);//rlt下发长度
|
|
}
|
|
}
|
|
- if(xxRE == XXID_zdxt)//回复鉴权ID
|
|
|
|
|
|
+ if(xxRE == MessageID_heartbeat)//回复鉴权ID
|
|
{
|
|
{
|
|
if(YESorNO==YES)
|
|
if(YESorNO==YES)
|
|
{
|
|
{
|
|
@@ -418,6 +475,8 @@ void MIPURCHandle(void)
|
|
uint8_t tcsjLen = MIPurc[13];
|
|
uint8_t tcsjLen = MIPurc[13];
|
|
memcpy(MIPurcXXTCSJ,&MIPurc[13],xxtcLen);
|
|
memcpy(MIPurcXXTCSJ,&MIPurc[13],xxtcLen);
|
|
printf("@得到透传数据,%d\r\n",tcsjLen);
|
|
printf("@得到透传数据,%d\r\n",tcsjLen);
|
|
|
|
+
|
|
|
|
+
|
|
memset(MIPurc,0,rlt);//rlt下发长度
|
|
memset(MIPurc,0,rlt);//rlt下发长度
|
|
|
|
|
|
}
|
|
}
|
|
@@ -429,38 +488,30 @@ void MIPURCHandle(void)
|
|
{
|
|
{
|
|
ZDJQflag = false;
|
|
ZDJQflag = false;
|
|
HAL_Delay(500);
|
|
HAL_Delay(500);
|
|
- uint8_t test[] = {0xAA}; //test心跳
|
|
|
|
- tt808FsFunc(test,1,XXID_zdxt); //test心跳
|
|
|
|
|
|
+ uint8_t test[] = {0x05}; //test心跳
|
|
|
|
+ tt808FsFunc(test,1,MessageID_heartbeat); //test心跳
|
|
uploadtime = HAL_GetTick();//获取首次发送状态信息基准时间
|
|
uploadtime = HAL_GetTick();//获取首次发送状态信息基准时间
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
time_t timestamp ;
|
|
time_t timestamp ;
|
|
-void time_bj(void) {
|
|
|
|
-
|
|
|
|
- struct tm timeinfo;
|
|
|
|
- timeinfo.tm_year = tt808.Rtime[0]+2000-1900;
|
|
|
|
- timeinfo.tm_mon = tt808.Rtime[1]-1;
|
|
|
|
- timeinfo.tm_mday = tt808.Rtime[2];
|
|
|
|
- timeinfo.tm_hour = tt808.Rtime[3];
|
|
|
|
- timeinfo.tm_min = tt808.Rtime[4];
|
|
|
|
- timeinfo.tm_sec = tt808.Rtime[5];
|
|
|
|
- timestamp = mktime(&timeinfo);
|
|
|
|
-
|
|
|
|
- db.timeStamp[0] = (timestamp >> 16)&0xFFFF;
|
|
|
|
- db.timeStamp[1] = (timestamp)&0xFFFF;
|
|
|
|
|
|
+void time_bj(void)
|
|
|
|
+{
|
|
|
|
+ struct tm timeinfo;
|
|
|
|
+ timeinfo.tm_year = tt808.Rtime[0]+2000-1900;
|
|
|
|
+ timeinfo.tm_mon = tt808.Rtime[1]-1;
|
|
|
|
+ timeinfo.tm_mday = tt808.Rtime[2];
|
|
|
|
+ timeinfo.tm_hour = tt808.Rtime[3]-8;
|
|
|
|
+ timeinfo.tm_min = tt808.Rtime[4];
|
|
|
|
+ timeinfo.tm_sec = tt808.Rtime[5];
|
|
|
|
+ timestamp = mktime(&timeinfo);
|
|
|
|
+
|
|
|
|
+ dblocptr->location.timeStamp = timestamp;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
void ReU4Proces(void)
|
|
void ReU4Proces(void)
|
|
{
|
|
{
|
|
if(GnssFlag)
|
|
if(GnssFlag)
|
|
@@ -471,37 +522,37 @@ void ReU4Proces(void)
|
|
// 调用函数提取字符串
|
|
// 调用函数提取字符串
|
|
extractString(MGNSSLOC, cSpeed,7 ,8);//采集
|
|
extractString(MGNSSLOC, cSpeed,7 ,8);//采集
|
|
dSpeed = convertToDouble(cSpeed); //转换浮点数
|
|
dSpeed = convertToDouble(cSpeed); //转换浮点数
|
|
- dSpeed*=100;
|
|
|
|
-
|
|
|
|
|
|
+ dSpeed*=10;
|
|
|
|
|
|
- // 调用函数提取字符串
|
|
|
|
- extractString(MGNSSLOC, wd,1 ,2);//采集
|
|
|
|
- dWd = convertToDouble(wd); //转换浮点数
|
|
|
|
- dWd*=10000;
|
|
|
|
|
|
|
|
// 调用函数提取字符串
|
|
// 调用函数提取字符串
|
|
- extractString(MGNSSLOC, jd,2 ,3);//采集
|
|
|
|
- dJd = convertToDouble(jd); //转换浮点数
|
|
|
|
- dJd*=10000;
|
|
|
|
|
|
+ extractString(MGNSSLOC, clatitude,1 ,2);//采集
|
|
|
|
+ dlatitude = convertToDouble(clatitude); //转换浮点数
|
|
|
|
+ dblocptr->location.latitude = convertGPS(dlatitude);
|
|
|
|
+
|
|
|
|
+ extractString(MGNSSLOC, clongitude,2 ,3);//采集
|
|
|
|
+ dlongitude = convertToDouble(clongitude); //转换浮点数
|
|
|
|
+ dblocptr->location.longitude = convertGPS(dlongitude);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ extractString(MGNSSLOC, csatellitesNum,10 ,11);//采集卫星个数
|
|
|
|
+ tt808.satellitesNum = convertToDouble(csatellitesNum); //转换浮点数
|
|
|
|
+ //printf("%d",tt808.satellitesNum);
|
|
|
|
|
|
- if(dSpeed !=0 && dWd!=0 &&dJd!=0) //有数据进行更新!
|
|
|
|
- {
|
|
|
|
- db.speed[0] = (uint16_t)dSpeed;
|
|
|
|
- db.WD_u16[0] = ((uint32_t)dWd >> 16) &0xffff;
|
|
|
|
- db.WD_u16[1] = ((uint32_t)dWd) &0xffff; // 打印提取到的字符串
|
|
|
|
- db.JD_u16[0] = ((uint32_t)dJd >> 16) &0xffff;
|
|
|
|
- db.JD_u16[1] = ((uint32_t)dJd) &0xffff;
|
|
|
|
|
|
|
|
-// printf("提取到的字符串为:%s\n", speed);
|
|
|
|
-// printf("Converted double: %.f\n", dSpeed);
|
|
|
|
-// printf("Converted double: %04X\n", db.speed[0]);
|
|
|
|
-// printf("提取到的字符串为:%s\n", wd);
|
|
|
|
-// printf("Converted double: %.f\n", dWd);
|
|
|
|
-// printf("Converted double: %04X%04X\n", db.WD_u16[0],db.WD_u16[1]);
|
|
|
|
-// printf("提取到的字符串为:%s\n", jd);
|
|
|
|
-// printf("Converted double: %.f\n", dJd);
|
|
|
|
-// printf("Converted double: %04X%04X\n", db.JD_u16[0],db.JD_u16[1]);
|
|
|
|
- if(menu.current == 0xBB)
|
|
|
|
|
|
+ dblocptr->location.speed = (uint16_t)dSpeed;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(dSpeed !=0 && dlongitude!=0 && dlatitude!=0) //有数据进行更新!
|
|
|
|
+ {
|
|
|
|
+ signal = true;
|
|
|
|
+
|
|
|
|
+ if(menu.current == 0xBB && tipsflag!= ConnOK)
|
|
|
|
+ {
|
|
|
|
+ menu.current = 0;
|
|
|
|
+ refresh=true;
|
|
|
|
+ }
|
|
|
|
+ else if(tipsflag == Back && signal)
|
|
{
|
|
{
|
|
menu.current = 0;
|
|
menu.current = 0;
|
|
refresh=true;
|
|
refresh=true;
|
|
@@ -509,18 +560,17 @@ void ReU4Proces(void)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- if(signal)
|
|
|
|
|
|
+ if(signal && sys_mode[0]!=0xFFFF)
|
|
{
|
|
{
|
|
- //signal = false;
|
|
|
|
|
|
+ signal = false;
|
|
menu.current = 0xBB;
|
|
menu.current = 0xBB;
|
|
tipsflag = Nosignal;
|
|
tipsflag = Nosignal;
|
|
refresh=true;
|
|
refresh=true;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- //printf("Time: %04X%04X\n", db.timeStamp[0],db.timeStamp[1]);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
memset(MGNSSLOC,0,100);
|
|
memset(MGNSSLOC,0,100);
|
|
|
|
|
|
}
|
|
}
|