|
@@ -117,6 +117,9 @@ static void TcpTask(void* arg)
|
|
|
osDelay(5000);
|
|
|
appSetCFUN(1);
|
|
|
osDelay(10000);
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("Network restart\n");
|
|
|
+ #endif
|
|
|
}
|
|
|
break;
|
|
|
case QMSG_ID_SOCK_SENDPKG:
|
|
@@ -171,6 +174,7 @@ static void TcpTask(void* arg)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ sendQueueMsg(QMSG_ID_NW_IP_NOREACHABLE, 0);
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("connection %u or status invalid", socContext.id, socContext.status);
|
|
|
#endif
|
|
@@ -231,7 +235,7 @@ static void TcpDataInfoAssembleSend()
|
|
|
UINT8 month,day,hour,minute,sec;
|
|
|
UTC8TimeType UTC8TimeTcp;
|
|
|
UINT8 i = 0;
|
|
|
- INT8 len = -1;
|
|
|
+ INT16 len = -1;
|
|
|
UINT8 *SendBuffer = NULL;
|
|
|
//电池工作模式的延迟转换由Maintask负责,发送频率调节由tcp负责
|
|
|
switch (BattWorkStateDelay)
|
|
@@ -538,7 +542,56 @@ static void TcpDataInfoAssembleSend()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(send_counter==0)//调试信息暂时不发,需调整之后发送
|
|
|
+ if(send_counter%30==0)//调试信息暂时不发,需调整之后发送
|
|
|
+ {
|
|
|
+ DebugMsgtoTcpType DebugMsgInfo;
|
|
|
+ UINT16 BufferLen = 1000;
|
|
|
+ SendBuffer = malloc(BufferLen+sizeof(DebugMsgInfo));
|
|
|
+ memset(SendBuffer+sizeof(DebugMsgInfo)-1, 0x41,BufferLen);
|
|
|
+ appGetSystemTimeUtcSync(&TimeStracture);
|
|
|
+ year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
|
|
|
+ month=(TimeStracture.UTCtimer1&0xff00)>>8;
|
|
|
+ day=TimeStracture.UTCtimer1&0xff;
|
|
|
+ hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
|
|
|
+ minute=(TimeStracture.UTCtimer2&0xff0000)>>16;
|
|
|
+ sec=(TimeStracture.UTCtimer2&0xff00)>>8;
|
|
|
+ UTCToBeijing((UTC8TimeType *)&UTC8TimeTcp,year,month,day,hour,minute,sec);
|
|
|
+ DataLen=sizeof(DebugMsgInfo.DebugInfo) + BufferLen;
|
|
|
+ DebugMsgInfo.startSymbol[0] = TCP_START_SYM1;
|
|
|
+ DebugMsgInfo.startSymbol[1] = TCP_START_SYM2;
|
|
|
+ DebugMsgInfo.cmdSymbol = TCP_CMD_SYM;
|
|
|
+ DebugMsgInfo.ansSymbol = TCP_ANS_SYM;
|
|
|
+ memcpy(DebugMsgInfo.SN, AppNVMData.battSN,BATT_SN_LEN);
|
|
|
+ DebugMsgInfo.encryptMethod = TCP_ENCPT_DISABLE; //not encrypt
|
|
|
+ DebugMsgInfo.dataLength[0] = (DataLen>>8) & 0xFF;
|
|
|
+ DebugMsgInfo.dataLength[1] = DataLen & 0xFF;
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[0] = (UTC8TimeTcp.year - 0x07D0) & 0xFF; //year
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[1] = UTC8TimeTcp.month & 0xFF; //month
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[2] = UTC8TimeTcp.day & 0xFF; //day
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[3] = UTC8TimeTcp.hour & 0xFF; //hour
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[4] = UTC8TimeTcp.minute & 0xFF; //mins
|
|
|
+ DebugMsgInfo.DebugInfo.sendTimeUTC[5] = UTC8TimeTcp.second & 0xFF; //sec
|
|
|
+ DebugMsgInfo.DebugInfo.msgMark = DEBUGMSG;
|
|
|
+ DebugMsgInfo.DebugInfo.DebugLen[0] = BufferLen>>8;
|
|
|
+ DebugMsgInfo.DebugInfo.DebugLen[1] = BufferLen;
|
|
|
+ memcpy(SendBuffer,(UINT8 *)&DebugMsgInfo,sizeof(DebugMsgInfo)-1);
|
|
|
+ DebugMsgInfo.CRC = bcc_chk(SendBuffer, BufferLen+sizeof(DebugMsgInfo)-1);
|
|
|
+ memcpy(SendBuffer+BufferLen+sizeof(DebugMsgInfo)-1,&DebugMsgInfo.CRC,1);
|
|
|
+ len = tcpipConnectionSend(socContext.id, SendBuffer, BufferLen+sizeof(DebugMsgInfo), 0, 0, 0);
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("DebugMsg-[%d]:\n",len);
|
|
|
+ for (int i = 0; i < BufferLen+sizeof(DebugMsgInfo); i++)
|
|
|
+ {
|
|
|
+ printf("%02x ",*(SendBuffer + i));
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+ if(SendBuffer!=NULL)
|
|
|
+ {
|
|
|
+ free(SendBuffer);
|
|
|
+ }
|
|
|
+ SendBuffer=NULL;
|
|
|
+ }
|
|
|
+ if(FALSE)//调试信息暂时不发,需调整之后发送
|
|
|
{
|
|
|
DebugMsgtoTcpType DebugMsgInfo;
|
|
|
UINT16 BufferLen = 0;
|