Browse Source

【JM-3.0.0.8】1.增加状态转换函数判定当前上传频率,2.增加上传失败的判定

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
00e0e65d2a
5 changed files with 104 additions and 8 deletions
  1. 1 1
      inc/AppConfig.h
  2. 1 1
      inc/AppSignal.h
  3. 1 1
      src/AppSignal.c
  4. 64 1
      src/AppTaskMain.c
  5. 37 4
      src/AppTaskTcp.c

+ 1 - 1
inc/AppConfig.h

@@ -13,7 +13,7 @@
 #define DATA_MODULE_TYPE (1)           //1表示NB模块,2表示4G cat1
 #define EOLSTATE (0)                   //1表示下线检测跳过,使用默认值,0表示使用下线检测
 #define DEFAULT_SN "JMTEST00000000001" //默认上传的SN编码
-#define APPSWVERSION 0x03000007        //数据模块软件版本号
+#define APPSWVERSION 0x03000008        //数据模块软件版本号
 
 #define TCP_ADD "iotp.fast-fun.cn" //数据上传的地址
 #define TCP_PORT 8712              //数据上传的端口

+ 1 - 1
inc/AppSignal.h

@@ -57,7 +57,7 @@ extern UINT8 GpsData[16];                     //GPS 数据缓存区
 extern UINT16 updateDifferDataPackageCounter; //差分包升级计数器
 extern BOOL downloadReady;
 extern UINT8 UDSSwitch; //下线检测标志位
-
+extern UINT8 BattWorkStateDelay;
 //declear the UINT8 vars
 extern UINT8 csq;
 extern UINT8 bmsStatus;

+ 1 - 1
src/AppSignal.c

@@ -22,7 +22,7 @@ UINT8 PosFlag = 0;         //��λ��Ϣ�Ƿ���Ч��־λ
 UINT8 GpsFlag = 0;         //GPS ������Ч��־λ
 UINT8 PadInterrupt = 0x00; //ÿ��bit����һ���жϱ�־
 UINT8 Lockstatus = 0x00;
-
+UINT8 BattWorkStateDelay = 0x00;
 /**declear the uint16 vars**/
 UINT16 nbHwVersion = 0xFFFF; //����ģ��Ӳ��״̬
 UINT16 ErrorNum[5] = {0};    //Error array����������

+ 64 - 1
src/AppTaskMain.c

@@ -26,7 +26,7 @@ static void appBeforeSlp1(void *pdata, slpManLpState state);
 static void appAfterSlp1(void *pdata, slpManLpState state);
 static void appBeforeSlp2(void *pdata, slpManLpState state);
 static void appAfterSlp2(void *pdata, slpManLpState state);
-
+static void BattWorkDelayFunc(UINT8 battWorkCurrentState);
 UINT8 MainSlpHandler = 0xff; //主线程睡眠句柄
 static void MainTask(void *arg)
 {
@@ -65,6 +65,8 @@ static void MainTask(void *arg)
     }
     xTimerStart(monitor_timer, 0);
     UINT32 DignoseCounter = 0;
+    UINT8 BattWorkState = 0;
+    INT16 BattI = 0;
     while (true)
     {
         switch (gProcess_Main_Task)
@@ -88,6 +90,20 @@ static void MainTask(void *arg)
                 DignoseCounter = TimeCounter;
                 if (TimeCounter % 10 == 0)
                 {
+                    BattI = (INT16)(packTotalCurr - 10000U);
+                    if (BattI > 50) //电流大于5A认为放电
+                    {
+                        BattWorkState = BATT_DISCHARGE_SYM; //discharge
+                    }
+                    else if (BattI < -50) //电流大于-5A认为充电
+                    {
+                        BattWorkState = BATT_CHARGE_SYM; //charge
+                    }
+                    else
+                    {
+                        BattWorkState = BATT_IDLE_SYM; //stop
+                    }
+                    BattWorkDelayFunc(BattWorkState);
                     // UINT32 space = osMessageQueueGetSpace(CanRecvHandle);
                     // printf("space=\t%d\n", space);
 //BattWorkDelayFunc(battWorkState);
@@ -306,4 +322,51 @@ static void appAfterSlp2(void *pdata, slpManLpState state)
 #ifdef USING_PRINTF
     printf("sleep2 failed:%d \n", state);
 #endif
+}
+static void BattWorkDelayFunc(UINT8 battWorkCurrentState)
+{
+    static UINT8 workDelayCounter = 0;
+
+    if (battWorkCurrentState == BATT_IDLE_SYM && BattWorkStateDelay == BATT_DISCHARGE_SYM) //从放电转静置 60s延时
+    {
+        workDelayCounter++;
+        if (workDelayCounter >= 60)
+        {
+            workDelayCounter = 0;
+            BattWorkStateDelay = battWorkCurrentState;
+        }
+    }
+    else if (battWorkCurrentState == BATT_IDLE_SYM && BattWorkStateDelay == BATT_CHARGE_SYM) //从充电转静置60s延时
+    {
+        workDelayCounter++;
+        if (workDelayCounter >= 60)
+        {
+            workDelayCounter = 0;
+            BattWorkStateDelay = battWorkCurrentState;
+        }
+    }
+    else if (battWorkCurrentState == BATT_DISCHARGE_SYM && BattWorkStateDelay != BATT_DISCHARGE_SYM) //从 充电或者静置 转放电 1s延时
+    {
+        workDelayCounter++;
+        if (workDelayCounter >= 1)
+        {
+            workDelayCounter = 0;
+            BattWorkStateDelay = battWorkCurrentState;
+        }
+    }
+    else if (battWorkCurrentState == BATT_CHARGE_SYM && BattWorkStateDelay != BATT_CHARGE_SYM) //从 放电或者静置 转充电 1s延时
+    {
+        workDelayCounter++;
+        if (workDelayCounter >= 1)
+        {
+            workDelayCounter = 0;
+            BattWorkStateDelay = battWorkCurrentState;
+        }
+    }
+    else
+    {
+        BattWorkStateDelay = battWorkCurrentState;
+        workDelayCounter = 0;
+    }
+    return;
 }

+ 37 - 4
src/AppTaskTcp.c

@@ -228,7 +228,7 @@ static void TcpDataInfoAssembleSend()
     INT8 rsnr = 0;
 
     UINT16 DataLen = 0;
-    UINT8 BattSendFreq = 30;
+    UINT16 BattSendFreq = 30;
     UINT8 GpsSendFreq = 30;
 
     UINT16 year;
@@ -249,6 +249,15 @@ static void TcpDataInfoAssembleSend()
             clrbit(PadInterrupt, 4);
         }
     }
+
+    if (BattWorkStateDelay == BATT_IDLE_SYM)
+    {
+        BattSendFreq = 10 * 60;
+    }
+    else
+    {
+        BattSendFreq = 10;
+    }
     /*
     if(FALSE)
     {
@@ -516,7 +525,7 @@ static void TcpDataInfoAssembleSend()
             }
         }
     }
-    if ((send_counter) % 30 == 0) //90发送
+    if ((send_counter) % (BattSendFreq * 3) == 0) //90发送
     {
         appGetSystemTimeUtcSync(&TimeStracture);
         year = (TimeStracture.UTCtimer1 & 0xffff0000) >> 16;
@@ -544,8 +553,16 @@ static void TcpDataInfoAssembleSend()
             free(SendBuffer);
         }
         SendBuffer = NULL;
+        if (len > 0)
+        {
+            ;
+        }
+        else
+        {
+            sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
+        }
     }
-    if ((send_counter + 1) % 10 == 0) //91发送
+    if ((send_counter + 1) % BattSendFreq == 0) //91发送
     {
         appGetSystemTimeUtcSync(&TimeStracture);
         year = (TimeStracture.UTCtimer1 & 0xffff0000) >> 16;
@@ -573,8 +590,16 @@ static void TcpDataInfoAssembleSend()
             free(SendBuffer);
         }
         SendBuffer = NULL;
+        if (len > 0)
+        {
+            ;
+        }
+        else
+        {
+            sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
+        }
     }
-    if ((send_counter + 2) % 120 == 0) //92发送
+    if ((send_counter + 2) % (BattSendFreq * 4) == 0) //92发送
     {
         appGetSystemTimeUtcSync(&TimeStracture);
         year = (TimeStracture.UTCtimer1 & 0xffff0000) >> 16;
@@ -602,6 +627,14 @@ static void TcpDataInfoAssembleSend()
             free(SendBuffer);
         }
         SendBuffer = NULL;
+        if (len > 0)
+        {
+            ;
+        }
+        else
+        {
+            sendQueueMsg(QMSG_ID_NW_IP_SUSPEND, 0);
+        }
     }
     /*调试信息字符发送形式,但是发送流量会大2倍
     if((send_counter)%10==0)//90发送