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

+ 26 - 7
Application_cbd_apm32f1/applications/control.c

@@ -2095,12 +2095,13 @@ void WorkTask(void)
                 ctr_shake(ON, device_status.shake_sec);
                 //补光&&拍照
                 LOG_I("拍照!!!");
-                ctr_led(ON);
-                HK_TakePhoto();
-                //清扫
-                device_status.clear_status=1;
-                //清扫失效则使用震动
-                //ctr_shake(ON, 100);
+                device_status.photo_ws = 1;
+//                ctr_led(ON);
+//                HK_TakePhoto();
+//                //清扫
+//                device_status.clear_status=1;
+//                //清扫失效则使用震动
+//                //ctr_shake(ON, 100);
             }
         }
    }
@@ -2385,16 +2386,19 @@ static void Control_Check_thread_entry(void *parameter)
     static int total_seconds = 200;
     static int current_second = 0;
     static int process = 0;
+
+    static int route_off_t = 0;
     #if MATCH_DEVICE == 1
     rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
     rt_pin_write(LED_P,ON);
     #endif
     device_status.C01 = 0;
+    device_status.route_off_t = 0;
     rt_thread_delay(10000);
+
     while(1)
     {
         if(device_status.update_flag==1) break;
-        if(device_status.version_type==5) break;
         if(device_status.work_status==1&&device_status.heat_sw==1)
         {
             ctr_lamp(ON, 1);
@@ -2423,11 +2427,25 @@ static void Control_Check_thread_entry(void *parameter)
             }else {
                 process = 0;
                 current_second = 0;
+                if(device_status.route_off_t!=0)
+                {
+                    ctr_router(OFF);
+                    route_off_t = device_status.route_off_t * 60 + 1;
+                    while(route_off_t!=0)
+                    {
+                        route_off_t--;
+                        rt_thread_delay(1000);
+                    }
+                    ctr_router(ON);
+                    device_status.route_off_t = 0;
+                }
+#if 0
                 if(device_status.rain_status==0)
                 {
                     rt_pin_mode(LED_P, PIN_MODE_OUTPUT);
                     rt_pin_write(LED_P,ON);
                 }
+
                 //根据故障码 亮指示灯
                 //灯管故障
                 if(device_status.C01 & (1 << 0))
@@ -2514,6 +2532,7 @@ static void Control_Check_thread_entry(void *parameter)
                     //延时10S
                     rt_thread_delay(10000);
                 }
+#endif
             }
 
         }

+ 1 - 0
Application_cbd_apm32f1/applications/control.h

@@ -129,6 +129,7 @@ typedef struct  _packed
     uint16_t shake_sec;      //震动时间
     uint16_t thsp;           //息屏时间
     uint16_t C01;            //故障码
+    uint16_t route_off_t;   //路由器断电时间
     rt_uint32_t num_updata;         //
     rt_uint32_t rebootcnt;          //启动次数
     rt_uint32_t light_over_tim;     //光控定时差秒数,镇流器的结束时间

+ 13 - 49
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -28,7 +28,7 @@
 #define DBG_ENABLE
 #define DBG_COLOR
 #define DBG_TAG "dtu"
-#define DBG_LEVEL         DBG_LOG
+#define DBG_LEVEL   DBG_LOG
 #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
 
 
@@ -128,7 +128,6 @@ static int DTU_uart2_init(void)
 /*数据发送*/
 void DTU_Write(char *fmt, ...)
 {
-    //static const char dtu_conf[4] = {device_status.vol,0x00,0x00,0x00};
     va_list ap;
     static char dtu_str[1024];
     rt_size_t str_length;
@@ -139,15 +138,7 @@ void DTU_Write(char *fmt, ...)
     if (str_length > 1024 - 1)
         str_length = 1024 - 1;
     rt_device_write(dtuserial, 0, dtu_str, str_length);
-    rt_thread_mdelay(100);
-//    if(strstr(dtu_str,"volume")!=RT_NULL)
-//    {
-//        rt_device_write(dtuserial,0,dtu_conf,4);
-//    }
-//    else if (strstr(dtu_str,"reset")!=RT_NULL) {
-//        const char dtu_conf[4] = {7,0x00,0x00,0x00};
-//        rt_device_write(dtuserial,0,dtu_conf,4);
-//    }
+    LOG_D("DTU_Write:%s",dtu_str);
 }
 /* 接收数据回调函数 */
 static rt_err_t dtu_input(rt_device_t dev, rt_size_t size)
@@ -451,7 +442,6 @@ static void dtu_thread_entry_send(void *parameter)
             }
             else {
                 char *readinfo =  makeJson_ReadInfo();
-                rt_kprintf("upload data:%s\n",readinfo);
                 DTU_Write("%s",readinfo);
                 rt_free(readinfo);
                 rt_thread_delay(1000);
@@ -1588,6 +1578,7 @@ int parseDtu(char *json_string)
               else if (strstr(item_cmd->valuestring,"ctrl")!=RT_NULL)
               {
                   type = cJSON_GetObjectItem(item_ext,"type");
+                  cJSON *time_s = cJSON_GetObjectItem(item_ext,"time");
                   if(strstr(type->valuestring,"rtu_off_on")!=RT_NULL)
                   {
                       LOG_W("DTU 12V Power down");
@@ -1660,6 +1651,15 @@ int parseDtu(char *json_string)
                   {
                       ctr_led(OFF);
                   }
+                  //{"ext": {"type": "route_off","time": 5}, "cmd": "ctrl"}   //远程关闭路由器电源
+                  else if (strstr(type->valuestring,"route_off")!=RT_NULL)
+                  {
+                      if(time_s!=RT_NULL)
+                      {
+                          device_status.route_off_t = time_s->valueint;
+                          LOG_I("设置路由器断电时间:%d",device_status.route_off_t);
+                      }
+                  }
                   else if(strstr(type->valuestring,"selfcheck")!=RT_NULL)
                   {
                       if(device_status.selfcheck_ws == 2)
@@ -1674,16 +1674,6 @@ int parseDtu(char *json_string)
                       }
                       LOG_I("收到自检指令:%d",device_status.selfcheck_ws);
                   }
-                  else if(strstr(type->valuestring,"insect_kill")!=RT_NULL)
-                  {
-                      device_status.autotakepic = 10;
-                      LOG_W("收到害虫信号!");
-                  }
-                  else if(strstr(type->valuestring,"insect_save")!=RT_NULL)
-                  {
-                      device_status.autotakepic = 11;
-                      LOG_W("收到益虫信号!");
-                  }
               }
               //切换平台
               else if (strstr(item_cmd->valuestring,"platform")!=RT_NULL)
@@ -1967,29 +1957,6 @@ int parseDtu(char *json_string)
                                 LOG_E("set_date failed!");
                             }
                       }
-//                      static char year_s[5],month_s[3],day_s[3],hour_s[3],min_s[3],sec_s[3];
-//                      strncpy(year_s, datetime->valuestring, 4);
-//                      strncpy(month_s,datetime->valuestring+4,2);
-//                      strncpy(day_s,datetime->valuestring+6,2);
-//                      strncpy(hour_s,datetime->valuestring+8,2);
-//                      strncpy(min_s,datetime->valuestring+10,2);
-//                      strncpy(sec_s,datetime->valuestring+12,2);
-//                      if(atoi(year_s)>=2024&&atoi(year_s)<3000&&atoi(month_s)>0&&atoi(month_s)<13&&atoi(day_s)>0&&atoi(day_s)<32)
-//                      {
-//                          if(set_date(atoi(year_s),atoi(month_s),atoi(day_s))==RT_EOK)
-//                          {
-//                              LOG_I("设置日期:%d年%d月%d日",atoi(year_s),atoi(month_s),atoi(day_s));
-//                              if(atoi(hour_s)>0&&atoi(hour_s)<=24&&atoi(min_s)>=0&&atoi(min_s)<=60&&atoi(sec_s)>=0&&atoi(sec_s)<=60)
-//                              {
-//                                  LOG_I("设置时间:%d时%d分%d秒",atoi(hour_s),atoi(min_s),atoi(sec_s));
-//                                  set_time(atoi(hour_s),atoi(min_s),atoi(sec_s));
-//                              }
-//                          }
-//                          else {
-//                              LOG_E("set_date failed!");
-//                              rt_hw_rtc_init();
-//                          }
-//                      }
                   }
 
                   LOG_I("参数同步:lat:%s lng:%s",lat->valuestring,lng->valuestring);
@@ -2674,11 +2641,8 @@ int parseDtu(char *json_string)
 void UpLoad_Data(void)
 {
     char *updata = makeJson();
-    LOG_I("upload data:%d %s",rt_strlen(updata),updata);
+    DTU_Write(updata);
     rt_free(updata);
-    #if Color_EN ==0
-    DTU_Write("%s",updata);
-    #endif
     //list_mem();
     //播放数据上传中语音
 }

+ 5 - 1
Application_cbd_apm32f1/applications/hmi.c

@@ -535,6 +535,7 @@ static void HMI_Decode(void)
         }
         else{
             ctr_shake(ON,device_status.shake_sec);
+            ctr_router(ON);
         }
     }
     //打开补光
@@ -1532,8 +1533,11 @@ static void Ctr_Mortor_entry(void* parameter)
             if(photo_led_sec==300)    //
             {
                 ctr_led(OFF);
-                photo_led_sec = 900;
                 device_status.photo_ws = 0;
+                if(device_status.work_status==1&&device_status.up_status==1)
+                {
+                    device_status.clear_status = 1;
+                }
                 HMI_WRITE("sysTest.switchPhoto.val=0");
                 HMI_WRITE("sysTest.switchFill.val=0");
             }

+ 4 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,7 @@
+# 2025-06-28 更新说明
+针对比赛设备:
+   定时开关路由器供电可通过屏幕震动  开启;
+   远程可控制路由器 关闭时间;
 # 2025-06-10 更新说明
 #define VERSION_HK_2000W    "2.22.4(2000W)"         //4.0水稻
 1. 自检清扫电流检测阈值150降低为120