3 Commits 27166813f3 ... f20d8b39a2

Author SHA1 Message Date
  CHENJIE-PC\QiXiang_CHENJIE f20d8b39a2 【V3.1.241.65】 增加了租期上传,BCU也进行了修改 2 years ago
  CHENJIE-PC\QiXiang_CHENJIE 91aa5ac630 Merge remote-tracking branch 'QX/V3-7250-QTF' into V3-V31XX-7250 2 years ago
  CHENJIE-PC\QiXiang_CHENJIE 90f2c9bd3c 租期上传测试 2 years ago
8 changed files with 178 additions and 37 deletions
  1. 4 2
      inc/AppConfig.h
  2. 2 1
      inc/AppFunc.h
  3. 2 1
      inc/AppSignal.h
  4. 29 0
      inc/AppTaskTcp.h
  5. 25 3
      src/AppFunc.c
  6. 2 2
      src/AppSignal.c
  7. 19 18
      src/AppTaskMain.c
  8. 95 10
      src/AppTaskTcp.c

+ 4 - 2
inc/AppConfig.h

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2022-01-04 16:06:32
+ * @LastEditTime : 2022-01-10 12:04:52
  * @Description  : App Config H file 配置文件,可以针对不同参数进行更改
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppConfig.h
  */
@@ -16,7 +16,7 @@
 #define DEFAULT_SN "RLTEST00000000001" //默认上传的SN编码
 
 #define APPSWRELEASE 0          //软件测试版本标志位,0-测试,1-发布
-#define APPSWVERSION 0x0301F241 //数据模块软件版本号
+#define APPSWVERSION 0x0301F141 //数据模块软件版本号
 
 #define RELAYCONFIG 1              //继电器配置
 #define TCP_ADD "iotp.fast-fun.cn" //数据上传的地址
@@ -58,6 +58,7 @@
 // message type mark 0x02上报数据单元定义区
 #define BATTMSG 0x80
 #define GPSMSG 0x82
+#define OTHERMSG 0x84
 #define STATESMSG 0x85
 #define VERSIONMSG 0x86
 #define DEBUGMSG 0x8C
@@ -111,6 +112,7 @@ typedef struct _AppDataType
     UINT8 RentalType;            //租期类型
     UINT8 ExpiryTimeArray[6];    //超期时间
     UINT8 ErrorMsg;
+    UINT8 RentalStartTime[6]; //租期开始时间
 } AppDataBody;
 typedef struct _AppAlgorithmType
 {

+ 2 - 1
inc/AppFunc.h

@@ -3,7 +3,7 @@
  * @Date         : 2021-10-14 09:27:15
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-16 11:10:28
+ * @LastEditTime : 2022-01-07 15:04:47
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppFunc.h
  */
@@ -35,6 +35,7 @@ typedef struct _Fota_Type
     UINT8 Fota_CRC;
 
 } Fota_Type;
+INT16 day_diff(UINT8 *pDate1, UINT8 *pDate2);
 BOOL BattHeaterSwitch(UINT8 *heaterSwitch, UINT8 HeatForceControl);
 BOOL uartBattInfoDecode(UINT8 *dataPtr);
 BOOL UDSAskforDownLoadData();

+ 2 - 1
inc/AppSignal.h

@@ -3,7 +3,7 @@
  * @Date         : 2021-12-28 19:25:29
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-29 16:52:03
+ * @LastEditTime : 2022-01-10 12:05:47
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppSignal.h
  */
@@ -26,6 +26,7 @@
 // declear the bool vars
 extern volatile BOOL NB_Fota_update_flag;
 extern volatile BOOL BMS_Fota_update_flag;
+extern volatile BOOL Rentalupdate;
 extern UINT32 ErrFlg;
 
 extern BOOL downloadReady;

+ 29 - 0
inc/AppTaskTcp.h

@@ -157,6 +157,35 @@ typedef struct DebugMsgtoTcp_Type
 	DebugInfoType DebugInfo;
 	UINT8 CRC;
 } DebugMsgtoTcpType;
+typedef struct _OtherInfoType
+{
+	UINT8 sendTimeBTC[6];
+	UINT8 msgMark;
+	UINT8 msgCollectionTimeBTC[6];
+	UINT8 HeatTargetT;
+	UINT8 HeatOverTime[2];
+	UINT8 RentalType;
+	UINT8 RentalStartTime[6];
+	UINT8 RentalDays[2];
+	UINT8 ExpiryDays[2];
+	UINT8 BleUserID[4];
+	UINT8 BleCode[4];
+	UINT8 BleAddress[6];
+	UINT8 BmsUploadFre[2];
+	UINT8 PosUploadFre[2];
+	UINT8 ChrgPack;
+} OtherInfoType;
+typedef struct OtherMsgtoTcpType
+{
+	UINT8 startSymbol[2];
+	UINT8 cmdSymbol;
+	UINT8 ansSymbol;
+	UINT8 SN[BATT_SN_LEN];
+	UINT8 encryptMethod;
+	UINT8 dataLength[2];
+	OtherInfoType OtherInfo;
+	UINT8 CRC;
+} OtherMsgtoTcpType;
 typedef enum
 {
 	APP_SOCKET_CONNECTION_CLOSED = 0,

+ 25 - 3
src/AppFunc.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-11-09 12:08:17
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-31 11:55:18
+ * @LastEditTime : 2022-01-07 15:04:39
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppFunc.c
  */
@@ -12,6 +12,27 @@
 #include "hal_module_adapter.h"
 #include "BCUDisp.h"
 #include "funlib.h"
+/**
+ * @brief : 日期计算函数
+ * @param {int} *pDate1
+ * @param {int} *pDate2
+ * @return {*}
+ */
+INT16 day_diff(UINT8 *pDate1, UINT8 *pDate2)
+{
+	int y2, m2, d2;
+	int y1, m1, d1;
+
+	m1 = (pDate1[1] + 9) % 12;
+	y1 = pDate1[0] - m1 / 10;
+	d1 = 365 * y1 + y1 / 4 - y1 / 100 + y1 / 400 + (m1 * 306 + 5) / 10 + (pDate1[2] - 1);
+
+	m2 = (pDate2[1] + 9) % 12;
+	y2 = pDate2[0] - m2 / 10;
+	d2 = 365 * y2 + y2 / 4 - y2 / 100 + y2 / 400 + (m2 * 306 + 5) / 10 + (pDate2[2] - 1);
+
+	return (d2 - d1);
+}
 /**
  * @brief : 保护板保护状态解码
  * @param {*}
@@ -320,7 +341,7 @@ void BattLockFunc(void)
 		ret = rentalEndDetectFunc();
 		if (ret == 1 && AppDataInfo.RentalLock == FALSE) //租期判定是否超期函数
 		{
-#ifdef USING_PRINTF
+#ifdef USING_PRINTF1
 			printf("retal lock,%d\n", ret);
 #endif
 			AppDataInfo.RentalLock = TRUE;
@@ -328,7 +349,7 @@ void BattLockFunc(void)
 		}
 		else if (ret == 0 && AppDataInfo.RentalLock == TRUE)
 		{
-#ifdef USING_PRINTF
+#ifdef USING_PRINTF1
 			printf("retal unlock,%d\n", ret);
 #endif
 			AppDataInfo.RentalLock = FALSE;
@@ -1420,6 +1441,7 @@ static void setDefaultAppDataInfo(void)
 	AppDataInfo.RentalType = 0;					  //租期类型
 	memset(AppDataInfo.ExpiryTimeArray, 0x00, 6); //超期时间
 	AppDataInfo.ErrorMsg = 0;
+	memset(AppDataInfo.RentalStartTime, 0x00, 6);
 	return;
 }
 /**

+ 2 - 2
src/AppSignal.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-10-14 09:27:15
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-29 10:35:24
+ * @LastEditTime : 2022-01-10 12:02:22
  * @Description  : Global variable definition c file,此文件存放App使用到的全局变量
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppSignal.c
  */
@@ -13,7 +13,7 @@
 volatile BOOL NB_Fota_update_flag = FALSE;
 volatile BOOL BMS_Fota_update_flag = FALSE;
 volatile BOOL CanInterruptFlag = FALSE;
-
+volatile BOOL Rentalupdate = FALSE;
 UINT32 ErrFlg = FALSE;
 BOOL downloadReady = FALSE;
 

+ 19 - 18
src/AppTaskMain.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-10-14 09:27:15
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-29 10:55:45
+ * @LastEditTime : 2022-01-07 14:44:38
  * @Description  : 主要负责:1.工作模式转换2.定时器定时3.定时保存运行数据4.异常状态重启
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskMain.c
  */
@@ -90,27 +90,28 @@ static void MainTask(void *arg)
             //状态转换延时
             if (TimeCounter % 10 == 0)
             {
-            	UINT8 battWorkStateI = 0;
-            	if(battI>10005)
-            	{
-            		battWorkStateI = BATT_DISCHARGE_SYM;	
-            	}
-				else if(battI<9995&&battI!=0)
-				{
-				   battWorkStateI = BATT_CHARGE_SYM;	
-				}
-				else
-				{
-				   battWorkStateI = BATT_IDLE_SYM;	
-				}
-				
-				BattWorkDelayFunc(battWorkStateI);
+                UINT8 battWorkStateI = 0;
+                if (battI > 10005)
+                {
+                    battWorkStateI = BATT_DISCHARGE_SYM;
+                }
+                else if (battI < 9995 && battI != 0)
+                {
+                    battWorkStateI = BATT_CHARGE_SYM;
+                }
+                else
+                {
+                    battWorkStateI = BATT_IDLE_SYM;
+                }
+
+                BattWorkDelayFunc(battWorkStateI);
 #ifdef USING_PRINTF1
                 printf("[%d]-%d-%d,%d,%d \n", __LINE__, TimeCounter, socd_pct_battSoc, fastChargeTemp, normalChargeTemp);
 #endif
-                if (TimeCounter % (10 * 60) == 0)
+                if (TimeCounter % (10 * 60 * 30) == 0)
                 {
                     BattLockFunc();
+                    Rentalupdate = TRUE;
                 }
             }
             if (WorkTimerEnd == TRUE) //从工作转换为监听的条件,定时器结束
@@ -202,7 +203,7 @@ static void MainTask(void *arg)
 #ifdef DEBUGLOG
                 UINT8 WakeUpFlg = 0;
                 WakeUpFlg = ((SleepTimerEnd) << 3) | ((TCPWorkState == 1) << 2) | ((PadInterrupt_clrCounter >= 1) << 1) | (otherTempAvg > (50 + 40));
-				ihd_st_wakeUpStat = WakeUpFlg;
+                ihd_st_wakeUpStat = WakeUpFlg;
                 Debug_printf("WORK:%d,%d,%d,%d\n", PadInterrupt_clrCounter, PadInterrupt, UartInterruptcount, WakeUpFlg);
 #endif
                 PROC_MAIN_STATE_SWITCH(PROCESS_STATE_IDLE);

+ 95 - 10
src/AppTaskTcp.c

@@ -14,7 +14,6 @@ static StaticTask_t gProcess_Tcp_Task_t;
 static UINT8 gProcess_Tcp_TaskStack[PROC_TCP_TASK_STACK_SIZE];
 static QueueHandle_t psEventQueueHandle; //状态转换队列句柄
 static osThreadId_t TcpTaskId = NULL;
-
 static eventCallbackMessage_t *queueItem = NULL;
 static UINT8 gImsi[16] = {0};
 static UINT32 gCellID = 0;
@@ -584,11 +583,11 @@ static void TcpDataInfoAssembleSend()
                                 %d,%d,%d,%d,%d,,\
                                 %d,%d,%d,%d,%d,%d,%d,,\
                                 %d,%d,%d,,",
-                socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_bcuSoc,pimd_pct_battSoc,
+                socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_bcuSoc, pimd_pct_battSoc,
                 sfmd_I_curr, sfmd_V_cellUMax, sfmd_V_cellUMin, sfmv_V_cellU[0], sfmv_V_cellU[1], sfmv_V_cellU[2],
-                cand_idx_cellNr, appv_V_cellU[cand_idx_cellNr - 1],cand_Q_cellCap, ihd_tm_parkTime, sohd_Q_chrgEo, iscv_Q_remainCpEi[cand_idx_cellNr - 1], iscd_tm_totalEi,
-                pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar,pimd_flg_inval,
-                pimv_V_cellOcv[0], pimv_V_cellOcv[1], pimv_V_cellOcv[2], pimv_R_cellOhm[0], pimv_R_cellOhm[1], pimv_R_cellOhm[2],pimv_R_cellOhm[sfmd_idx_cellUMin],
+                cand_idx_cellNr, appv_V_cellU[cand_idx_cellNr - 1], cand_Q_cellCap, ihd_tm_parkTime, sohd_Q_chrgEo, iscv_Q_remainCpEi[cand_idx_cellNr - 1], iscd_tm_totalEi,
+                pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar, pimd_flg_inval,
+                pimv_V_cellOcv[0], pimv_V_cellOcv[1], pimv_V_cellOcv[2], pimv_R_cellOhm[0], pimv_R_cellOhm[1], pimv_R_cellOhm[2], pimv_R_cellOhm[sfmd_idx_cellUMin],
                 iscd_flg_flt[0], iscd_flg_flt[1], iscd_flg_flt[2]);
         if (Debugcounter % 5 == 0)
         {
@@ -647,6 +646,95 @@ static void TcpDataInfoAssembleSend()
         }
         SendBuffer = NULL;
     }
+    if (send_counter == 5 || Rentalupdate == TRUE) //其他信息上传
+    {
+        OtherMsgtoTcpType OtherMsgToTcpInfo;
+        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 = (UINT16)sizeof(OtherMsgToTcpInfo.OtherInfo);
+        OtherMsgToTcpInfo.startSymbol[0] = TCP_START_SYM1;
+        OtherMsgToTcpInfo.startSymbol[1] = TCP_START_SYM2;
+        OtherMsgToTcpInfo.cmdSymbol = TCP_CMD_SYM;
+        OtherMsgToTcpInfo.ansSymbol = TCP_ANS_SYM;
+        memcpy(OtherMsgToTcpInfo.SN, AppNVMData.battSN, BATT_SN_LEN);
+        OtherMsgToTcpInfo.encryptMethod = TCP_ENCPT_DISABLE; // not encrypt
+        OtherMsgToTcpInfo.dataLength[0] = (DataLen >> 8) & 0xFF;
+        OtherMsgToTcpInfo.dataLength[1] = DataLen & 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[0] = (UTC8TimeTcp.year - 0x07D0) & 0xFF; // year
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[1] = UTC8TimeTcp.month & 0xFF;           // month
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[2] = UTC8TimeTcp.day & 0xFF;             // day
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[3] = UTC8TimeTcp.hour & 0xFF;            // hour
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[4] = UTC8TimeTcp.minute & 0xFF;          // mins
+        OtherMsgToTcpInfo.OtherInfo.sendTimeBTC[5] = UTC8TimeTcp.second & 0xFF;          // sec
+        OtherMsgToTcpInfo.OtherInfo.msgMark = OTHERMSG;
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[0] = (UTC8TimeTcp.year - 0x07D0) & 0xFF; // year
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[1] = UTC8TimeTcp.month & 0xFF;           // month
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[2] = UTC8TimeTcp.day & 0xFF;             // day
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[3] = UTC8TimeTcp.hour & 0xFF;            // hour
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[4] = UTC8TimeTcp.minute & 0xFF;          // mins
+        OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC[5] = UTC8TimeTcp.second & 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.HeatTargetT = tmsc_T_closeMinThr;
+        OtherMsgToTcpInfo.OtherInfo.HeatOverTime[0] = 0x00;
+        OtherMsgToTcpInfo.OtherInfo.HeatOverTime[1] = 0x00;
+        OtherMsgToTcpInfo.OtherInfo.RentalType = AppDataInfo.RentalType;
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[0] = AppDataInfo.RentalStartTime[0];
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[1] = AppDataInfo.RentalStartTime[1];
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[2] = AppDataInfo.RentalStartTime[2];
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[3] = AppDataInfo.RentalStartTime[3];
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[4] = AppDataInfo.RentalStartTime[4];
+        OtherMsgToTcpInfo.OtherInfo.RentalStartTime[5] = AppDataInfo.RentalStartTime[5];
+        INT16 RetalDays = 0;
+        INT16 ExpiryDays = 0;
+        if (AppDataInfo.RentalType == 2)
+        {
+            RetalDays = day_diff(AppDataInfo.RentalStartTime, AppDataInfo.ExpiryTimeArray);
+            ExpiryDays = day_diff(AppDataInfo.ExpiryTimeArray, OtherMsgToTcpInfo.OtherInfo.msgCollectionTimeBTC);
+        }
+        else
+        {
+            RetalDays = 0;
+            ExpiryDays = 0;
+        }
+        OtherMsgToTcpInfo.OtherInfo.RentalDays[0] = RetalDays >> 8;
+        OtherMsgToTcpInfo.OtherInfo.RentalDays[1] = RetalDays;
+        OtherMsgToTcpInfo.OtherInfo.ExpiryDays[0] = ExpiryDays >> 8;
+        OtherMsgToTcpInfo.OtherInfo.ExpiryDays[1] = ExpiryDays;
+        OtherMsgToTcpInfo.OtherInfo.BleUserID[0] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleUserID[1] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleUserID[2] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleUserID[3] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleCode[0] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleCode[1] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleCode[2] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleCode[3] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[0] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[1] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[2] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[3] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[4] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BleAddress[5] = 0xFF;
+        OtherMsgToTcpInfo.OtherInfo.BmsUploadFre[0] = (UINT8)((UINT16)(BattSendFreq * 10) >> 8);
+        OtherMsgToTcpInfo.OtherInfo.BmsUploadFre[1] = (UINT8)((UINT16)(BattSendFreq * 10));
+        OtherMsgToTcpInfo.OtherInfo.PosUploadFre[0] = (UINT8)((UINT16)(GpsSendFreq * 10) >> 8);
+        OtherMsgToTcpInfo.OtherInfo.PosUploadFre[1] = (UINT8)((UINT16)(GpsSendFreq * 10));
+        OtherMsgToTcpInfo.OtherInfo.ChrgPack = 0x00;
+        OtherMsgToTcpInfo.CRC = bcc_chk((UINT8 *)&OtherMsgToTcpInfo, sizeof(OtherMsgToTcpInfo) - 1);
+        len = tcpipConnectionSend(socContext.id, (UINT8 *)&OtherMsgToTcpInfo, sizeof(OtherMsgToTcpInfo), 0, 0, 0);
+        if (len > 0)
+        {
+            Rentalupdate = FALSE;
+        }
+        else
+        {
+            sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
+        }
+    }
     if (send_counter == 0) //调试信息暂时不发,需调整之后发送
     {
         DebugMsgtoTcpType DebugMsgInfo;
@@ -876,14 +964,11 @@ static void TcpDataInfoRecvHandle()
                     rentaldays = *(Ptr + 38) << 8 | *(Ptr + 39);
                     ExpiryTimeCal(rentalStartArray, rentaldays, ExpiryUTC8TimeArray);
                     MEMCPY(AppDataInfo.ExpiryTimeArray, ExpiryUTC8TimeArray, 6);
+                    MEMCPY(AppDataInfo.RentalStartTime, rentalStartArray, 6);
                     AppDataInfo.appDataModify = TRUE;
                     tcpipConnectionSend(socContext.id, TcpCmdAnswer, 31, 0, 0, 0);
-#ifdef USING_PRINTF1
-                    printf("rental!\n");
-                    for (UINT8 i = 0; i < 6; i++)
-                        printf("%d  ", ExpiryUTC8TimeArray[i]);
-#endif
                     BattLockFunc();
+                    Rentalupdate = TRUE;
                     ihd_flg_DTCClear = 1;
                 }
                 else