|
@@ -57,7 +57,6 @@ static QueueHandle_t TcpRecvHandle = NULL;
|
|
|
//Tcp线程堆栈申请区
|
|
|
|
|
|
//函数声明区
|
|
|
-static void TcpWorkStatus(void *arg);
|
|
|
static void sendQueueMsg(UINT32 msgId, UINT32 xTickstoWait);
|
|
|
static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 paramLen);
|
|
|
static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent);
|
|
@@ -281,7 +280,14 @@ static void TcpDataInfoAssembleSend()
|
|
|
BattToTcpInfo.battInfo.battPackVol[0] = BattU >> 8;
|
|
|
BattToTcpInfo.battInfo.battPackVol[1] = BattU & 0xFF;
|
|
|
temp = ((UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1])>>1)&0x03;
|
|
|
- BattToTcpInfo.battInfo.mosState = ((temp&0x01)<<01)|(temp>>0x01);
|
|
|
+ if(AppNVMData.isBattLocked==TRUE)
|
|
|
+ {
|
|
|
+ BattToTcpInfo.battInfo.switchState = ((temp&0x01)<<1)|((temp&0x02)>>1)|0x01<<2;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BattToTcpInfo.battInfo.switchState = ((temp&0x01)<<1)|((temp&0x02)>>1)|0x00<<2;
|
|
|
+ }
|
|
|
BattToTcpInfo.battInfo.battSOC = UartReadMsg.data[(0x0B+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
|
|
|
BattToTcpInfo.battInfo.battSOH = UartReadMsg.data[(0x0C+BATT_CELL_VOL_NUM+TEMP_NUM)*2+1];
|
|
|
memcpy(BattToTcpInfo.battInfo.batCellBalenceState,&UartReadMsg.data[(0x06+BATT_CELL_VOL_NUM+TEMP_NUM)*2],4);
|
|
@@ -413,7 +419,6 @@ static void TcpDataInfoRecvHandle()
|
|
|
osMessageQueueGet(TcpRecvHandle,&TcpRecvData,0,0);
|
|
|
osDelay(100);
|
|
|
Uart_Write_Data_Type UartWriteCmd;
|
|
|
- StatesMsgtoTcpType StatesMsg;
|
|
|
OsaUtcTimeTValue TimeStracture;
|
|
|
UINT8 DataLen;
|
|
|
UINT8 Tcp_Cmd;
|
|
@@ -443,7 +448,11 @@ static void TcpDataInfoRecvHandle()
|
|
|
TcpCmdAnswer[2] = TCP_CONCMD_SYM;
|
|
|
if(*(Ptr+30)==0x01)//远程升级命令
|
|
|
{
|
|
|
- Fota_Func(Ptr,socContext.id);
|
|
|
+ Fota_Func(Ptr,socContext.id,0x01);
|
|
|
+ }
|
|
|
+ else if(*(Ptr+30)==0x88)//BMS远程升级数据传输命令
|
|
|
+ {
|
|
|
+ Fota_Func(Ptr,socContext.id,0x88);
|
|
|
}
|
|
|
else if(*(Ptr+30)==0x80)//远程锁定命令
|
|
|
{
|
|
@@ -459,14 +468,6 @@ static void TcpDataInfoRecvHandle()
|
|
|
{
|
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteCmd,0,1000);
|
|
|
}
|
|
|
- TcpCmdAnswer[3] = 0x01;
|
|
|
- memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
|
|
|
- TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
|
- TcpCmdAnswer[22] = 0x00;
|
|
|
- TcpCmdAnswer[23] = 0x06;
|
|
|
- memcpy(&TcpCmdAnswer[24],(Ptr+24),6);
|
|
|
- TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer,30);
|
|
|
- tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
|
|
|
}
|
|
|
else //0x02代表解锁
|
|
|
{
|
|
@@ -476,57 +477,18 @@ static void TcpDataInfoRecvHandle()
|
|
|
UartWriteCmd.Data[0] = 0x00;
|
|
|
UartWriteCmd.Data[1] = 0x03;
|
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteCmd,0,1000);
|
|
|
- TcpCmdAnswer[3] = 0x01;
|
|
|
- memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
|
|
|
- TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
|
- TcpCmdAnswer[22] = 0x00;
|
|
|
- TcpCmdAnswer[23] = 0x06;
|
|
|
- memcpy(&TcpCmdAnswer[24],(Ptr+24),6);
|
|
|
- TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer,30);
|
|
|
- tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
|
|
|
- }
|
|
|
- osDelay(1000);
|
|
|
- appGetSystemTimeUtcSync(&TimeStracture);
|
|
|
- DataLen= (UINT16)sizeof(StatesMsg.StatesInfo);
|
|
|
- StatesMsg.startSymbol[0] = TCP_START_SYM1;
|
|
|
- StatesMsg.startSymbol[1] = TCP_START_SYM2;
|
|
|
- StatesMsg.cmdSymbol = TCP_CMD_SYM;
|
|
|
- StatesMsg.ansSymbol = TCP_ANS_SYM;
|
|
|
- memcpy(StatesMsg.SN, AppNVMData.battSN,BATT_SN_LEN);
|
|
|
- StatesMsg.encryptMethod = TCP_ENCPT_DISABLE; //not encrypt
|
|
|
- StatesMsg.dataLength[0] = (DataLen>>8) & 0xFF;
|
|
|
- StatesMsg.dataLength[1] = DataLen & 0xFF;
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[0] = ((((TimeStracture.UTCtimer1) >> 16) & 0xFFFF) - 0x07D0) & 0xFF; //year
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[1] = ((TimeStracture.UTCtimer1) >> 8 ) & 0xFF; //month
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[2] = (TimeStracture.UTCtimer1) & 0xFF; //day
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[3] = ((TimeStracture.UTCtimer2) >> 24 ) & 0xFF; //hour
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[4] = ((TimeStracture.UTCtimer2) >> 16 ) & 0xFF; //mins
|
|
|
- StatesMsg.StatesInfo.sendTimeUTC[5] = ((TimeStracture.UTCtimer2) >> 8 ) & 0xFF; //sec
|
|
|
- StatesMsg.StatesInfo.msgMark = STATESMSG;
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[0] = ((((TimeStracture.UTCtimer1) >> 16) & 0xFFFF) - 0x07D0) & 0xFF; //year
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[1] = ((TimeStracture.UTCtimer1) >> 8 ) & 0xFF; //month
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[2] = (TimeStracture.UTCtimer1) & 0xFF; //day
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[3] = ((TimeStracture.UTCtimer2) >> 24 ) & 0xFF; //hour
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[4] = ((TimeStracture.UTCtimer2) >> 16 ) & 0xFF; //mins
|
|
|
- StatesMsg.StatesInfo.msgCollectionTimeUTC[5] = ((TimeStracture.UTCtimer2) >> 8 ) & 0xFF;
|
|
|
- StatesMsg.StatesInfo.ResetStates = 0;
|
|
|
- if((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1]==0x00)&&(AppNVMData.isBattLocked == TRUE))
|
|
|
- {
|
|
|
- StatesMsg.StatesInfo.BattLockStates = 1;
|
|
|
- }
|
|
|
- else if((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1]!=0x00)&&(AppNVMData.isBattLocked == FALSE))
|
|
|
- {
|
|
|
- StatesMsg.StatesInfo.BattLockStates = 0;
|
|
|
- }
|
|
|
- else if((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1]!=0x00)&&(AppNVMData.isBattLocked == TRUE))
|
|
|
- {
|
|
|
- StatesMsg.StatesInfo.BattLockStates = 2;
|
|
|
}
|
|
|
- StatesMsg.StatesInfo.HeatSwitchStates = UartReadMsg.data[(0x1C+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+2)*2+1];
|
|
|
- StatesMsg.StatesInfo.BuzzerStatus = 0;
|
|
|
- StatesMsg.CRC = bcc_chk((UINT8 *)&StatesMsg, sizeof(StatesMsgtoTcpType)-1 );
|
|
|
- tcpipConnectionSend(socContext.id, (UINT8 *)&StatesMsg, sizeof(StatesMsgtoTcpType), 0, 0, 0);
|
|
|
+ TcpCmdAnswer[3] = 0x01;
|
|
|
+ memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
|
|
|
+ TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
|
+ TcpCmdAnswer[22] = 0x00;
|
|
|
+ TcpCmdAnswer[23] = 0x06;
|
|
|
+ memcpy(&TcpCmdAnswer[24],(Ptr+24),6);
|
|
|
+ TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer,30);
|
|
|
osMutexRelease(UartMutex);
|
|
|
+ tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
|
|
|
+ TcpService=0x00;
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -545,7 +507,6 @@ static void TcpDataInfoRecvHandle()
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
free(TcpRecvData);
|
|
|
}
|
|
|
}
|