zhunk 1 год назад
Родитель
Сommit
f8a78d65ee

+ 1 - 1
Application_cbd_apm32f1/applications/control.h

@@ -23,7 +23,7 @@
     #define VERSION_HK_2000W    "1.3led.40(2000W)"       //水稻
 #else
     #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "2.12.4(2000W)"         //4.0水稻
+    #define VERSION_HK_2000W    "2.13.4(2000W)"         //4.0水稻
 #endif
 
 #define VERSION_ZP          "1.45.1(ZP)"            //1.0转盘

+ 6 - 15
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -413,20 +413,11 @@ struct tm* parseTimestamp(const char *timestamp) {
 }
 
 void setSystemTime(struct tm *timeinfo) {
-    time_t t = mktime(timeinfo);
-    if (t == -1) {
-        LOG_E("Failed to convert time to time_t");
-        return;
-    }
-    // Convert the time_t value to a timeval structure
-    struct timeval tv;
-    tv.tv_sec = t;
-    tv.tv_usec = 0; // Assuming no microseconds in the timestamp
-    if (settimeofday(&tv, NULL) == -1) {
-        LOG_E("Failed to set system time!");
-        return;
+    if(set_date(timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday)==RT_EOK)
+    {
+        set_time(timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
+        LOG_I("System time set successfully:%04d-%02d-%02d-%02d-%02d-%02d!",timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday,timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec);
     }
-    LOG_I("System time set successfully!");
 }
 
 // 函数定义:判断数组中是否有大于 100 的元素
@@ -1791,11 +1782,11 @@ int parseDtu(char *json_string)
                           {
                              timestamp_diff = tv.tv_sec - timestamp;
                           }
-                          if (tm_time != NULL&&timestamp_diff>60) {
+                          if (timestamp_diff>60) {
                              setSystemTime(tm_time);
-                             free(tm_time); // Free the allocated memory
                           }
                       }
+                      free(tm_time); // Free the allocated memory
                   }
                   if(hum!=NULL&&tmp!=NULL)
                   {

+ 3 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,6 @@
+# 2025-05-21 更新说明
+#define VERSION_HK_2000W    "2.13.4(2000W)"         //4.0水稻
+1. 修改温湿度设置时间方法
 # 2025-05-19 更新说明
 #define VERSION_HK          "2.5.41(HK)"            //4.0海康-1200W
 #define VERSION_HK_2000W    "2.12.4(2000W)"         //4.0水稻