|
|
@@ -314,13 +314,13 @@ static void dtu_thread_entry_recv(void *parameter)
|
|
|
rx_buffer[rx_length] = '\0';
|
|
|
// 处理数据(新增调试接口)
|
|
|
LOG_I("Raw Data:%s-%d",rx_buffer, rx_length);
|
|
|
-
|
|
|
- if(device_status.dtype==3)
|
|
|
+ if(strstr(rx_buffer,"{")==RT_NULL||strstr(rx_buffer,"}")==RT_NULL)
|
|
|
{
|
|
|
HMI_WRITE("sysSet.va0.txt=\"%s\"",rx_buffer);
|
|
|
- rt_timer_stop(timer_uart2);
|
|
|
+ }else{
|
|
|
+ process_uart_data(rx_buffer, rx_length);
|
|
|
}
|
|
|
- process_uart_data(rx_buffer, rx_length);
|
|
|
+
|
|
|
rt_free(rx_buffer);
|
|
|
#if 0
|
|
|
if(result == RT_EOK)
|
|
|
@@ -444,9 +444,7 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
{
|
|
|
|
|
|
device_status.power_status = 1;
|
|
|
- device_status.num_updata = 0;
|
|
|
- static uint16_t current_arry[10];
|
|
|
- static uint8_t record_current = 0;
|
|
|
+ device_status.num_updata = 200;
|
|
|
rt_thread_delay(10000);
|
|
|
static rt_uint16_t wait_i = 0;
|
|
|
static rt_uint8_t check_i = 0;
|
|
|
@@ -458,7 +456,7 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
static struct tm now_tm; //现在
|
|
|
//获取当前时间戳
|
|
|
now_tm =*localtime(&now_t);
|
|
|
- if(atoi(device_status.net)==0||atoi(device_status.gps)==1||(now_tm.tm_year+1900 >=2024)) //当前时间大于2024
|
|
|
+ if(atoi(device_status.net)==0||(now_tm.tm_year+1900 >=2024)) //当前时间大于2024
|
|
|
{
|
|
|
if(device_status.rain_status==1||device_status.temp_status==1)
|
|
|
{
|
|
|
@@ -480,13 +478,14 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
HMI_WRITE("sleep=%d",1);
|
|
|
}
|
|
|
if(device_status.sleep_mode == 1) {
|
|
|
- if(device_status.num_updata==120)
|
|
|
+ LOG_I("启动联网模块剩余:%d -120",device_status.num_updata);
|
|
|
+ if(device_status.num_updata==120&&device_status.work_status==0)
|
|
|
{
|
|
|
+ device_status.dattim = 120; //省电,设置上传间隔为2H
|
|
|
ctr_router(ON);
|
|
|
ctr_RTU_DTU(ON);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else {
|
|
|
char *readinfo = makeJson_ReadInfo();
|
|
|
@@ -506,12 +505,6 @@ static void dtu_thread_entry_send(void *parameter)
|
|
|
}
|
|
|
device_status.num_updata = device_status.dattim * 60;
|
|
|
if(device_status.dattim==0) device_status.dattim=30; //数据上传时间间隔设置为0?
|
|
|
-
|
|
|
- if(device_status.sleep_mode == 1) {
|
|
|
- rt_thread_delay(5000);
|
|
|
- ctr_router(OFF);
|
|
|
- ctr_RTU_DTU(OFF);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
@@ -1307,6 +1300,7 @@ int parseDtu(char *json_string)
|
|
|
free(json_temp);
|
|
|
}
|
|
|
if(device_status.work_status==0) ctr_lamp(OFF, 1); //关闭高压
|
|
|
+ device_status.sleep_mode = 10;
|
|
|
}
|
|
|
if(item_checkself!=NULL){//自检签名
|
|
|
memset(device_status.qianming,0,sizeof(device_status.qianming));
|
|
|
@@ -1370,6 +1364,12 @@ int parseDtu(char *json_string)
|
|
|
rt_free(shake);
|
|
|
rt_thread_delay(2000);
|
|
|
}
|
|
|
+ //{"cmd":"photoinfo","ext":{"photo_ct":2}}
|
|
|
+ else if (strstr(item_cmd->valuestring,"photoinfo")!=RT_NULL)
|
|
|
+ {
|
|
|
+ device_status.sleep_mode = 10;
|
|
|
+ LOG_I("拍照成功,准备关闭联网模块电源!");
|
|
|
+ }
|
|
|
//远程给rtu重新上电
|
|
|
else if (strstr(item_cmd->valuestring,"ctrl")!=RT_NULL)
|
|
|
{
|
|
|
@@ -1417,6 +1417,7 @@ int parseDtu(char *json_string)
|
|
|
{
|
|
|
ctr_led(OFF);
|
|
|
}
|
|
|
+ //{"ext": {"type": "sleep_mode"}, "cmd": "ctrl"}
|
|
|
else if(strstr(type->valuestring,"sleep_mode")!=RT_NULL)
|
|
|
{
|
|
|
device_status.sleep_mode = 1;
|
|
|
@@ -1424,45 +1425,7 @@ int parseDtu(char *json_string)
|
|
|
LOG_I("收到设置休眠指令:%d",device_status.sleep_mode);
|
|
|
}
|
|
|
}
|
|
|
- //切换平台
|
|
|
- else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
|
|
|
- {
|
|
|
- type = cJSON_GetObjectItem(item_ext,"type");
|
|
|
- if(strstr(type->valuestring,"8.136.98.49")!=RT_NULL)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
|
- ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
|
|
|
- //给RTU发送切换指令
|
|
|
- DTU_Write("%s",makeJson_platform("8.136.98.49"));
|
|
|
- rt_free(makeJson_platform("8.136.98.49"));
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_sprintf(device_status.json_w_platform,"平台操作:切换平台>大数据,操作时间:%s",device_status.stamp);
|
|
|
- json_s = 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_s);
|
|
|
- rt_free(json_s);
|
|
|
- rt_thread_delay(1000);
|
|
|
- MA_save();
|
|
|
- }
|
|
|
- else if (strstr(type->valuestring,"120.27.222.26")!=RT_NULL)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "120.27.222.26");
|
|
|
- ef_set_env_blob("platform", &device_status.mqttcfg1, sizeof(device_status.mqttcfg1));
|
|
|
- //给RTU发送切换指令
|
|
|
- DTU_Write("%s",makeJson_platform("120.27.222.26"));
|
|
|
- rt_free(makeJson_platform("120.27.222.26"));
|
|
|
- rt_thread_delay(1000);
|
|
|
- rt_sprintf(device_status.json_w_platform,"平台操作:切换平台>四情,操作时间:%s",device_status.stamp);
|
|
|
- json_s = 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_s);
|
|
|
- rt_free(json_s);
|
|
|
- rt_thread_delay(1000);
|
|
|
- MA_save();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
//水稻2000万像素的串口拍照指令
|
|
|
else if (strstr(item_cmd->valuestring,"mvs_photo")!=RT_NULL)
|
|
|
{
|
|
|
@@ -1487,7 +1450,7 @@ int parseDtu(char *json_string)
|
|
|
rt_free(restart);
|
|
|
rt_thread_delay(2000);
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
else if (strstr(item_cmd->valuestring,"update")!=RT_NULL)
|
|
|
{
|
|
|
rt_kprintf("准备升级!!!");
|
|
|
@@ -1631,18 +1594,14 @@ int parseDtu(char *json_string)
|
|
|
mqttcfg2 = cJSON_GetObjectItem(item_ext,"mqttcfg2");
|
|
|
link_sta = cJSON_GetObjectItem(item_ext,"link_sta");
|
|
|
link_ip = cJSON_GetObjectItem(item_ext,"link_ip");
|
|
|
- photo_sta = cJSON_GetObjectItem(item_ext,"photo_sta");
|
|
|
cJSON *gps_inuse = cJSON_GetObjectItem(item_ext,"gps_inuse");
|
|
|
cJSON *gps_view = cJSON_GetObjectItem(item_ext,"gps_view");
|
|
|
//如果DTU的IMEI和FLash中的不一样,保存到FLASH
|
|
|
value_commn = cJSON_GetObjectItem(item_ext,"photo_sta");
|
|
|
- if(photo_sta!=NULL){
|
|
|
- device_status.camsta = photo_sta->valueint;
|
|
|
- LOG_I("相机状态:%d",device_status.camsta);
|
|
|
- }
|
|
|
+
|
|
|
if(value_commn!=RT_NULL)
|
|
|
{
|
|
|
- HMI_WRITE("menu.eth1_sta.val=%d",atoi(value_commn->valuestring));
|
|
|
+ device_status.camsta = value_commn->valueint;
|
|
|
}
|
|
|
value_commn = cJSON_GetObjectItem(item_ext,"cpu_tmp");
|
|
|
sprintf(device_status.cpu_temp,"%s",value_commn->valuestring);
|
|
|
@@ -1817,16 +1776,8 @@ int parseDtu(char *json_string)
|
|
|
sprintf(device_status.project,"%s",project->valuestring);
|
|
|
if(mqttcfg1!=NULL)
|
|
|
{
|
|
|
- if(strstr("8.136.98.49",mqttcfg1->valuestring)!=RT_NULL)
|
|
|
- {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
|
- }
|
|
|
- else if (strstr("120.27.222.26",mqttcfg1->valuestring)!=RT_NULL) {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "120.27.222.26");
|
|
|
- }
|
|
|
- else {
|
|
|
- rt_sprintf(device_status.mqttcfg1, "8.136.98.49");
|
|
|
- }
|
|
|
+ rt_sprintf(device_status.mqttcfg1, mqttcfg1->valuestring);
|
|
|
+
|
|
|
LOG_I("当前平台1:%s",mqttcfg1->valuestring);
|
|
|
}
|
|
|
if(mqttcfg2!=NULL)
|
|
|
@@ -2378,16 +2329,6 @@ int parseDtu(char *json_string)
|
|
|
UpLoad_Data();
|
|
|
rt_thread_delay(2000);
|
|
|
//2022/06/23,add:
|
|
|
- if(device_status.dtype==3)
|
|
|
- {
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
rt_thread_delay(1000);
|
|
|
MA_save();
|
|
|
rt_thread_delay(1000);
|
|
|
@@ -2406,6 +2347,11 @@ void UpLoad_Data(void)
|
|
|
#if Color_EN ==0
|
|
|
DTU_Write("%s",updata);
|
|
|
#endif
|
|
|
+ if(device_status.sleep_mode == 1&&device_status.work_status==0&&atoi(device_status.net)==0) {
|
|
|
+ rt_thread_delay(5000);
|
|
|
+ ctr_router(OFF);
|
|
|
+ ctr_RTU_DTU(OFF);
|
|
|
+ }
|
|
|
//list_mem();
|
|
|
//播放数据上传中语音
|
|
|
}
|