|
@@ -19,6 +19,7 @@ uint8_t MIPurcXXTCSJ[100];//平台
|
|
|
uint8_t speedBegin=0;
|
|
|
uint8_t speedEnd=0;
|
|
|
uint8_t speed[10]; //处理头部
|
|
|
+int pushpullcount = 0;
|
|
|
double dSpeed=0;
|
|
|
double dlatitude=0;
|
|
|
double dlongitude=0;
|
|
@@ -54,6 +55,10 @@ void MessageHandle(uint16_t MessageID)
|
|
|
{
|
|
|
|
|
|
uint16_t MessageAttributeData = Messagetemp_length;
|
|
|
+ if(MessageID ==MessageID_Retrans)
|
|
|
+ {
|
|
|
+ MessageAttributeData+=3;
|
|
|
+ }
|
|
|
MessageAttributeData |= ( Messagetemp_length | (TCPJMFSNULL<<10)); // 将长度左移3位后和加密方式进行按位或操作(001 RSA ,000 无加密)
|
|
|
|
|
|
header[0] = ((MessageID>>8)&0xff);
|
|
@@ -120,7 +125,9 @@ uint8_t Message_bodydata(uint8_t *Message, uint8_t length, uint8_t outMessage[],
|
|
|
{
|
|
|
int index = 0;
|
|
|
uint8_t temp_length = 0;//加首尾 25/23/crc
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if(MessageID==MessageID_authentication || MessageID==MessageID_heartbeat)//不加头尾(鉴权、心跳)
|
|
|
{
|
|
|
temp_length = length;//不加首尾
|
|
@@ -137,23 +144,53 @@ uint8_t Message_bodydata(uint8_t *Message, uint8_t length, uint8_t outMessage[],
|
|
|
outMessage[i]=temp_Message[i];
|
|
|
}
|
|
|
}
|
|
|
- else if(MessageID==MessageID_location || MessageID==MessageID_Retrans)//终端地址0200 补传0704
|
|
|
+ else if(MessageID==MessageID_location)//终端地址0200 补传0704
|
|
|
{
|
|
|
|
|
|
temp_length = length;//不加首尾
|
|
|
//状态标志/纬度/经度/速度
|
|
|
+
|
|
|
+ uint8_t temp_Message[temp_length];
|
|
|
|
|
|
+
|
|
|
dblocptr->location.statusFlag = swapBytes32(dblocptr->location.statusFlag);
|
|
|
dblocptr->location.latitude = swapBytes32(dblocptr->location.latitude);
|
|
|
dblocptr->location.longitude = swapBytes32(dblocptr->location.longitude);
|
|
|
dblocptr->location.speed = swapBytes16(dblocptr->location.speed);
|
|
|
|
|
|
+ for (int i = 0; i < length; i++) {
|
|
|
+ temp_Message[index++] = Message[i]; // 将消息头拷贝到报文中
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for(int i =0;i<temp_length;i++)
|
|
|
+ {
|
|
|
+ outMessage[i]=temp_Message[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(MessageID==MessageID_Retrans)// 补传0704+5
|
|
|
+ {
|
|
|
+ temp_length = length;//不加首尾
|
|
|
+ //状态标志/纬度/经度/速度
|
|
|
+ dblocptr->temppull.statusFlag = swapBytes32(dblocptr->temppull.statusFlag);
|
|
|
+ dblocptr->temppull.latitude = swapBytes32(dblocptr->temppull.latitude);
|
|
|
+ dblocptr->temppull.longitude = swapBytes32(dblocptr->temppull.longitude);
|
|
|
+ dblocptr->temppull.speed = swapBytes16(dblocptr->temppull.speed);
|
|
|
+
|
|
|
uint8_t temp_Message[temp_length];
|
|
|
|
|
|
+ temp_Message[index++] = 0x00;
|
|
|
+ temp_Message[index++] = 0x01;
|
|
|
+ temp_Message[index++] = 0x00;
|
|
|
+ temp_Message[index++] = 0x00;
|
|
|
+ temp_Message[index++] = 0x22;
|
|
|
+
|
|
|
+
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
temp_Message[index++] = Message[i]; // 将消息头拷贝到报文中
|
|
|
}
|
|
|
|
|
|
+
|
|
|
for(int i =0;i<temp_length;i++)
|
|
|
{
|
|
|
outMessage[i]=temp_Message[i];
|
|
@@ -335,21 +372,21 @@ void ReMIPURC(void)
|
|
|
}
|
|
|
else if(strncmp((char*)U4_4GrecvBuff, "+MGNSSURC: \"state\",1", strlen("+MGNSSURC: \"state\",1"))==0)
|
|
|
{
|
|
|
- printf("#MGNSS设置成功\r\n");
|
|
|
+ printf("@MGNSS设置成功\r\n");
|
|
|
|
|
|
memset(U4_4GrecvBuff,0,strlen("+MGNSSURC: \"state\",1"));
|
|
|
}
|
|
|
|
|
|
else if(strncmp((char*)U4_4GrecvBuff, "+MGNSSURC: \"state\",0", strlen("+MGNSSURC: \"state\",0"))==0)//断开平台
|
|
|
{
|
|
|
- printf("#主动取消GNSS\r\n");
|
|
|
+ printf("@主动取消GNSS\r\n");
|
|
|
memset(U4_4GrecvBuff,0,strlen("+MGNSSURC: \"state\",0"));
|
|
|
}
|
|
|
|
|
|
else if(strncmp((char*)U4_4GrecvBuff, "+MIPURC: \"di", strlen("+MIPURC: \"di"))==0)//"disconn" 平台断连
|
|
|
{
|
|
|
Offline=true;
|
|
|
- printf("与平台断开连接\r\n");
|
|
|
+ printf("@与平台断开连接\r\n");
|
|
|
//ML307AReset();//与平台断开连接 offline
|
|
|
memset(U4_4GrecvBuff,0,BUFFER_SIZE);
|
|
|
}
|
|
@@ -359,7 +396,7 @@ void ReMIPURC(void)
|
|
|
{
|
|
|
Offline=false;
|
|
|
Online = true;
|
|
|
- printf("设备已上线!!\r\n");
|
|
|
+ printf("@设备已上线!!\r\n");
|
|
|
module4G_F = true;
|
|
|
menu.current = 0xBB;
|
|
|
tipsflag = Back;
|
|
@@ -378,7 +415,7 @@ void ReMIPURC(void)
|
|
|
else if((strncmp((char*)U4_4GrecvBuff, "+CPIN: SIM REMOVED", strlen("+CPIN: SIM REMOVED"))==0) || (strncmp((char*)U4_4GrecvBuff, "+CME ERROR: 10", strlen("+CME ERROR: 10"))==0) )//无SIM
|
|
|
{
|
|
|
//TODO
|
|
|
- printf("SIM卡缺失\r\n");
|
|
|
+ printf("@SIM卡缺失\r\n");
|
|
|
Offline=true;
|
|
|
signal = false;
|
|
|
menu.current = 0xBB;
|
|
@@ -391,8 +428,8 @@ void ReMIPURC(void)
|
|
|
{
|
|
|
//TODO
|
|
|
Offline=true;
|
|
|
- printf("#与平台断开连接\r\n");
|
|
|
- ML307AReset();//与平台断开连接 offline
|
|
|
+ signal = false;
|
|
|
+ printf("@与平台断开连接\r\n");
|
|
|
memset(U4_4GrecvBuff,0,BUFFER_SIZE);
|
|
|
|
|
|
}
|
|
@@ -401,7 +438,7 @@ void ReMIPURC(void)
|
|
|
{
|
|
|
//TODO
|
|
|
Offline=true;
|
|
|
- printf("#PDP激活是败\r\n");
|
|
|
+ printf("@PDP激活失败\r\n");
|
|
|
memset(U4_4GrecvBuff,0,BUFFER_SIZE);
|
|
|
|
|
|
}
|
|
@@ -537,10 +574,10 @@ void ReU4Proces(void)
|
|
|
dblocptr->location.longitude = convertGPS(dlongitude);
|
|
|
|
|
|
|
|
|
- printf("%d\r\n",dblocptr->location.latitude);
|
|
|
- printf("%d\r\n",dblocptr->location.longitude);
|
|
|
- printf("%08X\r\n",dblocptr->location.latitude);
|
|
|
- printf("%08X\r\n",dblocptr->location.longitude);
|
|
|
+// printf("%d\r\n",dblocptr->location.latitude);
|
|
|
+// printf("%d\r\n",dblocptr->location.longitude);
|
|
|
+// printf("%08X\r\n",dblocptr->location.latitude);
|
|
|
+// printf("%08X\r\n",dblocptr->location.longitude);
|
|
|
|
|
|
extractString(MGNSSLOC, csatellitesNum,10 ,11);//采集卫星个数
|
|
|
dblocptr->location.satellitesNum = convertToDouble(csatellitesNum); //转换浮点数
|
|
@@ -587,59 +624,65 @@ int countregular = 0;
|
|
|
void Regular_reporting_Loc(void)
|
|
|
{
|
|
|
countregular+=1;
|
|
|
- dblocptr->location.alarmFlag=0x00000000;
|
|
|
- dblocptr->location.statusFlag=0x00000002;
|
|
|
- dblocptr->location.height=0x0000;
|
|
|
- dblocptr->location.direction=0x0000;
|
|
|
- dblocptr->location.signalCmd=0x30;
|
|
|
- dblocptr->location.signalCmd_len=0x01;
|
|
|
- dblocptr->location.atellitesCmd=0x31;
|
|
|
- dblocptr->location.atellitesCmd_len=0x01;
|
|
|
+ if(countregular==3 && !Offline )//在线状态10s更新状态,30s上传 (各种状态正常在线,直接上传信息)
|
|
|
+ {
|
|
|
+ countregular=0;
|
|
|
+ tt808FsFunc((uint8_t*)&(dblocptr->location.alarmFlag), 34, MessageID_location);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if(Offline)//掉线状态10s入库定位记录
|
|
|
+}
|
|
|
+
|
|
|
+void pushpullWork(void)
|
|
|
+{
|
|
|
+ pushpullcount++;
|
|
|
+ if(Offline && pushpullcount==10000)//掉线状态10s入库定位记录
|
|
|
{
|
|
|
- printf("设备掉线,执行入库操作!!\r\n");
|
|
|
+
|
|
|
+ RTCtime();//写入做参考
|
|
|
+ printf("@@@设备掉线,执行入库操作!!%d\r\n",dblocptr->temppush.loc_pushIndex);
|
|
|
Database_Push(0);
|
|
|
|
|
|
//*每10s重连平台
|
|
|
char TCPconnvalue[100];
|
|
|
TcpConn(TCPconnvalue, 1, JLPTIP, JLPTPORT,0); //cid=1 tcpConnmode=0 普通模式
|
|
|
- if(sendCmd_4G(TCPconnvalue, "+MIPOPEN: 1,0", 1, 3)) //TCP连接 0普通模式 2缓存模式 1透传模式
|
|
|
+ if(sendCmd_4G(TCPconnvalue, "+MIPOPEN: 1,0", 1, 1)) //TCP连接 0普通模式 2缓存模式 1透传模式
|
|
|
{
|
|
|
- printf("#TCP连接完成\r\n");
|
|
|
+ printf("@@@TCP连接完成\r\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- printf("#重连失败!\r\n");
|
|
|
+ printf("@@@重连失败!\r\n");
|
|
|
}
|
|
|
- }
|
|
|
- else if(countregular==2 && Retrans && MiddleObj)//重传 7e0704002701820200777700060001000022000000000000000301cd8b7007278acd00000000000023051918174830011e310103b77e
|
|
|
+ }
|
|
|
+ else if(Retrans && MiddleObj)//重传 7e0704002701820200777700060001000022000000000000000301cd8b7007278acd00000000000023051918174830011e310103b77e
|
|
|
{
|
|
|
- countregular=0;
|
|
|
- tt808FsFunc((uint8_t*)&(dblocptr->temppull.alarmFlag), 34, MessageID_Retrans);
|
|
|
+
|
|
|
+ tt808FsFunc((uint8_t*)&(dblocptr->temppull.alarmFlag), 39, MessageID_Retrans);
|
|
|
printf("出库%d操作完成,当前索引%d\r\n",dblocptr->headinfo.loc_pullIndex-1,dblocptr->headinfo.loc_pullIndex);
|
|
|
MiddleObj = false;
|
|
|
}
|
|
|
- else if(Online && !MiddleObj) //上线出库
|
|
|
+ else if(Online && !MiddleObj && pushpullcount==1000) //上线出库
|
|
|
{
|
|
|
+ pushpullcount=0;
|
|
|
if(dblocptr->headinfo.loc_pushIndex==0)
|
|
|
{
|
|
|
- printf("更新上线标识,库内无数据\r\n");
|
|
|
+ printf("@@@更新上线标识,库内无数据\r\n");
|
|
|
Online = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- printf("库内有数据,执行操作\r\n");
|
|
|
+ RTCtime();//写入做参考
|
|
|
+ printf("@@@库内有数据,执行操作\r\n");
|
|
|
Database_Pull(0);
|
|
|
+ MiddleObj=true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- else if(countregular==3 && !Offline)//在线状态10s更新状态,30s上传 (各种状态正常在线,直接上传信息)
|
|
|
+ else if(pushpullcount>10001)
|
|
|
{
|
|
|
- countregular=0;
|
|
|
- //tt808FsFunc((uint8_t*)&(dblocptr->location.alarmFlag), 34, MessageID_location);
|
|
|
+
|
|
|
+ pushpullcount=0;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|