zhunk преди 3 месеца
родител
ревизия
0d379e0c13
променени са 35 файла, в които са добавени 384 реда и са изтрити 4573 реда
  1. 1 5
      Application_CBD/.config
  2. 27 7
      Application_CBD/.config.old
  3. 227 229
      Application_CBD/.cproject
  4. BIN
      Application_CBD/.settings/.rtmenus
  5. 1 1
      Application_CBD/.settings/language.settings.xml
  6. 4 10
      Application_CBD/applications/control.h
  7. 28 5
      Application_CBD/applications/dtu_uart2.c
  8. 77 14
      Application_CBD/applications/hmi.c
  9. 3 0
      Application_CBD/applications/lwjson_stream.c
  10. 0 1
      Application_CBD/applications/sht30_collect.c
  11. 0 5
      Application_CBD/packages/cJSON-latest/README.md
  12. 0 5
      Application_CBD/packages/cJSON-latest/README_ZH.md
  13. 0 9
      Application_CBD/packages/cJSON-latest/SConscript
  14. 0 3110
      Application_CBD/packages/cJSON-latest/cJSON.c
  15. 0 293
      Application_CBD/packages/cJSON-latest/cJSON.h
  16. 0 20
      Application_CBD/packages/cJSON-latest/cJSON_port.c
  17. 0 58
      Application_CBD/packages/cJSON-latest/cJSON_util.c
  18. 0 25
      Application_CBD/packages/cJSON-latest/cJSON_util.h
  19. 2 2
      Application_CBD/packages/pkgs_error.json
  20. 0 56
      Application_CBD/packages/sht3x-latest/README.md
  21. 0 9
      Application_CBD/packages/sht3x-latest/SConscript
  22. 0 13
      Application_CBD/packages/sht3x-latest/docs/README.md
  23. BIN
      Application_CBD/packages/sht3x-latest/docs/datasheets/SHT3x_Alert_Mode_DIS_V1.pdf
  24. BIN
      Application_CBD/packages/sht3x-latest/docs/datasheets/Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital.pdf
  25. 0 6
      Application_CBD/packages/sht3x-latest/docs/version.md
  26. 0 506
      Application_CBD/packages/sht3x-latest/sht3x.c
  27. 0 182
      Application_CBD/packages/sht3x-latest/sht3x.h
  28. 14 0
      Application_CBD/readme.md
  29. BIN
      Application_CBD/rt-thread/tools/building.pyc
  30. BIN
      Application_CBD/rt-thread/tools/eclipse.pyc
  31. BIN
      Application_CBD/rt-thread/tools/menuconfig.pyc
  32. BIN
      Application_CBD/rt-thread/tools/mkdist.pyc
  33. BIN
      Application_CBD/rt-thread/tools/utils.pyc
  34. 0 2
      Application_CBD/rtconfig.h
  35. BIN
      Application_CBD/rtconfig.pyc

+ 1 - 5
Application_CBD/.config

@@ -955,11 +955,7 @@ CONFIG_PKG_SYSWATCH_VER="latest"
 # CONFIG_PKG_USING_QMP6989 is not set
 # CONFIG_PKG_USING_BALANCE is not set
 # CONFIG_PKG_USING_SHT2X is not set
-CONFIG_PKG_USING_SHT3X=y
-CONFIG_PKG_SHT3X_PATH="/packages/peripherals/sensors/sht3x"
-# CONFIG_PKG_USING_SHT3X_V100 is not set
-CONFIG_PKG_USING_SHT3X_LATEST_VERSION=y
-CONFIG_PKG_SHT3X_VER="latest"
+# CONFIG_PKG_USING_SHT3X is not set
 # CONFIG_PKG_USING_SHT4X is not set
 # CONFIG_PKG_USING_AD7746 is not set
 # CONFIG_PKG_USING_ADT74XX is not set

+ 27 - 7
Application_CBD/.config.old

@@ -127,7 +127,7 @@ CONFIG_RT_USING_PWM=y
 # CONFIG_RT_USING_PM is not set
 CONFIG_RT_USING_RTC=y
 # CONFIG_RT_USING_ALARM is not set
-CONFIG_RT_USING_SOFT_RTC=y
+# CONFIG_RT_USING_SOFT_RTC is not set
 # CONFIG_RT_USING_SDIO is not set
 CONFIG_RT_USING_SPI=y
 # CONFIG_RT_USING_QSPI is not set
@@ -625,7 +625,31 @@ CONFIG_PKG_FAL_VER="latest"
 CONFIG_PKG_FAL_VER_NUM=0x99999
 # CONFIG_PKG_USING_FILEX is not set
 # CONFIG_PKG_USING_LEVELX is not set
-# CONFIG_PKG_USING_FLASHDB is not set
+CONFIG_PKG_USING_FLASHDB=y
+CONFIG_PKG_FLASHDB_PATH="/packages/system/FlashDB"
+CONFIG_FDB_USING_KVDB=y
+# CONFIG_FDB_KV_AUTO_UPDATE is not set
+CONFIG_FDB_USING_TSDB=y
+CONFIG_FDB_USING_FAL_MODE=y
+# CONFIG_FDB_WRITE_GRAN_1BIT is not set
+# CONFIG_FDB_WRITE_GRAN_8BITS is not set
+CONFIG_FDB_WRITE_GRAN_32BITS=y
+# CONFIG_FDB_WRITE_GRAN_64BITS is not set
+# CONFIG_FDB_WRITE_GRAN_128BITS is not set
+CONFIG_FDB_WRITE_GRAN=32
+CONFIG_FDB_NOT_USING_FILE_MODE=y
+# CONFIG_FDB_USING_FILE_LIBC_MODE is not set
+# CONFIG_FDB_USING_FILE_POSIX_MODE is not set
+# CONFIG_FLASHDB_USING_SAMPLES is not set
+CONFIG_FDB_DEBUG_ENABLE=y
+CONFIG_PKG_USING_FLASHDB_V20100=y
+# CONFIG_PKG_USING_FLASHDB_V10102 is not set
+# CONFIG_PKG_USING_FLASHDB_V10101 is not set
+# CONFIG_PKG_USING_FLASHDB_V10100 is not set
+# CONFIG_PKG_USING_FLASHDB_V10000 is not set
+# CONFIG_PKG_USING_FLASHDB_LATEST_VERSION is not set
+CONFIG_PKG_FLASHDB_VER="v2.1.0"
+CONFIG_PKG_FLASHDB_VER_NUM=0x20100
 # CONFIG_PKG_USING_SQLITE is not set
 # CONFIG_PKG_USING_RTI is not set
 # CONFIG_PKG_USING_DFS_YAFFS is not set
@@ -955,11 +979,7 @@ CONFIG_PKG_SYSWATCH_VER="latest"
 # CONFIG_PKG_USING_QMP6989 is not set
 # CONFIG_PKG_USING_BALANCE is not set
 # CONFIG_PKG_USING_SHT2X is not set
-CONFIG_PKG_USING_SHT3X=y
-CONFIG_PKG_SHT3X_PATH="/packages/peripherals/sensors/sht3x"
-# CONFIG_PKG_USING_SHT3X_V100 is not set
-CONFIG_PKG_USING_SHT3X_LATEST_VERSION=y
-CONFIG_PKG_SHT3X_VER="latest"
+# CONFIG_PKG_USING_SHT3X is not set
 # CONFIG_PKG_USING_SHT4X is not set
 # CONFIG_PKG_USING_AD7746 is not set
 # CONFIG_PKG_USING_ADT74XX is not set

Файловите разлики са ограничени, защото са твърде много
+ 227 - 229
Application_CBD/.cproject


BIN
Application_CBD/.settings/.rtmenus


+ 1 - 1
Application_CBD/.settings/language.settings.xml

@@ -5,7 +5,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-411634754427827492" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-486798775489886410" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
 				<language-scope id="org.eclipse.cdt.core.gcc"/>
 				<language-scope id="org.eclipse.cdt.core.g++"/>
 			</provider>

+ 4 - 10
Application_CBD/applications/control.h

@@ -18,7 +18,6 @@
 #define SENSOR_EN        0              //温湿度:0关闭,1打开
 #define ROBOT_EN         0              //机器人
 #define Color_EN         0              //定制色诱
-#define BOOT_ERR         1              //1-新bootloader,0-旧bootloader()2023年9月份之前的设备升级需要设置为0
 #define DZ_250723        0              //触发雨控后隔天再解除
 #define DZ_260519        0              //进入工作后,每小时转一次仓
 #define DZ_260623_2      0              //中端款测报灯  每次工作前和雨控解除后  上下仓门打开 等待5分钟 清扫10次 关闭上下仓门 开始正常工作  假设8点开始正常工作 可能需要7点30或者35来执行这个动作
@@ -29,13 +28,13 @@
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
 #else
 #if DZ_260630_1 == 0
-     #define VERSION_HK          "1.69.41(HK)"            //4.0海康-1200W
+     #define VERSION_HK          "1.70.41(HK)"            //4.0海康-1200W
 #else
     #define VERSION_HK          "1.68.41(HK-DZ260630_1)"  //4.0海康-1200W
 #endif
 #if DZ_260623_2 == 0
 #if DZ_260630_1 == 0
-    #define VERSION_HK_2000W    "1.69.40(2000W)"         //4.0水稻
+    #define VERSION_HK_2000W    "1.70.40(2000W)"         //4.0水稻
 #else
     #define VERSION_HK_2000W    "1.68.40(2000W-DZ260630_1)"         //4.0水稻
 #endif
@@ -44,16 +43,13 @@
 #endif
 #endif
 #if DZ_260519 == 0
-#define VERSION_ZP          "1.69.1(ZP)"                //1.0转盘
+#define VERSION_ZP          "1.70.1(ZP)"                //1.0转盘
 #else
 #define VERSION_ZP          "DZ_260519"                 //1.0转盘
 #endif
-
-#define VERSION_GK          "1.69.1(GK)"                //1.0高空
-
+#define VERSION_GK          "1.70.1(GK)"                //1.0高空
 #define VERSION_XCT         "1.13.6(HK)"                //吸虫塔-海康
 #define VERSION_Robot       "1.0(robot)"                //展厅机器人
-
 #define VERSION_BZY         "2.60"                      //孢子仪
 
 
@@ -139,12 +135,10 @@ typedef struct  _packed
     uint8_t led_sta;         //补光灯报警0-正常,1-异常
     uint8_t selfcheck_ws;    //自检开关
     uint8_t rtu_isboot;      //RTU启动状态:0-正常,1-异常
-    #if BOOT_ERR == 1
     uint8_t gps_inuse;
     uint8_t gps_view;
     uint8_t _lamp;
     uint8_t mock_uart2_timer_flag;
-    #endif
     uint16_t dattim;         //数据上传间隔
     uint16_t shake_sec;      //震动时间
     uint16_t thsp;           //息屏时间

+ 28 - 5
Application_CBD/applications/dtu_uart2.c

@@ -30,6 +30,7 @@
 #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
 #include <lwjson.h>
 #include "sys_monitor.h"
+#include "param_mirror.h"
 
 
 #define DTU_THREAD_PRIORITY         6          //线程优先级
@@ -142,14 +143,25 @@ static void dtu_thread_entry_recv(void *parameter)
             rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
         }
         system_status.uart2_rx_bytes+=1;
-        accum_buf[accum_len++]=ch;
-        if (accum_len >= sizeof(accum_buf)) {
-            // 防止超范围
+
+        /* 累积存储,留 1 字节放 '\0',避免 parseDtu 越界访问 */
+        if (accum_len >= sizeof(accum_buf) - 1) {
+            LOG_W("dtu accum buffer overflow(%d), drop & reset parser!", (int)accum_len);
             accum_len = 0;
+            memset(accum_buf, 0, sizeof(accum_buf));
             lwjson_stream_reset(&lwparser);
-            memset(accum_buf,0,sizeof(accum_buf));
+            /* 把串口硬件 RX 队列里残留的字节也丢掉,避免下一帧再次错乱 */
+            {
+                char drain_buf[64];
+                while (rt_device_read(dtuserial, -1, drain_buf, sizeof(drain_buf)) > 0) {
+                    /* drain */
+                }
+            }
             continue;
         }
+        accum_buf[accum_len++] = ch;
+        accum_buf[accum_len]   = '\0';
+
         lwjsonr_t ret;
         ret = lwjson_stream_parse(&lwparser, ch); // 把串口数据逐字节的喂给解析器去解析
         switch(ret)
@@ -859,6 +871,11 @@ void parse_param_to_mcu(cJSON* Params)
             ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
         }
 
+        /* Cloud-driven config write: snapshot device_status into the
+         * mirror so a later EF loss can still recover. Sync is idempotent;
+         * doing it unconditionally avoids per-field book-keeping. */
+        param_mirror_sync();
+
     }else{
         LOG_E("Params is NULL!");
     }
@@ -2776,7 +2793,6 @@ int parseDtu(char *json_string)
                           {
                               rt_sprintf(device_status.json_w_clock,"平台操作:修改工作时间:开始-%d,结束-%d,模式-%d(0-光控,1-时控)-%s",device_status.startBar,device_status.stopBar,device_status.timeSwitch,device_status.stamp);
                               json_s = makeJson_Warn(device_status.json_w_clock, "修改时间");
-                              ef_set_env_blob("json_w_clock", &device_status.json_w_clock, sizeof(device_status.json_w_clock));   //将修改屏幕参数操作记录保存到Flash中
                               if(atoi(device_status.net)==0)
                                   DTU_Write("%s",json_s);
                               rt_free(json_s);
@@ -2789,6 +2805,13 @@ int parseDtu(char *json_string)
           }
         cJSON_Delete(root);
     }
+
+    /* Cloud-driven config write may have updated mirror fields
+     * (startBar/stopBar/timeSwitch/tpl/tph/ds/version_type/dtype...).
+     * Snapshot the latest device_status into the mirror so a later EF
+     * loss can recover. Sync is idempotent. */
+    param_mirror_sync();
+
     return 0;
 }
 

+ 77 - 14
Application_CBD/applications/hmi.c

@@ -26,6 +26,7 @@
 #include "dtu_uart2.h"
 #include <fal.h>
 #include "sys_monitor.h"
+#include "param_mirror.h"
 #define DBG_ENABLE
 #define DBG_COLOR
 #define DBG_TAG "hmi"
@@ -875,6 +876,7 @@ static void HMI_Decode(void)
         LOG_I("开始排虫!");
         device_status.handle_bugger = 0;
         ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
+        param_mirror_sync();
     }
     else if(strstr(rx_buffer,"putTest.shouchong")!=NULL){
         if(device_status.run_sta == 0){
@@ -886,6 +888,7 @@ static void HMI_Decode(void)
         LOG_I("开始收虫!");
         device_status.handle_bugger = 1;
         ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
+        param_mirror_sync();
     }
     //设置设备时间
     else if (strstr(rx_buffer,"stamp=")!=NULL)
@@ -1018,6 +1021,7 @@ static void HMI_Decode(void)
             }
 
             MA_save();
+            param_mirror_sync();
             LOG_I("参数已保存:%d-%d-%d-%d-%d-%d",device_status.collecting_sh1,device_status.collecting_eh1,device_status.collecting_sh2,device_status.collecting_eh2,device_status.shake_sec,device_status.cul_time);
             return;
         }
@@ -1101,12 +1105,12 @@ static void HMI_Decode(void)
         //2022/06/23,add:
         rt_sprintf(device_status.json_w_clock,"屏幕操作:修改工作时间:开始-%d,结束-%d,模式-%d(0-光控,1-时控)操作时间:%s",device_status.startBar,device_status.stopBar,device_status.timeSwitch,device_status.stamp);
         json_temp = makeJson_Warn(device_status.json_w_clock, "修改工作时间");
-        ef_set_env_blob("json_w_clock", &device_status.json_w_clock, sizeof(device_status.json_w_clock));   //将修改屏幕参数操作记录保存到Flash中
         if(atoi(device_status.net)==0)
             DTU_Write("%s",json_temp);
         rt_free(json_temp);
         rt_thread_delay(2000);
         MA_save();
+        param_mirror_sync();
         rt_free(var);
         rt_kprintf("工作时间参数已保存:模式-%d,光控时间-%d,时控开始时间-%d,时控结束时间-%d\n",device_status.timeSwitch,device_status.sunBar,device_status.startBar,device_status.stopBar);
     }
@@ -1172,6 +1176,7 @@ static void HMI_Decode(void)
                 LOG_I("制冷开关:%d",device_status.cold_sw);
                 LOG_I("系统设置已保存:\n自动熄屏-%d\n音量-%d\n培养温度-%d\n数据上传间隔-%d",device_status.thsp,device_status.vol,device_status.heatvalue,device_status.dattim);
                 MA_save();
+                param_mirror_sync();
                 return;
             }
         var = strstr(rx_buffer,"=");
@@ -1211,6 +1216,7 @@ static void HMI_Decode(void)
         }
         rt_thread_delay(1000);
         MA_save();
+        param_mirror_sync();
         rt_free(var);
         rt_kprintf("系统设置已保存:收集时间-%d,加热时间-%d,加热温度-%d,音量-%d,自动关屏-%d\n",device_status.clt_time,device_status.heattime,device_status.heatvalue,device_status.vol,device_status.thsp);
     }
@@ -1256,6 +1262,7 @@ static void HMI_Decode(void)
             device_status.dattim =atoi(dattim_str); //数据上传间隔
             ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim));
             MA_save();
+            param_mirror_sync();
         }
         else {
             rt_kprintf("设置失败!!!\n");
@@ -1303,7 +1310,6 @@ static void HMI_Decode(void)
         //2022/06/23,add:
         rt_sprintf(device_status.json_w_platform,"屏幕操作:切换平台:8.136.98.49,操作时间:%s",device_status.stamp);
         json_temp = makeJson_Warn(device_status.json_w_platform, "切换平台");
-        ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform));   //将修改屏幕参数操作记录保存到Flash中
         if(atoi(device_status.net)==0)
             DTU_Write("%s",json_temp);
         rt_free(json_temp);
@@ -1325,7 +1331,6 @@ static void HMI_Decode(void)
         //2022/06/23,add:
         rt_sprintf(device_status.json_w_platform,"屏幕操作:切换平台:120.27.222.26,操作时间:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
         json_temp = makeJson_Warn(device_status.json_w_platform, "切换平台");
-        ef_set_env_blob("json_w_platform", &device_status.json_w_platform, sizeof(device_status.json_w_platform));   //将修改屏幕参数操作记录保存到Flash中
         if(atoi(device_status.net)==0)
             DTU_Write("%s",json_temp);
         rt_free(json_temp);
@@ -1340,7 +1345,6 @@ static void HMI_Decode(void)
         //2022/06/23,add:
         rt_sprintf(device_status.json_w_reset,"屏幕操作:系统重置:电池供电,操作时间:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
         json_temp = makeJson_Warn(device_status.json_w_reset, "系统重置");
-        ef_set_env_blob("json_w_reset", &device_status.json_w_reset, sizeof(device_status.json_w_reset));   //将修改屏幕参数操作记录保存到Flash中
         if(atoi(device_status.net)==0)
             DTU_Write("%s",json_temp);
         rt_free(json_temp);
@@ -1354,7 +1358,6 @@ static void HMI_Decode(void)
         //2022/06/23,add:
         rt_sprintf(device_status.json_w_reset,"屏幕操作:系统重置:交流供电,操作时间:%04d-%02d-%02d %02d:%02d:%02d",tm.tm_year+1900,tm.tm_mon+1,tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec);
         json_temp = makeJson_Warn(device_status.json_w_reset, "系统重置");
-        ef_set_env_blob("json_w_reset", &device_status.json_w_reset, sizeof(device_status.json_w_reset));   //将修改屏幕参数操作记录保存到Flash中
         if(atoi(device_status.net)==0)
             DTU_Write("%s",json_temp);
         rt_free(json_temp);
@@ -1383,6 +1386,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
+            param_mirror_sync();
         }
         else {
 
@@ -1399,6 +1403,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
+            param_mirror_sync();
         }
         else {
 
@@ -1416,6 +1421,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
+            param_mirror_sync();
         }
         else {
 
@@ -1433,6 +1439,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型+
             MA_save();
+            param_mirror_sync();
         }
         return;
     }
@@ -1447,6 +1454,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型+
             MA_save();
+            param_mirror_sync();
         }
         return;
     }
@@ -1462,6 +1470,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型+
             DTU_Write("SwversionV41");
             MA_save();
+            param_mirror_sync();
         }
         else {
 
@@ -1479,6 +1488,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             DTU_Write("SwversionV4");
             MA_save();
+            param_mirror_sync();
         }
         else {
 
@@ -1495,6 +1505,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype));        //版本类型
             MA_save();
+            param_mirror_sync();
         }
     }
     else if (strstr(rx_buffer,"SwversionV30")!=NULL) {
@@ -1504,6 +1515,7 @@ static void HMI_Decode(void)
             sprintf(device_status.driver, "%s",VERSION_Robot);
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             MA_save();
+            param_mirror_sync();
         }
     }
     else if((strstr(rx_buffer,"SwversionV7")!=NULL)) {
@@ -1516,6 +1528,7 @@ static void HMI_Decode(void)
             ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));        //版本类型
             DTU_Write("SwversionV7");
             MA_save();
+            param_mirror_sync();
         }
     }
     else if (strstr(rx_buffer,"putTest.switchFAN_PU=1")!=NULL) {
@@ -1637,7 +1650,7 @@ static void Ctr_Mortor_entry(void* parameter)
    static rt_uint16_t mock_uart_timer2_cnt = 0;
     while(1)
     {
-        #if 1
+#if 0
         time_t time_reset12V;
         time(&time_reset12V);
         static struct tm alarm_reset12V;
@@ -1647,12 +1660,11 @@ static void Ctr_Mortor_entry(void* parameter)
             char *rep = makeJsonRpc2_0("reboot",NULL, 1);
             if(rep){
                 DTU_Write(rep);
-                //启动超时定时器
                 free(rep);
             }
             rt_thread_delay(1000);
         }
-
+#endif
         if(device_status.mock_uart2_timer_flag==1)
         {
             mock_uart_timer2_cnt++;
@@ -1664,7 +1676,7 @@ static void Ctr_Mortor_entry(void* parameter)
         }else{
             mock_uart_timer2_cnt = 0;
         }
-        #endif
+
         if(device_status.ctr_up_motor==1)
         {
             ctr_cangmen_up(OPEN);
@@ -1898,6 +1910,24 @@ void Check_ParamConfig(void)
     else {
         LOG_E("easyflash init ERRPR!!!");
     }
+    /* If iSave was lost (EF has no record of it, value stays 0), check the
+     * mirror before deciding to apply defaults. A valid mirror means the
+     * device was configured before — recover from there instead of blowing
+     * all params back to factory defaults. */
+    if (device_status.iSave != FLASH_FLAG)
+    {
+        param_payload_t boot_mirror;
+        if (param_mirror_load(&boot_mirror) == RT_EOK)
+        {
+            LOG_W("iSave lost but mirror is valid (seq=%u), recovering",
+                  boot_mirror.write_seq);
+            mirror_to_device_status(&boot_mirror);
+            /* iSave is now FLASH_FLAG; set iFlag=0 to match the normal
+             * "load user config" path semantics. */
+            device_status.iFlag = 0;
+        }
+    }
+
     //保存默认配置
     if(device_status.iSave!=FLASH_FLAG)
     {
@@ -1971,9 +2001,28 @@ void Check_ParamConfig(void)
         LOG_I("thsp:%d", device_status.thsp);
         LOG_I("passwd:%d",device_status.passWord);
 
+        /* Seed the mirror with the same defaults we just wrote to EF.
+         * After this point, all EF writes below also sync to the mirror. */
+        param_mirror_sync();
+
     }//从easyflash读取参数配置
     else if (device_status.iSave==FLASH_FLAG) {
+        /* Try to recover from the mirror first. If the mirror has a valid
+         * copy, prefer it over single-key EF lookups: a single dropped EF
+         * entry no longer causes a stale default to surface. Fields that
+         * are NOT in the mirror (imei, iccid, deviceId, json_w_*, driver_bl,
+         * platform, env_t/h) are still fetched from EF below. */
         device_status.iFlag = 0;
+        param_payload_t mirror;
+        if (param_mirror_load(&mirror) == RT_EOK)
+        {
+            LOG_I("param mirror loaded (seq=%u)", mirror.write_seq);
+            mirror_to_device_status(&mirror);
+        }
+        else
+        {
+            LOG_W("param mirror unavailable, falling back to EF single-key");
+        }
         ef_get_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype),NULL);                             //设备类型
         ef_get_env_blob("dattim",&device_status.dattim,sizeof(device_status.dattim),NULL);                          //数据上传间隔
         ef_get_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time), NULL);                    //收集时间
@@ -2009,13 +2058,21 @@ void Check_ParamConfig(void)
         ef_get_env_blob("handle_bugger",&device_status.handle_bugger,sizeof(device_status.handle_bugger),NULL);     //排虫
         device_status.light_over_tim = device_status.sunBar * 3600;                                                 //光控计数
         device_status.work_done = 0;
-        //工作完成标志位
-        if(device_status.dattim==0)
-        {
-            device_status.dattim = 10;
-        }
+        if(device_status.dattim==0 ||
+              device_status.thsp==0||
+              device_status.sunBar==0||
+              device_status.tph==0){
+            device_status.iFlag = 1;
+        }
+        //丢参数时的异常处理
+        if(device_status.dattim==0) device_status.dattim = 10;
         if(device_status.thsp==0) device_status.thsp = 300;
         if(device_status.sunBar==0) device_status.sunBar = 4;
+        if(device_status.tph==0) device_status.tph = 70;
+        if(device_status.clt_time==0) device_status.clt_time = 10;
+        if(device_status.heattime==0) device_status.heattime = 10;
+        if(device_status.heatvalue==0) device_status.heatvalue = 100;
+
         /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
         if(device_status.dtype!=7)
         {
@@ -2187,6 +2244,10 @@ void Check_ParamConfig(void)
 #endif
     }
 }
+/* device_status_to_mirror / mirror_to_device_status / param_mirror_sync
+ * have been moved to param_mirror.c so any translation unit can call
+ * param_mirror_sync() without needing internal hmi.c linkage. */
+
 void ResetParamDefault(void)
 {
     rt_sprintf(device_status.tempture,"%d",-15);
@@ -2252,6 +2313,7 @@ void ResetParamDefault(void)
     ef_set_env_blob("ds", &device_status.ds, sizeof(device_status.ds));
     ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
     ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
+    param_mirror_sync();
     HMI_WRITE("play %d,%d,%d",1,5,0);
     DTU_Write("reset.mp3");
     rt_thread_delay(1000);
@@ -2303,6 +2365,7 @@ void ResetParamDefault_DC(void)
     ef_set_env_blob("shake_sec", &device_status.shake_sec, sizeof(device_status.shake_sec));   //震动时间
     ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
     ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
+    param_mirror_sync();
     DTU_Write("reset.mp3");
     rt_thread_delay(1000);
 }

+ 3 - 0
Application_CBD/applications/lwjson_stream.c

@@ -157,6 +157,9 @@ lwjsonr_t
 lwjson_stream_reset(lwjson_stream_parser_t* jsp) {
     jsp->parse_state = LWJSON_STREAM_STATE_WAITINGFIRSTCHAR;
     jsp->stack_pos = 0;
+    LWJSON_MEMSET(jsp->stack, 0x00, sizeof(jsp->stack));
+    LWJSON_MEMSET(&jsp->data, 0x00, sizeof(jsp->data));
+    jsp->prev_c = '\0';
     return lwjsonOK;
 }
 

+ 0 - 1
Application_CBD/applications/sht30_collect.c

@@ -9,7 +9,6 @@
  */
 #include <rtthread.h>
 #include <board.h>
-#include <sht3x.h>
 #include "sht30_collect.h"
 #include <string.h>
 #include <stdio.h>

+ 0 - 5
Application_CBD/packages/cJSON-latest/README.md

@@ -1,5 +0,0 @@
-# cJSON
-
-[中文页](README_ZH.md) | English
-
-Ultralightweight JSON parser in ANSI C

+ 0 - 5
Application_CBD/packages/cJSON-latest/README_ZH.md

@@ -1,5 +0,0 @@
-# cJSON
-
-中文页 | [English](README.md)
-
-超轻量级的 C 语言 json 解析库 

+ 0 - 9
Application_CBD/packages/cJSON-latest/SConscript

@@ -1,9 +0,0 @@
-from building import *
-
-cwd     = GetCurrentDir()
-src     = Glob('*.c')
-CPPPATH = [cwd]
-
-group = DefineGroup('cJSON', src, depend = ['PKG_USING_CJSON'], CPPPATH = CPPPATH)
-
-Return('group')

Файловите разлики са ограничени, защото са твърде много
+ 0 - 3110
Application_CBD/packages/cJSON-latest/cJSON.c


+ 0 - 293
Application_CBD/packages/cJSON-latest/cJSON.h

@@ -1,293 +0,0 @@
-/*
-  Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
-
-  Permission is hereby granted, free of charge, to any person obtaining a copy
-  of this software and associated documentation files (the "Software"), to deal
-  in the Software without restriction, including without limitation the rights
-  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-  copies of the Software, and to permit persons to whom the Software is
-  furnished to do so, subject to the following conditions:
-
-  The above copyright notice and this permission notice shall be included in
-  all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-  THE SOFTWARE.
-*/
-
-#ifndef cJSON__h
-#define cJSON__h
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
-#define __WINDOWS__
-#endif
-
-#ifdef __WINDOWS__
-
-/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention.  For windows you have 3 define options:
-
-CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
-CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
-CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
-
-For *nix builds that support visibility attribute, you can define similar behavior by
-
-setting default visibility to hidden by adding
--fvisibility=hidden (for gcc)
-or
--xldscope=hidden (for sun cc)
-to CFLAGS
-
-then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
-
-*/
-
-#define CJSON_CDECL __cdecl
-#define CJSON_STDCALL __stdcall
-
-/* export symbols by default, this is necessary for copy pasting the C and header file */
-#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
-#define CJSON_EXPORT_SYMBOLS
-#endif
-
-#if defined(CJSON_HIDE_SYMBOLS)
-#define CJSON_PUBLIC(type)   type CJSON_STDCALL
-#elif defined(CJSON_EXPORT_SYMBOLS)
-#define CJSON_PUBLIC(type)   __declspec(dllexport) type CJSON_STDCALL
-#elif defined(CJSON_IMPORT_SYMBOLS)
-#define CJSON_PUBLIC(type)   __declspec(dllimport) type CJSON_STDCALL
-#endif
-#else /* !__WINDOWS__ */
-#define CJSON_CDECL
-#define CJSON_STDCALL
-
-#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
-#define CJSON_PUBLIC(type)   __attribute__((visibility("default"))) type
-#else
-#define CJSON_PUBLIC(type) type
-#endif
-#endif
-
-/* project version */
-#define CJSON_VERSION_MAJOR 1
-#define CJSON_VERSION_MINOR 7
-#define CJSON_VERSION_PATCH 14
-
-#include <stddef.h>
-
-/* cJSON Types: */
-#define cJSON_Invalid (0)
-#define cJSON_False  (1 << 0)
-#define cJSON_True   (1 << 1)
-#define cJSON_NULL   (1 << 2)
-#define cJSON_Number (1 << 3)
-#define cJSON_String (1 << 4)
-#define cJSON_Array  (1 << 5)
-#define cJSON_Object (1 << 6)
-#define cJSON_Raw    (1 << 7) /* raw json */
-
-#define cJSON_IsReference 256
-#define cJSON_StringIsConst 512
-
-/* The cJSON structure: */
-typedef struct cJSON
-{
-    /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
-    struct cJSON *next;
-    struct cJSON *prev;
-    /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
-    struct cJSON *child;
-
-    /* The type of the item, as above. */
-    int type;
-
-    /* The item's string, if type==cJSON_String  and type == cJSON_Raw */
-    char *valuestring;
-    /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
-    int valueint;
-    /* The item's number, if type==cJSON_Number */
-    double valuedouble;
-
-    /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
-    char *string;
-} cJSON;
-
-typedef struct cJSON_Hooks
-{
-      /* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
-      void *(CJSON_CDECL *malloc_fn)(size_t sz);
-      void (CJSON_CDECL *free_fn)(void *ptr);
-} cJSON_Hooks;
-
-typedef int cJSON_bool;
-
-/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
- * This is to prevent stack overflows. */
-#ifndef CJSON_NESTING_LIMIT
-#define CJSON_NESTING_LIMIT 1000
-#endif
-
-/* returns the version of cJSON as a string */
-CJSON_PUBLIC(const char*) cJSON_Version(void);
-
-/* Supply malloc, realloc and free functions to cJSON */
-CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
-
-/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
-/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
-CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
-/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
-/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
-CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
-
-/* Render a cJSON entity to text for transfer/storage. */
-CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
-/* Render a cJSON entity to text for transfer/storage without any formatting. */
-CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
-/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
-CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
-/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
-/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
-CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
-/* Delete a cJSON entity and all subentities. */
-CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
-
-/* Returns the number of items in an array (or object). */
-CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
-/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
-CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
-/* Get item "string" from object. Case insensitive. */
-CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
-CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
-CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
-/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
-CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
-
-/* Check item type and return its value */
-CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
-CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
-
-/* These functions check the type of an item */
-CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
-CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
-
-/* These calls create a cJSON item of the appropriate type. */
-CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
-CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
-CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
-CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
-CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
-CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
-/* raw json */
-CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
-CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
-CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
-
-/* Create a string where valuestring references a string so
- * it will not be freed by cJSON_Delete */
-CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
-/* Create an object/array that only references it's elements so
- * they will not be freed by cJSON_Delete */
-CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
-CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
-
-/* These utilities create an Array of count items.
- * The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
-CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
-CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
-CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
-CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
-
-/* Append item to the specified array/object. */
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
-/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
- * WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
- * writing to `item->string` */
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
-/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
-CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
-
-/* Remove/Detach items from Arrays/Objects. */
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
-CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
-CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
-CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
-CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
-
-/* Update array items. */
-CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
-CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
-
-/* Duplicate a cJSON item */
-CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
-/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
- * need to be released. With recurse!=0, it will duplicate any children connected to the item.
- * The item->next and ->prev pointers are always zero on return from Duplicate. */
-/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
- * case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
-CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
-
-/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
- * The input pointer json cannot point to a read-only address area, such as a string constant,
- * but should point to a readable and writable adress area. */
-CJSON_PUBLIC(void) cJSON_Minify(char *json);
-
-/* Helper functions for creating and adding items to an object at the same time.
- * They return the added item or NULL on failure. */
-CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
-CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
-CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
-CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
-CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
-CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
-CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
-CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
-CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
-
-/* When assigning an integer value, it needs to be propagated to valuedouble too. */
-#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
-/* helper for the cJSON_SetNumberValue macro */
-CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
-#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
-/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
-CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
-
-/* Macro for iterating over an array or object */
-#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
-
-/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
-CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
-CJSON_PUBLIC(void) cJSON_free(void *object);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif

+ 0 - 20
Application_CBD/packages/cJSON-latest/cJSON_port.c

@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include <rtthread.h>
-
-#include "cJSON.h"
-
-int cJSON_hook_init(void)
-{
-    cJSON_Hooks cJSON_hook;
-
-    cJSON_hook.malloc_fn = (void *(*)(size_t sz))rt_malloc;
-    cJSON_hook.free_fn = rt_free;
-
-    cJSON_InitHooks(&cJSON_hook);
-
-    return RT_EOK;
-}
-INIT_COMPONENT_EXPORT(cJSON_hook_init);

+ 0 - 58
Application_CBD/packages/cJSON-latest/cJSON_util.c

@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <rtthread.h>
-
-#include "cJSON.h"
-#include "cJSON_util.h"
-
-//void cJSON_free(void *ptr)
-//{
-//    rt_free(ptr);
-//}
-
-const char * cJSON_item_get_string(cJSON *object, const char *item_name)
-{
-    cJSON *item;
-
-    item = cJSON_GetObjectItem(object, item_name);
-
-    if(!item)
-        return 0;
-
-    if( (item->type != cJSON_String) && (item->type != cJSON_Array) )
-        return 0;
-
-    if(item->type == cJSON_Array)
-        return item->child->valuestring; // TODO
-
-    return item->valuestring;
-}
-
-int cJSON_item_get_number(cJSON *object, const char *item_name, int * result)
-{
-    cJSON *item;
-
-    item = cJSON_GetObjectItem(object, item_name);
-
-    if(!item)
-        return -1;
-
-    if(item->type != cJSON_Number)
-        return -1;
-
-    if(result)
-        *result = item->valueint;
-
-    return 0;
-}
-
-void cJSON_AddInteger2StringToObject(cJSON *object, const char *name, int i)
-{
-    char str_buf[10+2];
-
-    sprintf(str_buf, "%d", i);
-    cJSON_AddStringToObject(object, name, str_buf);
-}

+ 0 - 25
Application_CBD/packages/cJSON-latest/cJSON_util.h

@@ -1,25 +0,0 @@
-#ifndef __CJSON_UTIL_INCLUDE__
-#define __CJSON_UTIL_INCLUDE__
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "cJSON.h"
-
-extern void cJSON_free(void *ptr);
-
-extern const char * cJSON_item_get_string(cJSON *object,const char *string);
-extern int cJSON_item_get_number(cJSON *object, const char *item_name, int * result);
-extern void cJSON_AddInteger2StringToObject(cJSON *object, const char *name, int i);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CJSON_UTIL_INCLUDE__ */

+ 2 - 2
Application_CBD/packages/pkgs_error.json

@@ -1,7 +1,7 @@
 [
  {
-  "path": "/packages/peripherals/sht3x", 
+  "path": "/packages/iot/cJSON", 
   "ver": "latest", 
-  "name": "SHT3X"
+  "name": "CJSON"
  }
 ]

+ 0 - 56
Application_CBD/packages/sht3x-latest/README.md

@@ -1,56 +0,0 @@
-# SHT3X
-
-## 1、介绍
-
-这是一个在RT-Thread上,SHT3X系列温湿度传感器的驱动。实现了温湿度的单次查询(single-shot)读取,并支持`Finsh/MSH`测试命令。
-本驱动编程实现方便读取多个SHT3X传感器。地址IO的控制和数据的滤波留给用户自行编程处理。
-
-### 1.1 目录结构
-
-| 名称 | 说明 |
-| ---- | ---- |
-| docs  | 文档目录 |
-| docs/datasheets  | 数据手册目录 |
-| docs/api.md  | 应用编程接口说明 |
-| docs/version.md  | 版本说明 |
-| sht3x.h  | 头文件 |
-| sht3x.c  | 源代码 |
-| SConscript | RT-Thread 默认的构建脚本 |
-| README.md | 软件包使用说明 |
-
-### 1.2 许可证
-
-SHT3x package 遵循 `LGPLv2.1` 许可,详见 `LICENSE` 文件。
-
-### 1.3 依赖
-
-依赖 `RT-Thread I2C` 设备驱动框架。
-
-## 2、如何获取软件包
-
-使用 sht3x package 需要在 RT-Thread 的包管理器中选择它,具体路径如下:
-
-```
-RT-Thread online packages
-    peripheral libraries and drivers  --->
-        [*] sht3x: digital humidity and temperature sensor sht3x driver library
-```
-
-然后让 RT-Thread 的包管理器自动更新,或者使用 `pkgs --update` 命令更新包到 BSP 中。
-
-## 3、使用 sht3x
-
-本驱动实现基于RT-Thread的I2C设备驱动框架,在打开 sht3x package 后,请务必打开至少1个I2C设备。
-
-* 完整的 API 手册可以访问这个[链接](docs/api.md)
-* 更多文档位于 [`/docs`](/docs) 下,使用前 **务必查看**
-
-## 4、注意事项
-
-- 请注意SHT3X芯片的地址引脚默认是上拉还是下拉电阻。上拉对应地址0x45,下拉对应地址0x44。
-
-## 5、联系方式 & 感谢
-
-* 维护:hao.dong
-* 邮箱:hao.dong.nanjing@outlook.com
-* 主页:https://github.com/donghao2nanjing/sht3x

+ 0 - 9
Application_CBD/packages/sht3x-latest/SConscript

@@ -1,9 +0,0 @@
-from building import *
-
-cwd     = GetCurrentDir()
-src     = Glob('*.c')
-path    = [cwd]
-
-group = DefineGroup('sht3x', src, depend = ['PKG_USING_SHT3X'], CPPPATH = path)
-
-Return('group')

+ 0 - 13
Application_CBD/packages/sht3x-latest/docs/README.md

@@ -1,13 +0,0 @@
-# 文档
-
-## 软件包地址
-
-- https://github.com/donghao2nanjing/sht3x
-
-## 文档列表
-
-|文件名                             |描述|
-|:-----                             |:----|
-|[version.md](version.md)           |版本信息|
-|[api.md](api.md)                   |API 说明|
-

BIN
Application_CBD/packages/sht3x-latest/docs/datasheets/SHT3x_Alert_Mode_DIS_V1.pdf


BIN
Application_CBD/packages/sht3x-latest/docs/datasheets/Sensirion_Humidity_Sensors_SHT3x_Datasheet_digital.pdf


+ 0 - 6
Application_CBD/packages/sht3x-latest/docs/version.md

@@ -1,6 +0,0 @@
-# 版本和修订 #
-
-| Date       | Version   |  Author    | Note  |
-| --------   | :-----:   | :----      | :---- |
-| 2019-11-26 | v1.0.1      | hao.dong   | init release |
-|            |           |            | |

+ 0 - 506
Application_CBD/packages/sht3x-latest/sht3x.c

@@ -1,506 +0,0 @@
-#include <string.h>
-
-#define DBG_ENABLE
-#define DBG_SECTION_NAME "sht3x"
-#define DBG_LEVEL DBG_LOG
-#define DBG_COLOR
-#include <rtdbg.h>
-
-#include "sht3x.h"
-
-#ifdef PKG_USING_SHT3X
-
-#define CRC_POLY 0x31 
-
-/**
- * This function write 2-byte cmd to SHT3x 
- *
- * @param dev the pointer of device driver structure
- * @param cmd the 16bit command to be sent to SHT3x
- *
- * @return the cmd transfer status, RT_EOK reprensents setting successfully.
- */
-static rt_err_t write_cmd(sht3x_device_t dev, rt_uint16_t cmd)
-{
-    struct rt_i2c_msg msgs;
-    rt_uint8_t buf[2] ;
-    buf[0] = cmd >> 8 ;
-    buf[1] = cmd & 0xFF ;
-
-    msgs.addr = dev->sht3x_addr;
-    msgs.flags = RT_I2C_WR;
-    msgs.buf = buf;
-    msgs.len = 2;
-
-    if (rt_i2c_transfer(dev->i2c, &msgs, 1) == 1)
-        return RT_EOK;
-    else
-        return -RT_ERROR;
-}
-
-/**
- *  This function read len bytes from dev and store the bytes in to buf 
- * 
- * @param dev the pointer of device driver structure
- * @param buf the pointer to buffer array 
- * @param len the number of bytes to be read 
- * 
- * @return the i2c read status, RT_EOK represents success.
- */
-static rt_err_t read_bytes(sht3x_device_t dev, rt_uint8_t * buf, rt_uint8_t len)
-{
-    if(rt_i2c_master_recv(dev->i2c, dev->sht3x_addr, RT_I2C_RD, buf, len) == len){
-        return RT_EOK ;
-    }else
-    {
-        return - RT_ERROR ;
-    }
-    
-}
-
-/**
- * This function calculate CRC value of bytes in buffer
- * CRC_POLY is predefined as 0x31
- * 
- * @param buf the pointer to buffer array 
- * @param len the length of buffer array 
- * 
- * @return calculated CRC value.
- */
-static rt_uint8_t crc8(rt_uint8_t * buf, rt_uint8_t len)
-{
-    rt_uint8_t crc = 0xFF ;
-    rt_uint8_t i, j ;
-    for(j = len; j; j --){
-        crc ^= *buf ++ ;
-        for( i = 8; i; i --){
-            crc = (crc & 0x80) ? (crc << 1) ^ CRC_POLY : (crc << 1) ;
-        }
-    }
-    return crc ;
-}
-
-/** 
- * This function read temperature and humidity by single shot mode 
- * Attention: 
- *  - rt_thread_mdelay() is called to wait for SHT3x to be ready to read
- *  - the temperature and humidity is stored in the device driver structure
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the status of read data from SHT3x, RT_EOK means success.
- */
-rt_err_t sht3x_read_singleshot(sht3x_device_t dev)
-{
-    rt_uint8_t temp[6] ;
-    rt_err_t result;
-    RT_ASSERT(dev);
-
-    result = rt_mutex_take(dev->lock, RT_WAITING_FOREVER);
-    if (result == RT_EOK)
-    {
-        if( write_cmd(dev, dev->cmd_readout) == RT_EOK)
-        {
-			// wait about 5 ms
-			rt_thread_mdelay(5);
-            if(read_bytes(dev, temp, 6) == RT_EOK){
-                if(crc8(temp, 2) == temp[2]){
-                    dev->temperature = -45.0 + (temp[1] | temp[0] << 8) * 175.0 / (0xFFFF - 1) ; //sensor temperature convert to reality
-                    result = RT_EOK ;
-                }else{
-                    result = -RT_ERROR ;
-                }
-                if(crc8(temp + 3, 2) == temp[5]){
-                    dev->humidity = (temp[4] | temp[3] << 8) * 0.0015259022 ; //sensor humidity convert to reality
-                }else{
-                    result = -RT_ERROR ;
-                }
-            }else
-            {
-                result = -RT_ERROR ;
-            }
-        }
-        else
-        {
-            result = -RT_ERROR ;
-        }
-	rt_mutex_release(dev->lock);
-    }
-    else
-    {
-        LOG_E("Taking mutex of SHT3x failed.");
-        result = -RT_ERROR;
-    }
-	
-    return result;
-}
-
-/**
- * This function resets all parameter with default
- *
- * @param dev the pointer of device driver structure
- *
- * @return the softreset status, RT_EOK reprensents setting successfully.
- */
-rt_err_t sht3x_softreset(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-    
-    if( write_cmd(dev, CMD_SOFT_RESET) == RT_EOK)
-    {
-        return RT_EOK;
-    }else{
-        return RT_ERROR ;
-    }
-}
-
-/** 
- * This function clear the status register in SHT3x  
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_clear_status(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-
-    if( write_cmd(dev, CMD_CLEAR_STATUS) == RT_EOK)
-    {
-        return RT_EOK ;
-    }else{
-        return RT_ERROR ;
-    }
-}
-
-/**
- * This function read the status register from SHT3x
- * Attention:
- *  - the status word is stored in device driver structure
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_read_status(sht3x_device_t dev)
-{
-    rt_uint8_t buf[3];
-    RT_ASSERT(dev);
-    if( write_cmd(dev, CMD_READ_STATUS) == RT_EOK)
-    {
-        read_bytes(dev, buf, 3);
-        if( crc8(buf, 2) == buf[2])
-        {
-            dev->status.status_word = ( buf[0] << 8 ) | buf[1];
-            return RT_EOK ;
-        }
-    }
-
-    return -RT_ERROR ;
-}
-
-/**
- * This function enable heater
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_enable_heater(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-    if( write_cmd(dev, CMD_HEATER_ENABLE) == RT_EOK)
-    {
-        return RT_EOK ;
-    }else
-    {
-        return -RT_ERROR ;
-    }
-}
-
-/**
- * This function disable heater
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_disable_heater(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-    if( write_cmd(dev, CMD_HEATER_DISABLE) == RT_EOK)
-    {
-        return RT_EOK ;
-    }else
-    {
-        return -RT_ERROR ;
-    }
-}
-
-/**
- * This function write accelerated response time command to SHT3x
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_acc_resp_time(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-    if( write_cmd(dev, CMD_ART) == RT_EOK)
-    {
-        return RT_EOK ;
-    }else
-    {
-        return -RT_ERROR ;
-    }
-}
-
-/**
- * This function write break command to SHT3x to break out of continuous readout mode
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_break(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-    if( write_cmd(dev, CMD_BREAK) == RT_EOK)
-    {
-        return RT_EOK ;
-    }else
-    {
-        return -RT_ERROR ;
-    }
-}
-
-/**
- * This function initializes sht3x registered device driver
- *
- * @param i2c_bus_name the name of i2c device used by SHT3x device
- * @param sht3x_addr the address of SHT3x device
- * 
- * @return the pointer to sht3x device driver structure.
- */
-sht3x_device_t sht3x_init(const char *i2c_bus_name, rt_uint8_t sht3x_addr)
-{
-    sht3x_device_t dev;
-    RT_ASSERT(i2c_bus_name);
-
-    dev = rt_calloc(1, sizeof(struct sht3x_device));
-    if (dev == RT_NULL)
-    {
-        LOG_E("Can't allocate memory for sht3x device on '%s' ", i2c_bus_name);
-        return RT_NULL;
-    }
-
-    if(sht3x_addr == SHT3X_ADDR_PD || sht3x_addr == SHT3X_ADDR_PU){
-        dev->sht3x_addr = sht3x_addr ;
-    }else{
-        LOG_E("Illegal sht3x address:'%x'", sht3x_addr);
-        rt_free(dev);
-        return RT_NULL;
-    }
-    
-    dev->i2c = rt_i2c_bus_device_find(i2c_bus_name);
-
-    if (dev->i2c == RT_NULL)
-    {
-        LOG_E("Can't find sht3x device on '%s' ", i2c_bus_name);
-        rt_free(dev);
-        return RT_NULL;
-    }
-
-    dev->lock = rt_mutex_create("mutex_sht3x", RT_IPC_FLAG_FIFO);
-    if (dev->lock == RT_NULL)
-    {
-        LOG_E("Can't create mutex for sht3x device on '%s' ", i2c_bus_name);
-        rt_free(dev);
-        return RT_NULL;
-    }
-
-    // I2C streching disabled, medium repeatability for default single shot readout
-    dev->cmd_readout = CMD_MEAS_POLLING_M ;
-
-	// clear the status register
-	sht3x_clear_status(dev);
-	
-    return dev;
-}
-
-/**
- * This function releases memory and deletes mutex lock
- *
- * @param dev the pointer of device driver structure
- */
-void sht3x_deinit(sht3x_device_t dev)
-{
-    RT_ASSERT(dev);
-
-    rt_mutex_delete(dev->lock);
-
-    rt_free(dev);
-}
-
-/**
- * This function is exported to MSH commands list 
- * Usage example:
- *  - sht3x probe i2c1 pu : initialize sht3x device on i2c1 bus with address pin pulled up(i2c address 0x45)
- *  - sht3x probe i2c1: initialize sht3x device one i2c1 bus with address pin pulled down by default(i2c address 0x44)
- *  - sht3x read: read and print temperature and humidity from previously initialized sht3x
- */
-void sht3x(int argc, char *argv[])
-{
-    static sht3x_device_t dev = RT_NULL;
-    rt_uint8_t sht_addr = SHT3X_ADDR_PD ;
-    
-    if (argc > 1)
-    {
-        if (!strcmp(argv[1], "probe"))
-        {
-            if (argc >= 3)
-            {
-                /* initialize the sensor when first probe */
-                if (!dev || strcmp(dev->i2c->parent.parent.name, argv[2]))
-                {
-                    /* deinit the old device */
-                    if(dev)
-                    {
-						rt_kprintf("Deinit sht3x");
-                        sht3x_deinit(dev);
-                    }
-                    // no else needed here
-                    if( argc > 3)
-                    {
-                        if( !strcmp("pd", argv[3]))
-                        {
-                            sht_addr = SHT3X_ADDR_PD ;
-                        }
-                        else if( !strcmp("pu", argv[3]))
-                        {
-                            sht_addr = SHT3X_ADDR_PU ;
-                        }
-                        else
-                        {
-                            rt_kprintf("Illegal sht3x address, using 0x44 by default\n");
-                            sht_addr = SHT3X_ADDR_PD ; // pulled down by default: 0x44 
-                        }
-                    }
-                    // no else needed here
-
-                    dev = sht3x_init(argv[2], sht_addr);
-                    if(!dev)
-                    {
-                        rt_kprintf("sht3x probe failed, check input args\n");
-                    }else
-					{
-						rt_kprintf("sht3x probed, addr:0x%x\n", sht_addr) ;
-					}
-                }
-            }
-            else
-            {
-                rt_kprintf("sht3x probe <i2c dev name>   - probe sensor by given name\n");
-            }
-        }
-        else if (!strcmp(argv[1], "read"))
-        {
-            if (dev)
-            {
-                /* read the sensor data */
-                sht3x_read_singleshot(dev);
-
-                rt_kprintf("sht3x humidity   : %d.%d \n", (int)dev->humidity, (int)(dev->humidity * 10) % 10);
-                rt_kprintf("sht3x temperature: %d.%d \n", (int)dev->temperature, (int)(dev->temperature * 10) % 10);
-            }
-            else
-            {
-                rt_kprintf("Please using 'sht3x probe <i2c dev name> <pu/pd>' first\n");
-            }
-        }
-		else if (!strcmp(argv[1], "status"))
-		{
-			if(dev)
-			{
-				if(sht3x_read_status(dev) == RT_EOK)
-				{
-					rt_kprintf("sht3x status:\n");
-					rt_kprintf("\tchecksum:\t%d\t- 0 means checksum correct\n", dev->status.bits.checksum_ok);
-					rt_kprintf("\tcommand:\t%d\t- 0 means last cmd executed OK\n", dev->status.bits.command_ok);
-					rt_kprintf("\treset deteced:\t%d\n", dev->status.bits.reset_detected);
-					rt_kprintf("\talert pending:\t%d\n", dev->status.bits.alert_pending);
-					rt_kprintf("\tT track alert:\t%d\n", dev->status.bits.T_tracking_alert);
-					rt_kprintf("\tRH track alert:\t%d\n", dev->status.bits.RH_tracking_alert);
-					rt_kprintf("\theater enabled:\t%d\n", dev->status.bits.heater);
-				}else
-				{
-					rt_kprintf("sht3x status not read\n");
-				}
-			}else
-			{
-				rt_kprintf("Please using 'sht3x probe <i2c dev name> <pu/pd>' first\n");
-			}
-		}
-		else if (!strcmp(argv[1], "reset"))
-		{
-			if(dev)
-			{
-				if(sht3x_softreset(dev) == RT_EOK)
-				{
-					rt_kprintf("sht3x reset cmd sent\n");
-				}else
-				{
-					rt_kprintf("sht3x reset cmd not sent\n");
-				}
-			}else
-			{
-				rt_kprintf("Please using 'sht3x probe <i2c dev name> <pu/pd>' first\n");
-			}
-		}
-		else if (!strcmp(argv[1], "heater"))
-		{
-			if(dev)
-			{
-				if( !strcmp(argv[2], "on"))
-				{
-					if(sht3x_enable_heater(dev) == RT_EOK)
-					{
-						rt_kprintf("sht3x heater cmd sent\n");
-					}else
-					{
-						rt_kprintf("sht3x heater cmd not sent\n");
-					}
-				}else if( !strcmp(argv[2], "off"))
-				{
-					if(sht3x_disable_heater(dev) == RT_EOK)
-					{
-						rt_kprintf("sht3x heater cmd sent\n");
-					}else
-					{
-						rt_kprintf("sht3x heater cmd not sent\n");
-					}
-				}
-				else{
-					rt_kprintf("Please input correct format:sht3x heater on/off\n");
-				}
-			}else
-			{
-				rt_kprintf("Please using 'sht3x probe <i2c dev name> <pu/pd>' first\n");
-			}
-		}
-        else
-        {
-            rt_kprintf("Unknown command. Enter 'sht3x' for help\n");
-        }
-    }
-    else
-    {
-        rt_kprintf("Usage:\n");
-        rt_kprintf("\tsht3x probe <i2c dev name> <pu/pd> -- probe sensor by i2c dev name and pull config\n");
-        rt_kprintf("\tsht3x read -- read sensor sht3x data\n");
-		rt_kprintf("\tsht3x status -- status register of sht3x\n");
-		rt_kprintf("\tsht3x reset -- send soft reset command to sht3x\n");
-		rt_kprintf("\tsht3x heater <on/off> -- turn on/off heater of sht3x\n");
-    }
-}
-
-MSH_CMD_EXPORT(sht3x, sht3x sensor);
-
-#endif /* PKG_USING_SHT3X */

+ 0 - 182
Application_CBD/packages/sht3x-latest/sht3x.h

@@ -1,182 +0,0 @@
-#ifndef __SHT3X_H__
-#define __SHT3X_H__
-
-#include <rthw.h>
-#include <rtthread.h>
-#include <rtdevice.h>
-
-#define SHT3X_REPETABILITY_LOW 0
-#define SHT3X_REPETABILITY_MEDIUM 1
-#define SHT3X_REPETABILITY_HIGH 2
-
-/* sht3x commands define */
-// read serial number:
-#define CMD_READ_SERIALNBR  0x3780     
-// read status register:
-#define CMD_READ_STATUS     0xF32D     
-// clear status register:
-#define CMD_CLEAR_STATUS    0x3041  
-// enabled heater:
-#define CMD_HEATER_ENABLE   0x306D   
-// disable heater  
-#define CMD_HEATER_DISABLE  0x3066      
-// soft reset
-#define CMD_SOFT_RESET      0x30A2      
-// accelerated response time
-#define CMD_ART             0x2B32
-// break, stop periodic data acquisition mode
-#define CMD_BREAK           0x3093
-
-// measurement: polling, high repeatability
-#define CMD_MEAS_POLLING_H 0x2400  
-// measurement: polling, medium repeatability
-#define CMD_MEAS_POLLING_M 0x240B  
-// measurement: polling, low repeatability
-#define CMD_MEAS_POLLING_L 0x2416 
-
-#define SHT3X_ADDR_PD 0x44 // addr pin pulled down: 0x44
-#define SHT3X_ADDR_PU 0x45 // addr pin pulled down: 0x45
-
-typedef union sht3x_status_word
-{
-    rt_uint16_t status_word;
-    struct status_bits
-    {
-        rt_uint16_t checksum_ok : 1 ;
-        rt_uint16_t command_ok : 1 ;
-        rt_uint16_t reserved_3 : 2 ;
-        rt_uint16_t reset_detected : 1 ;
-        rt_uint16_t reserved_2 : 5 ;
-        rt_uint16_t T_tracking_alert : 1 ;
-        rt_uint16_t RH_tracking_alert : 1 ;
-        rt_uint16_t reserved_1 : 1 ;
-        rt_uint16_t heater : 1 ;
-        rt_uint16_t reserved_0 : 1 ;
-        rt_uint16_t alert_pending: 1 ;
-    } bits;
-}sht3x_status;
-
-struct sht3x_device
-{
-    struct rt_i2c_bus_device *i2c;
-    rt_uint8_t sht3x_addr ;
-    rt_mutex_t lock;
-    float temperature ;
-    float humidity ;
-    /* the command for data readout: change it as you need */ 
-    rt_uint16_t cmd_readout;
-    sht3x_status status ;
-};
-typedef struct sht3x_device *sht3x_device_t;
-
-/**
- * This function write 2-byte cmd to SHT3x 
- *
- * @param dev the pointer of device driver structure
- * @param cmd the 16bit command to be sent to SHT3x
- *
- * @return the cmd transfer status, RT_EOK reprensents setting successfully.
- */
-static rt_err_t write_cmd(sht3x_device_t dev, rt_uint16_t cmd);
-
-/**
- *  This function read len bytes from dev and store the bytes in to buf 
- * 
- * @param dev the pointer of device driver structure
- * @param buf the pointer to buffer array 
- * @param len the number of bytes to be read 
- * 
- * @return the i2c read status, RT_EOK represents success.
- */
-static rt_err_t read_bytes(sht3x_device_t dev, rt_uint8_t * buf, rt_uint8_t len);
-
-/** 
- * This function read temperature and humidity by single shot mode 
- * Attention: 
- *  - rt_thread_mdelay() is called to wait for SHT3x to be ready to read
- *  - the temperature and humidity is stored in the device driver structure
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the status of read data from SHT3x, RT_EOK means success.
- */
-rt_err_t sht3x_read_singleshot(sht3x_device_t dev);
-
-/**
- * This function resets all parameter with default
- *
- * @param dev the pointer of device driver structure
- *
- * @return the softreset status,RT_EOK reprensents setting successfully.
- */
-rt_err_t sht3x_softreset(sht3x_device_t dev);
-
-/** 
- * This function clear the status register in SHT3x  
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_clear_status(sht3x_device_t dev);
-
-/**
- * This function read the status register from SHT3x
- * Attention:
- *  - the status word is stored in device driver structure
- * 
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_read_status(sht3x_device_t dev);
-
-/**
- * This function enable heater
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_enable_heater(sht3x_device_t dev);
-
-/**
- * This function disable heater
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_disable_heater(sht3x_device_t dev);
-
-/**
- * This function write accelerated response time command to SHT3x
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_acc_resp_time(sht3x_device_t dev);
-
-/**
- * This function write break command to SHT3x to break out of continuous readout mode
- * @param dev the pointer of device driver structure
- * 
- * @return the command transfer status, RT_EOK means success.
- */
-rt_err_t sht3x_break(sht3x_device_t dev);
-
-/**
- * This function initializes sht3x registered device driver
- *
- * @param dev the name of sht3x device
- *
- * @return the sht3x device.
- */
-sht3x_device_t sht3x_init(const char *i2c_bus_name, rt_uint8_t sht3x_addr);
-
-/**
- * This function releases memory and deletes mutex lock
- *
- * @param dev the pointer of device driver structure
- */
-void sht3x_deinit(sht3x_device_t dev);
-
-#endif /* _SHT30_H__ */

+ 14 - 0
Application_CBD/readme.md

@@ -1,3 +1,17 @@
+# 2026-08-26 更新说明
+	#define VERSION_HK          "1.70.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.70.40(2000W)"         //4.0水稻
+	#define VERSION_ZP          "1.70.1(ZP)"            //1.0转盘
+	#define VERSION_GK          "1.70.1(GK)"            //1.0高空
+	1、取消定时重启RTU;
+	2、串口通信异常处理;
+	3、针对丢参数问题改进:
+		存在单独丢参数的情况,这个分支没有处理,增加异常恢复
+		高温保护、收集时间、加热时间、加热温度丢失时恢复默认值;
+		写参数时:把整个 device_status 里"用户可改"的字段打包成 blob,先写 mirror[0],校验通过			后再写 mirror[1]。两个扇区都带 magic+CRC+写入序号
+		启动时:读两份,对比 write_seq 大的那份 → 优先用;crc 失败的丢;两份都坏了才退到默认值
+		镜像区独立于 EasyFlash 的 ENV 区,不影响 EF 的 GC 和寿命
+		写顺序保证:先写副扇区(带 SEQ=N+1)→ 校验 → 再写主扇区(SEQ=N+1)→ 启动时永远以"高 SEQ 优先
 # 2026-07-28 更新说明
 	1、使用模拟RTC
 	2、取消雨控与ctr_Cold联动;

BIN
Application_CBD/rt-thread/tools/building.pyc


BIN
Application_CBD/rt-thread/tools/eclipse.pyc


BIN
Application_CBD/rt-thread/tools/menuconfig.pyc


BIN
Application_CBD/rt-thread/tools/mkdist.pyc


BIN
Application_CBD/rt-thread/tools/utils.pyc


+ 0 - 2
Application_CBD/rtconfig.h

@@ -344,8 +344,6 @@
 
 /* sensors drivers */
 
-#define PKG_USING_SHT3X
-#define PKG_USING_SHT3X_LATEST_VERSION
 /* end of sensors drivers */
 
 /* touch drivers */

BIN
Application_CBD/rtconfig.pyc