|
@@ -405,8 +405,6 @@ static void TcpDataInfoAssembleSend()
|
|
{
|
|
{
|
|
send_counter++;
|
|
send_counter++;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
//Tcp数据接收处理函数
|
|
//Tcp数据接收处理函数
|
|
static void TcpDataInfoRecvHandle()
|
|
static void TcpDataInfoRecvHandle()
|
|
@@ -415,6 +413,9 @@ static void TcpDataInfoRecvHandle()
|
|
osMessageQueueGet(TcpRecvHandle,&TcpRecvData,0,0);
|
|
osMessageQueueGet(TcpRecvHandle,&TcpRecvData,0,0);
|
|
osDelay(100);
|
|
osDelay(100);
|
|
Uart_Write_Data_Type UartWriteCmd;
|
|
Uart_Write_Data_Type UartWriteCmd;
|
|
|
|
+ StatesMsgtoTcpType StatesMsg;
|
|
|
|
+ OsaUtcTimeTValue TimeStracture;
|
|
|
|
+ UINT8 DataLen;
|
|
UINT8 Tcp_Cmd;
|
|
UINT8 Tcp_Cmd;
|
|
UINT8 Control_Cmd;
|
|
UINT8 Control_Cmd;
|
|
UINT8 *Ptr;
|
|
UINT8 *Ptr;
|
|
@@ -446,6 +447,7 @@ static void TcpDataInfoRecvHandle()
|
|
}
|
|
}
|
|
else if(*(Ptr+30)==0x80)//远程锁定命令
|
|
else if(*(Ptr+30)==0x80)//远程锁定命令
|
|
{
|
|
{
|
|
|
|
+ osMutexAcquire(UartMutex, osWaitForever);
|
|
if(*(Ptr+31)==0x01)//0x01代表锁定
|
|
if(*(Ptr+31)==0x01)//0x01代表锁定
|
|
{
|
|
{
|
|
AppNVMData.appDataModify = TRUE;
|
|
AppNVMData.appDataModify = TRUE;
|
|
@@ -453,7 +455,18 @@ static void TcpDataInfoRecvHandle()
|
|
UartWriteCmd.WriteCmd = 0x01;
|
|
UartWriteCmd.WriteCmd = 0x01;
|
|
UartWriteCmd.Data[0] = 0x00;
|
|
UartWriteCmd.Data[0] = 0x00;
|
|
UartWriteCmd.Data[1] = 0x00;
|
|
UartWriteCmd.Data[1] = 0x00;
|
|
- //osMessageQueuePut(UartWriteCmdHandle,&UartWriteCmd,0,1000);
|
|
|
|
|
|
+ if((UartReadMsg.data[(0x03+BATT_CELL_VOL_NUM)*2+1]&0x03)==0x00)
|
|
|
|
+ {
|
|
|
|
+ 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代表解锁
|
|
else //0x02代表解锁
|
|
{
|
|
{
|
|
@@ -463,9 +476,61 @@ static void TcpDataInfoRecvHandle()
|
|
UartWriteCmd.Data[0] = 0x00;
|
|
UartWriteCmd.Data[0] = 0x00;
|
|
UartWriteCmd.Data[1] = 0x03;
|
|
UartWriteCmd.Data[1] = 0x03;
|
|
osMessageQueuePut(UartWriteCmdHandle,&UartWriteCmd,0,1000);
|
|
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;
|
|
}
|
|
}
|
|
-
|
|
|
|
- TcpCmdAnswer[3] = 0x01;
|
|
|
|
|
|
+ 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);
|
|
|
|
+ osMutexRelease(UartMutex);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ TcpCmdAnswer[3] = 0x0f;
|
|
memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
|
|
memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
|
|
TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
|
|
TcpCmdAnswer[22] = 0x00;
|
|
TcpCmdAnswer[22] = 0x00;
|