From c8240d55741f0ed86099a0a8c616f4fc68372134 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期四, 25 十二月 2025 10:17:55 +0800
Subject: [PATCH] OTA功能测试完成,4G超时时间异常,出现4G中断情况,等杜工修改。

---
 STM32H743/APL/app.c |   49 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/STM32H743/APL/app.c b/STM32H743/APL/app.c
index 6af073b..06b256d 100644
--- a/STM32H743/APL/app.c
+++ b/STM32H743/APL/app.c
@@ -19,6 +19,13 @@
 #include "motion_mode.h"
 #include "motion_control_task.h"
 #include "motion_calibration_task.h"
+#include "MQTTClient.h"
+#include "HIDO_Json.h"
+#include "PathStorage.h"
+#include "PathTest.h"
+#include "HTTPClient.h"
+#include "MQTTApp.h"
+
 osSemaphoreId_t g_semaphoreHandle = NULL;
 TaskHandle_t g_app_task_handle = NULL;
 
@@ -41,14 +48,20 @@
     }
 void app_task(void *pvParameters)
 {
+    HIDO_JsonInit();
     Shell_Init();
     GPS_Init();
     Internet_Init();
     UDPClient_Init();
     TCPClient_Init();
+    MQTTClient_Init();
 	BT_Init();
     SBUS_Init();
     PythonLink_Init();
+    HTTPClient_Init();
+    FileDownload_Init();
+    // PathStorage_Init();  // 娉ㄩ噴鎺塒athStorage锛岄伩鍏嶅崰鐢℉TTPClient
+    // OTATest_Init();  // OTA鍗囩骇娴嬭瘯锛堟浛鎹athTest_Init锛�
 #if (MOTION_ACTIVE_MODE == MOTION_MODE_CONTROL)
     MotionControl_TaskInit();
 #elif (MOTION_ACTIVE_MODE == MOTION_MODE_CALIBRATION)
@@ -64,6 +77,10 @@
     static HIDO_UINT32 gps_upload_counter = 0;
     const HIDO_UINT32 GPS_UPLOAD_INTERVAL = 200; /* 姣�200娆″惊鐜笂浼犱竴娆� (绾�1000ms) */
     
+    /* 铏氭嫙GPS涓婃姤瀹氭椂鍣� */
+    static HIDO_UINT32 virtual_gps_report_counter = 0;
+    const HIDO_UINT32 VIRTUAL_GPS_REPORT_INTERVAL = 200; /* 姣�200娆″惊鐜笂浼犱竴娆� (绾�1000ms) */
+
     while (1)
     {
         //HIDO_UINT32 timeout = HIDO_TimerGetNearestTimeout(1000);
@@ -79,7 +96,17 @@
         HIDO_ATLitePoll();
         Internet_Poll();
         GPS_Poll();
+        HTTPClient_Poll();
+        MQTTClient_Poll();
+        // OTATest_Poll();  // OTA鍗囩骇娴嬭瘯锛堟浛鎹athTest_Poll锛�
         
+        /* 铏氭嫙GPS涓婃姤 (姣忕涓�娆�) */
+        if (++virtual_gps_report_counter >= VIRTUAL_GPS_REPORT_INTERVAL)
+        {
+            virtual_gps_report_counter = 0;
+            MQTTApp_ReportGpsVirtual();
+        }
+
         /* 瀹氭椂涓婁紶GGA鎶ユ枃鍒�4G锛堟瘡绉掍竴娆★級 */
         if (++gps_upload_counter >= GPS_UPLOAD_INTERVAL)
         {
@@ -111,7 +138,7 @@
 #endif
         
         UDPClient_Poll();
-       // TCPClient_Poll();
+        TCPClient_Poll();
         IdleTask();
         HIDO_TimerPoll();
     }
@@ -146,6 +173,7 @@
     parameter_init();
      
     {
+        g_com_map[VERSION] = (1<<8)|(1);
         uint16_t dev_id = g_com_map[DEV_ID];
         uint16_t udp_port = g_com_map[UDP_PORT];
         uint16_t tcp_port = g_com_map[TCP_PORT];
@@ -157,14 +185,25 @@
         uint16_t tip1 = g_com_map[TCP_IP_1];
         uint16_t tip2 = g_com_map[TCP_IP_2];
         uint16_t tip3 = g_com_map[TCP_IP_3];
+        g_com_map[MQTT_IP_0] = 39;
+        g_com_map[MQTT_IP_1] = 99;
+        g_com_map[MQTT_IP_2] = 43;
+        g_com_map[MQTT_IP_3] = 227;
+        g_com_map[MQTT_PORT] = 1883;
+        uint16_t mip0 = g_com_map[MQTT_IP_0];
+        uint16_t mip1 = g_com_map[MQTT_IP_1];
+        uint16_t mip2 = g_com_map[MQTT_IP_2];
+        uint16_t mip3 = g_com_map[MQTT_IP_3];
+        uint16_t mqtt_port = g_com_map[MQTT_PORT];
 
 			
         uint16_t version = g_com_map[VERSION];
 
-        HIDO_Debug2("[BOOT] Version: %u\r\n", version);
-        HIDO_Debug2("[BOOT] DeviceID: %u\r\n", dev_id);
-        HIDO_Debug2("[BOOT] UDP Server: %u.%u.%u.%u:%u\r\n", ip0, ip1, ip2, ip3, udp_port);
-        HIDO_Debug2("[BOOT] TCP Server: %u.%u.%u.%u:%u\r\n", tip0, tip1, tip2, tip3, tcp_port);
+        HIDO_Debug("[BOOT] Version: %u\r\n", version);
+        HIDO_Debug("[BOOT] DeviceID: %u\r\n", dev_id);
+        HIDO_Debug("[BOOT] UDP Server: %u.%u.%u.%u:%u\r\n", ip0, ip1, ip2, ip3, udp_port);
+        HIDO_Debug("[BOOT] TCP Server: %u.%u.%u.%u:%u\r\n", tip0, tip1, tip2, tip3, tcp_port);
+        HIDO_Debug("[BOOT] MQTT Server: %u.%u.%u.%u:%u\r\n", mip0, mip1, mip2, mip3, mqtt_port);
     }
     osSemaphoreAttr_t semaphore_attr = {
         .name = "MySemaphore",

--
Gitblit v1.10.0