|
@@ -26,6 +26,7 @@
|
|
|
#include "dtu_uart2.h"
|
|
#include "dtu_uart2.h"
|
|
|
#include <fal.h>
|
|
#include <fal.h>
|
|
|
#include "sys_monitor.h"
|
|
#include "sys_monitor.h"
|
|
|
|
|
+#include "param_mirror.h"
|
|
|
#define DBG_ENABLE
|
|
#define DBG_ENABLE
|
|
|
#define DBG_COLOR
|
|
#define DBG_COLOR
|
|
|
#define DBG_TAG "hmi"
|
|
#define DBG_TAG "hmi"
|
|
@@ -875,6 +876,7 @@ static void HMI_Decode(void)
|
|
|
LOG_I("开始排虫!");
|
|
LOG_I("开始排虫!");
|
|
|
device_status.handle_bugger = 0;
|
|
device_status.handle_bugger = 0;
|
|
|
ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
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){
|
|
else if(strstr(rx_buffer,"putTest.shouchong")!=NULL){
|
|
|
if(device_status.run_sta == 0){
|
|
if(device_status.run_sta == 0){
|
|
@@ -886,6 +888,7 @@ static void HMI_Decode(void)
|
|
|
LOG_I("开始收虫!");
|
|
LOG_I("开始收虫!");
|
|
|
device_status.handle_bugger = 1;
|
|
device_status.handle_bugger = 1;
|
|
|
ef_set_env_blob("handle_bugger", &device_status.handle_bugger, sizeof(device_status.handle_bugger));
|
|
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)
|
|
else if (strstr(rx_buffer,"stamp=")!=NULL)
|
|
@@ -1018,6 +1021,7 @@ static void HMI_Decode(void)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MA_save();
|
|
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);
|
|
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;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1101,12 +1105,12 @@ static void HMI_Decode(void)
|
|
|
//2022/06/23,add:
|
|
//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);
|
|
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, "修改工作时间");
|
|
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)
|
|
if(atoi(device_status.net)==0)
|
|
|
DTU_Write("%s",json_temp);
|
|
DTU_Write("%s",json_temp);
|
|
|
rt_free(json_temp);
|
|
rt_free(json_temp);
|
|
|
rt_thread_delay(2000);
|
|
rt_thread_delay(2000);
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
rt_free(var);
|
|
rt_free(var);
|
|
|
rt_kprintf("工作时间参数已保存:模式-%d,光控时间-%d,时控开始时间-%d,时控结束时间-%d\n",device_status.timeSwitch,device_status.sunBar,device_status.startBar,device_status.stopBar);
|
|
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("制冷开关:%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);
|
|
LOG_I("系统设置已保存:\n自动熄屏-%d\n音量-%d\n培养温度-%d\n数据上传间隔-%d",device_status.thsp,device_status.vol,device_status.heatvalue,device_status.dattim);
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
var = strstr(rx_buffer,"=");
|
|
var = strstr(rx_buffer,"=");
|
|
@@ -1211,6 +1216,7 @@ static void HMI_Decode(void)
|
|
|
}
|
|
}
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
rt_free(var);
|
|
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);
|
|
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); //数据上传间隔
|
|
device_status.dattim =atoi(dattim_str); //数据上传间隔
|
|
|
ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim));
|
|
ef_set_env_blob("dattim", &device_status.dattim, sizeof(device_status.dattim));
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
rt_kprintf("设置失败!!!\n");
|
|
rt_kprintf("设置失败!!!\n");
|
|
@@ -1303,7 +1310,6 @@ static void HMI_Decode(void)
|
|
|
//2022/06/23,add:
|
|
//2022/06/23,add:
|
|
|
rt_sprintf(device_status.json_w_platform,"屏幕操作:切换平台:8.136.98.49,操作时间:%s",device_status.stamp);
|
|
rt_sprintf(device_status.json_w_platform,"屏幕操作:切换平台:8.136.98.49,操作时间:%s",device_status.stamp);
|
|
|
json_temp = makeJson_Warn(device_status.json_w_platform, "切换平台");
|
|
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)
|
|
if(atoi(device_status.net)==0)
|
|
|
DTU_Write("%s",json_temp);
|
|
DTU_Write("%s",json_temp);
|
|
|
rt_free(json_temp);
|
|
rt_free(json_temp);
|
|
@@ -1325,7 +1331,6 @@ static void HMI_Decode(void)
|
|
|
//2022/06/23,add:
|
|
//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);
|
|
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, "切换平台");
|
|
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)
|
|
if(atoi(device_status.net)==0)
|
|
|
DTU_Write("%s",json_temp);
|
|
DTU_Write("%s",json_temp);
|
|
|
rt_free(json_temp);
|
|
rt_free(json_temp);
|
|
@@ -1340,7 +1345,6 @@ static void HMI_Decode(void)
|
|
|
//2022/06/23,add:
|
|
//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);
|
|
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, "系统重置");
|
|
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)
|
|
if(atoi(device_status.net)==0)
|
|
|
DTU_Write("%s",json_temp);
|
|
DTU_Write("%s",json_temp);
|
|
|
rt_free(json_temp);
|
|
rt_free(json_temp);
|
|
@@ -1354,7 +1358,6 @@ static void HMI_Decode(void)
|
|
|
//2022/06/23,add:
|
|
//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);
|
|
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, "系统重置");
|
|
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)
|
|
if(atoi(device_status.net)==0)
|
|
|
DTU_Write("%s",json_temp);
|
|
DTU_Write("%s",json_temp);
|
|
|
rt_free(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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
return;
|
|
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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -1462,6 +1470,7 @@ static void HMI_Decode(void)
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型+
|
|
|
DTU_Write("SwversionV41");
|
|
DTU_Write("SwversionV41");
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
|
|
|
|
@@ -1479,6 +1488,7 @@ static void HMI_Decode(void)
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
|
DTU_Write("SwversionV4");
|
|
DTU_Write("SwversionV4");
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
else {
|
|
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("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
ef_set_env_blob("dtype",&device_status.dtype,sizeof(device_status.dtype)); //版本类型
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else if (strstr(rx_buffer,"SwversionV30")!=NULL) {
|
|
else if (strstr(rx_buffer,"SwversionV30")!=NULL) {
|
|
@@ -1504,6 +1515,7 @@ static void HMI_Decode(void)
|
|
|
sprintf(device_status.driver, "%s",VERSION_Robot);
|
|
sprintf(device_status.driver, "%s",VERSION_Robot);
|
|
|
ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else if((strstr(rx_buffer,"SwversionV7")!=NULL)) {
|
|
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)); //版本类型
|
|
ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type)); //版本类型
|
|
|
DTU_Write("SwversionV7");
|
|
DTU_Write("SwversionV7");
|
|
|
MA_save();
|
|
MA_save();
|
|
|
|
|
+ param_mirror_sync();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
else if (strstr(rx_buffer,"putTest.switchFAN_PU=1")!=NULL) {
|
|
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;
|
|
static rt_uint16_t mock_uart_timer2_cnt = 0;
|
|
|
while(1)
|
|
while(1)
|
|
|
{
|
|
{
|
|
|
- #if 1
|
|
|
|
|
|
|
+#if 0
|
|
|
time_t time_reset12V;
|
|
time_t time_reset12V;
|
|
|
time(&time_reset12V);
|
|
time(&time_reset12V);
|
|
|
static struct tm alarm_reset12V;
|
|
static struct tm alarm_reset12V;
|
|
@@ -1647,12 +1660,11 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
char *rep = makeJsonRpc2_0("reboot",NULL, 1);
|
|
char *rep = makeJsonRpc2_0("reboot",NULL, 1);
|
|
|
if(rep){
|
|
if(rep){
|
|
|
DTU_Write(rep);
|
|
DTU_Write(rep);
|
|
|
- //启动超时定时器
|
|
|
|
|
free(rep);
|
|
free(rep);
|
|
|
}
|
|
}
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+#endif
|
|
|
if(device_status.mock_uart2_timer_flag==1)
|
|
if(device_status.mock_uart2_timer_flag==1)
|
|
|
{
|
|
{
|
|
|
mock_uart_timer2_cnt++;
|
|
mock_uart_timer2_cnt++;
|
|
@@ -1664,7 +1676,7 @@ static void Ctr_Mortor_entry(void* parameter)
|
|
|
}else{
|
|
}else{
|
|
|
mock_uart_timer2_cnt = 0;
|
|
mock_uart_timer2_cnt = 0;
|
|
|
}
|
|
}
|
|
|
- #endif
|
|
|
|
|
|
|
+
|
|
|
if(device_status.ctr_up_motor==1)
|
|
if(device_status.ctr_up_motor==1)
|
|
|
{
|
|
{
|
|
|
ctr_cangmen_up(OPEN);
|
|
ctr_cangmen_up(OPEN);
|
|
@@ -1898,6 +1910,24 @@ void Check_ParamConfig(void)
|
|
|
else {
|
|
else {
|
|
|
LOG_E("easyflash init ERRPR!!!");
|
|
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)
|
|
if(device_status.iSave!=FLASH_FLAG)
|
|
|
{
|
|
{
|
|
@@ -1971,9 +2001,28 @@ void Check_ParamConfig(void)
|
|
|
LOG_I("thsp:%d", device_status.thsp);
|
|
LOG_I("thsp:%d", device_status.thsp);
|
|
|
LOG_I("passwd:%d",device_status.passWord);
|
|
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读取参数配置
|
|
}//从easyflash读取参数配置
|
|
|
else if (device_status.iSave==FLASH_FLAG) {
|
|
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;
|
|
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("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("dattim",&device_status.dattim,sizeof(device_status.dattim),NULL); //数据上传间隔
|
|
|
ef_get_env_blob("stime", &device_status.clt_time, sizeof(device_status.clt_time), 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); //排虫
|
|
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.light_over_tim = device_status.sunBar * 3600; //光控计数
|
|
|
device_status.work_done = 0;
|
|
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.thsp==0) device_status.thsp = 300;
|
|
|
if(device_status.sunBar==0) device_status.sunBar = 4;
|
|
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测报灯,默认设置测报灯*/
|
|
/*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
|
|
|
if(device_status.dtype!=7)
|
|
if(device_status.dtype!=7)
|
|
|
{
|
|
{
|
|
@@ -2187,6 +2244,10 @@ void Check_ParamConfig(void)
|
|
|
#endif
|
|
#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)
|
|
void ResetParamDefault(void)
|
|
|
{
|
|
{
|
|
|
rt_sprintf(device_status.tempture,"%d",-15);
|
|
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("ds", &device_status.ds, sizeof(device_status.ds));
|
|
|
ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
ef_set_env_blob("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
|
ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
|
|
|
+ param_mirror_sync();
|
|
|
HMI_WRITE("play %d,%d,%d",1,5,0);
|
|
HMI_WRITE("play %d,%d,%d",1,5,0);
|
|
|
DTU_Write("reset.mp3");
|
|
DTU_Write("reset.mp3");
|
|
|
rt_thread_delay(1000);
|
|
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("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("thsp", &device_status.thsp, sizeof(device_status.thsp));
|
|
|
ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
ef_set_env_blob("passWord", &device_status.passWord,sizeof(device_status.passWord));
|
|
|
|
|
+ param_mirror_sync();
|
|
|
DTU_Write("reset.mp3");
|
|
DTU_Write("reset.mp3");
|
|
|
rt_thread_delay(1000);
|
|
rt_thread_delay(1000);
|
|
|
}
|
|
}
|