|
@@ -28,8 +28,8 @@ static void TcpDataInfoAssembleSend();
|
|
|
static void TcpHeartDataSend();
|
|
|
static void TcpTask(void* arg)
|
|
|
{
|
|
|
- // appSetEDRXSettingSync(0,5,1800000);
|
|
|
- // appSetPSMSettingSync(1,3*60*60,10);
|
|
|
+ appSetEDRXSettingSync(0,5,1800000);
|
|
|
+ appSetPSMSettingSync(0,3*60*60,10);
|
|
|
appSetCFUN(1);
|
|
|
psEventQueueHandle = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(eventCallbackMessage_t*));
|
|
|
if (psEventQueueHandle == NULL)
|
|
@@ -144,11 +144,11 @@ static void TcpTask(void* arg)
|
|
|
{
|
|
|
if(tcpipConnectionClose(socContext.id) < 0)
|
|
|
{
|
|
|
- socContext.id = -1;
|
|
|
- socContext.status = APP_SOCKET_CONNECTION_CLOSED;
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("close connection %u success", socContext.id);
|
|
|
#endif
|
|
|
+ socContext.id = -1;
|
|
|
+ socContext.status = APP_SOCKET_CONNECTION_CLOSED;
|
|
|
ECOMM_TRACE(UNILOG_PLA_APP, ecTestCaseTcpClient_4, P_INFO, 1, "close connection %u success", socContext.id);
|
|
|
}
|
|
|
else
|
|
@@ -223,10 +223,10 @@ static void TcpDataInfoAssembleSend()
|
|
|
UTC8TimeType UTC8TimeTcp;
|
|
|
UINT8 i = 0;
|
|
|
INT8 len = -1;
|
|
|
+ UINT8 *SendBuffer = NULL;
|
|
|
WorkState = battWorkState; //电池工作模式的延迟转换由Maintask负责,发送频率调节由tcp负责
|
|
|
if(send_counter%BattSendFreq==0 && send_counter!=0)
|
|
|
{
|
|
|
- UINT8 *SendBuffer = NULL;
|
|
|
UINT16 ErrorTemp = 0x00;
|
|
|
UINT8 ProtocolHeaderLen = 25; //电池信息协议头部加校验码长度,此长度不更改
|
|
|
UINT8 ProtocolFixedLen = 60; //电池信息协议固定总长度 如协议新增,需要更改此长度
|
|
@@ -319,12 +319,8 @@ static void TcpDataInfoAssembleSend()
|
|
|
{
|
|
|
TcpSendLen = 0xFD & TcpSendLen;
|
|
|
sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
|
|
|
+ return;
|
|
|
}
|
|
|
- #ifdef USING_PRINTF1
|
|
|
- printf("BattMsg-[%d]:\n",len);
|
|
|
- for(int i =0 ;i<(ProtocolFixedLen + ProtocolFluctedLen);i++)
|
|
|
- printf("%02x ",*(SendBuffer+i));
|
|
|
- #endif
|
|
|
}
|
|
|
if(SendBuffer!=NULL)
|
|
|
{
|
|
@@ -332,12 +328,14 @@ static void TcpDataInfoAssembleSend()
|
|
|
}
|
|
|
SendBuffer=NULL;
|
|
|
}
|
|
|
- if(send_counter%GpsSendFreq==0)
|
|
|
+ if(send_counter%GpsSendFreq==0 && send_counter!=0)
|
|
|
{
|
|
|
GPSInfo *GpsRecvData=NULL;
|
|
|
osMessageQueueGet(GpsRecvHandle,&GpsRecvData,0,0);
|
|
|
GPSMsgtoTcpType GpsToTcpInfo;
|
|
|
-
|
|
|
+ UINT16 tac = 0;
|
|
|
+ UINT32 cellId = 0;
|
|
|
+ appGetLocationInfoSync(&tac,&cellId);
|
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
|
year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
|
|
|
month=(TimeStracture.UTCtimer1&0xff00)>>8;
|
|
@@ -369,6 +367,12 @@ static void TcpDataInfoAssembleSend()
|
|
|
GpsToTcpInfo.gpsInfo.msgCollectionTimeUTC[4] = UTC8TimeTcp.minute & 0xFF; //mins
|
|
|
GpsToTcpInfo.gpsInfo.msgCollectionTimeUTC[5] = UTC8TimeTcp.second & 0xFF;
|
|
|
memcpy((UINT8 *)&GpsToTcpInfo.gpsInfo.locateMark, GpsRecvData,sizeof(GPSInfo));
|
|
|
+ GpsToTcpInfo.gpsInfo.Tac[0] = tac>>8;
|
|
|
+ GpsToTcpInfo.gpsInfo.Tac[1] = tac&0xFF;
|
|
|
+ GpsToTcpInfo.gpsInfo.CellID[0] = cellId>>24;
|
|
|
+ GpsToTcpInfo.gpsInfo.CellID[0] = cellId>>16;
|
|
|
+ GpsToTcpInfo.gpsInfo.CellID[0] = cellId>>8;
|
|
|
+ GpsToTcpInfo.gpsInfo.CellID[0] = cellId;
|
|
|
GpsToTcpInfo.CRC = bcc_chk((UINT8 *)&GpsToTcpInfo, sizeof(GPSMsgtoTcpType)-1 );
|
|
|
if(GpsRecvData!=NULL)
|
|
|
free(GpsRecvData);
|
|
@@ -385,14 +389,9 @@ static void TcpDataInfoAssembleSend()
|
|
|
{
|
|
|
TcpSendLen = 0xFB & TcpSendLen;
|
|
|
sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
- #ifdef USING_PRINTF
|
|
|
- printf("GpsMsg:\n");
|
|
|
- UINT8* p = (UINT8 *)&GpsToTcpInfo;
|
|
|
- for(int i =0 ;i<sizeof(GpsToTcpInfo);i++)
|
|
|
- printf("%x ",*(p+i));
|
|
|
- #endif
|
|
|
}
|
|
|
if(send_counter==1)//版本信息上报 上报频率为每次重启后上报或者每次更新后上报或者每天上报一次均可
|
|
|
{
|
|
@@ -401,6 +400,11 @@ static void TcpDataInfoAssembleSend()
|
|
|
CHAR imei[15];
|
|
|
appGetIccidNumSync(iccid);
|
|
|
appGetImeiNumSync(imei);
|
|
|
+ CHAR *verData = NULL;
|
|
|
+ verData = appGetNBVersionInfo();
|
|
|
+ #ifdef USING_PRINTF
|
|
|
+ printf("verData:%s\n",verData);
|
|
|
+ #endif
|
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
|
year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
|
|
|
month=(TimeStracture.UTCtimer1&0xff00)>>8;
|
|
@@ -433,14 +437,12 @@ static void TcpDataInfoAssembleSend()
|
|
|
VerMsgToTcpInfo.VerInfo.msgCollectionTimeUTC[5] = UTC8TimeTcp.second & 0xFF;
|
|
|
memcpy(VerMsgToTcpInfo.VerInfo.ICCID,iccid,20);
|
|
|
memcpy(VerMsgToTcpInfo.VerInfo.IMEI,imei,15);
|
|
|
- //osMutexAcquire(UartMutex, osWaitForever);//Bms版本号上传2021-03-24修改
|
|
|
VerMsgToTcpInfo.VerInfo.BMSHwVersion[0] = bmsHwVersion /10;
|
|
|
VerMsgToTcpInfo.VerInfo.BMSHwVersion[1] = bmsHwVersion%10;
|
|
|
VerMsgToTcpInfo.VerInfo.BMSSwVersion[0] = 0;
|
|
|
VerMsgToTcpInfo.VerInfo.BMSSwVersion[1] = 0;
|
|
|
VerMsgToTcpInfo.VerInfo.BMSSwVersion[2] = bmsSwVersion/10;
|
|
|
VerMsgToTcpInfo.VerInfo.BMSSwVersion[3] = bmsSwVersion%10;
|
|
|
- //osMutexRelease(UartMutex);
|
|
|
VerMsgToTcpInfo.VerInfo.NBHwVersion[0] = (HWVERSION>>8)& 0xFF;
|
|
|
VerMsgToTcpInfo.VerInfo.NBHwVersion[1] = (HWVERSION)& 0xFF;
|
|
|
VerMsgToTcpInfo.VerInfo.BLVersion[0] = (BLSWVERSION>>24)& 0xFF;
|
|
@@ -479,62 +481,76 @@ static void TcpDataInfoAssembleSend()
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- // if(0)//调试信息暂时不发,需调整之后发送
|
|
|
- // {
|
|
|
- // DebugMsgtoTcpType DebugMsgInfo;
|
|
|
- // UINT16 BufferLen = 0;
|
|
|
- // BufferLen = Debug_GetSize();
|
|
|
- // if(BufferLen>200)
|
|
|
- // {
|
|
|
- // Debug_Del_Logfile();
|
|
|
- // #ifdef DEBUGLOG
|
|
|
- // Debug_printf("Sys:%d\n",AppDataInfo.SysReStart);
|
|
|
- // #endif
|
|
|
- // BufferLen = Debug_GetSize();
|
|
|
- // }
|
|
|
- // UINT8 rbuf[BufferLen];
|
|
|
- // Debug_Read_Logfile(rbuf,BufferLen);
|
|
|
- // SendBuffer = malloc(BufferLen+sizeof(DebugMsgInfo));
|
|
|
- // memcpy(SendBuffer+sizeof(DebugMsgInfo)-1, rbuf,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_PRINTF1
|
|
|
- // printf("DebugMsgInfo!\n");
|
|
|
- // UINT8* p = SendBuffer;
|
|
|
- // for(i =0 ;i<BufferLen+sizeof(DebugMsgInfo);i++)
|
|
|
- // printf("%x ",*(p+i));
|
|
|
- // #endif
|
|
|
- // Debug_Del_Logfile();
|
|
|
- // free(SendBuffer);
|
|
|
- // }
|
|
|
+ if(send_counter==0)//调试信息暂时不发,需调整之后发送
|
|
|
+ {
|
|
|
+ DebugMsgtoTcpType DebugMsgInfo;
|
|
|
+ UINT16 BufferLen = 0;
|
|
|
+ BufferLen = Debug_GetSize();
|
|
|
+ if(BufferLen==0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if(BufferLen>200)
|
|
|
+ {
|
|
|
+ Debug_Del_Logfile();
|
|
|
+ #ifdef DEBUGLOG
|
|
|
+ Debug_printf("Sys:%d\n",AppDataInfo.SysReStartCount);
|
|
|
+ #endif
|
|
|
+ BufferLen = Debug_GetSize();
|
|
|
+ }
|
|
|
+ UINT8 rbuf[BufferLen];
|
|
|
+ Debug_Read_Logfile(rbuf,BufferLen);
|
|
|
+ SendBuffer = malloc(BufferLen+sizeof(DebugMsgInfo));
|
|
|
+ memcpy(SendBuffer+sizeof(DebugMsgInfo)-1, rbuf,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);
|
|
|
+ #endif
|
|
|
+ if(len>0)
|
|
|
+ {
|
|
|
+ Debug_Del_Logfile();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ send_counter = 0;
|
|
|
+ sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(SendBuffer!=NULL)
|
|
|
+ {
|
|
|
+ free(SendBuffer);
|
|
|
+ }
|
|
|
+ SendBuffer=NULL;
|
|
|
+ }
|
|
|
if(send_counter>0xffff)
|
|
|
{
|
|
|
send_counter = 0;
|
|
@@ -755,7 +771,7 @@ static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 pa
|
|
|
case NB_URC_ID_MM_SIGQ:
|
|
|
{
|
|
|
rssi = *(UINT8 *)param;
|
|
|
- #ifdef USING_PRINTF
|
|
|
+ #ifdef USING_PRINTF1
|
|
|
printf("RSSI signal=%d\n",rssi);
|
|
|
#endif
|
|
|
break;
|
|
@@ -778,6 +794,7 @@ static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 pa
|
|
|
{
|
|
|
cereg = (CmiPsCeregInd *)param;
|
|
|
gCellID = cereg->celId;
|
|
|
+
|
|
|
#ifdef USING_PRINTF
|
|
|
printf("URCCallBack:CEREG changed act:%d celId:%d locPresent:%d tac:%d\n", cereg->act, cereg->celId, cereg->locPresent, cereg->tac);
|
|
|
#endif
|