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

BIN
Application_cbd_apm32f1/.settings/.rtmenus


+ 1 - 1
Application_cbd_apm32f1/.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="-436559387563516312" 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="-406456977695124745" 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>

+ 0 - 562
Application_cbd_apm32f1/applications/control.c

@@ -163,45 +163,7 @@ void ctr_JD_Clear(uint8_t shake_sw)
     ctr_cangmen_up(OFF);    //关闭清扫
     ctr_Heat(OFF);
 }
-//工作任务流程
-void WorkTask_XCT(void)
-{
-    while(device_status.work_status==1&&device_status.ds==1)
-    {
 
-        ctr_Motor_xifu(ON);
-        //打开相机供电
-        ctr_Camera_Power(ON);
-        //ctr_Heat(ON);   //清洁风机
-        uint32_t photo_fre = 0;
-        photo_fre = device_status.dattim * 60;
-        while(photo_fre!=0)
-        {
-            photo_fre --;
-            rt_thread_delay(1000);
-            LOG_I("收集中,等待开始拍照:%d",photo_fre);
-        }
-        //卷带
-        ctr_JD_Clear(OFF);
-        //拍照
-        HK_TakePhoto();
-        //关闭吸附风机
-        ctr_Motor_xifu(OFF);
-        //关闭相机供电
-        //ctr_Heat(OFF);
-        ctr_Camera_Power(OFF);
-        //卷带
-        ctr_JD_Clear(ON);
-//        rt_thread_delay(1000);
-//        ctr_JD_Clear(ON);
-        //震动
-        Motor_shake(ON, device_status.shake_sec);
-    }
-    //关闭风机
-    ctr_Motor_xichong(OFF);
-    ctr_Motor_xifu(OFF);
-    LOG_I("不在工作时间,未工作!!!");
-}
 /**********************************************************************/
 /*光控*/
 uint8_t In_Light_status(void)
@@ -1080,94 +1042,6 @@ void Hk_Take_io(void)
     rt_pin_write(HK_IO, 1);
 }
 
-void calorstat(uint16_t heat_time)
-{
-    //uint8_t heat_up_cnt = 0;
-    uint16_t n = 0;
-    uint16_t delay_heat = 60;
-    FlagStatus heat_flg = RESET;
-    device_status.heat_time_min = 0;
-    device_status.run_sta = device_status.heattem;      //初始化加热实时温度
-    ctr_Heat(ON);
-//    UpLoad_Data();      //开始加热时的第一条数据
-    //恒温模式
-    for(n=0;n < heat_time;n++)
-    {
-        if(device_status.heattem>device_status.heatvalue&&heat_flg==RESET)
-        {
-            heat_flg = SET;
-            ctr_Heat(OFF);
-            while(delay_heat!=0)
-            {
-                device_status.C01 &= ~(1<<1);   //加热 正常
-                delay_heat --;
-                rt_kprintf("正在恒温加热!!!:%d",delay_heat);
-                HMI_WRITE("workSta.g0.txt=\"正在恒温加热!!!:%d\"",delay_heat);
-                rt_thread_delay(1000);
-                if(device_status.heattem>device_status.run_sta + 1){
-                    device_status.run_sta = device_status.heattem;
-                }
-            }
-            delay_heat = 60;
-            //跳出FOR循环
-            n = n + 60;
-        }
-
-        if(device_status.heattem>device_status.run_sta + 1){
-            device_status.run_sta = device_status.heattem;
-        }
-        if(device_status.heattem < (device_status.heatvalue - 5)&&heat_flg == SET)
-        {
-            //device_status.run_sta = device_status.heattem;
-            ctr_Heat(ON);
-        }
-        else if (device_status.heattem>=device_status.heatvalue&&heat_flg==SET)
-        {
-//            if(heat_up_cnt==0)
-//            {
-//                UpLoad_Data();      //加热到设定温度的数据
-//                heat_up_cnt = 1;
-//            }
-            //device_status.run_sta = device_status.heattem;
-            ctr_Heat(OFF);
-        }
-        if((n % 60)==0)
-        {
-            device_status.heat_time_min = device_status.heat_time_min + 1;
-            if(device_status.heat_time_min % 5 == 0)    //加热5分钟温度低于50,判定加热故障
-            {
-                if(device_status.heattem<50) {
-                    device_status.C01 |= (1 << 1);  // 第1位变为1,加热故障
-                }else {
-                    device_status.C01 &= ~(1<<1);   //加热 正常
-                }
-            }
-        }
-        //如果触发异常退出加热
-        if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-        {
-            rt_thread_delay(1000);
-            if(device_status.bat_status == 1)
-            {
-                rt_kprintf("============================触发异常退出加热==========================");
-                ctr_lamp(OFF,1);
-                ctr_Heat(OFF);
-                break;
-            }
-        }
-        if(device_status.timeSwitch==0&&device_status.sun_status==1)
-        {
-            ctr_Heat(OFF);
-            rt_kprintf("异常退出!!!\n");
-            break;
-        }
-        rt_thread_delay(1000);
-        rt_kprintf("=======正在加热======:%d-%d\n",n,heat_time);
-        HMI_WRITE("workSta.g0.txt=\"正在加热!!!:%d-%d\"",n,heat_time);
-    }
-    ctr_Heat(OFF);
-    //UpLoad_Data();      //加热结束的数据
-}
 //初始化所有控制驱动,关闭
 void HardWare_Init(uint8_t boot)
 {
@@ -1487,430 +1361,6 @@ void WorkCheck(void)
 }
 
 
-#if 0
-//工作状态检测
-void WorkCheck(void)
-{
-    static rt_uint32_t light_timeout = 3600;
-    static int check_stamp_cnt = 0;
-    //雨控检测,温控检测,电池电压检测
-    while(device_status.ds==1&&device_status.rain_status==0&&device_status.temp_status==0&&device_status.bat_status==0)
-    {
-        //工作模式检测(RTC时间正常,1-时控/0-光控)(RTC时间异常强行使用光控)
-        if(device_status.timeSwitch==1)
-        {
-            LOG_I("***********时控*****************");
-            if(device_status.startBar==device_status.stopBar&&device_status.startBar==0){
-                device_status.work_status = 1;
-                LOG_I("24 hours work...");
-                #if LAMP_EN == 1
-                device_status.lamp_status = 1;
-                device_status.lamp1_status = 0;
-                device_status.lamp2_status = 0;
-                if(device_status.sun_status==1){
-                    ctr_lamp(OFF, 1);
-                    ctr_lamp(OFF, 2);
-                    ctr_lamp(OFF, 3);
-                }
-                #endif
-            }
-
-            //如果开始和结束是同一天
-            if(device_status.startBar<device_status.stopBar)
-            {
-                LOG_I("开始和结束是同一天");
-                time_t now;
-                time(&now);
-                static struct tm nowtime;   //现在
-                static struct tm starttime; //开始
-                static struct tm endtime;   //结束
-                //获取当前时间戳
-                nowtime =*localtime(&now);
-                nowtime.tm_hour = nowtime.tm_hour-8;
-                //获取定时开始的时间戳
-                starttime = *localtime(&now);
-                starttime.tm_hour = device_status.startBar-8;
-                starttime.tm_min = 0;
-                starttime.tm_sec = 0;
-                //获取定时结束的时间戳
-                endtime = *localtime(&now);
-                endtime.tm_hour = device_status.stopBar-8;
-                endtime.tm_min = 0;
-                endtime.tm_sec = 0;
-                LOG_I("***工作结束在当天:现在时间:%d-开始时间:%d-结束时间:%d***",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
-                //如果当前时间大于开始时间且小于结束时间,且没有开始工作
-                if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&endtime))<0))
-                {
-                    LOG_I("当前时间大于开始时间,小于结束时间,工作中!!!");
-                    check_stamp_cnt++;
-                    if(check_stamp_cnt>20)
-                    {
-                        device_status.work_status = 1;
-                    }
-
-                }
-                //如果当前时间小于开始时间
-                else if(difftime(mktime(&nowtime),mktime(&starttime))<0)
-                {
-                    LOG_I("当前时间小于开始时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
-                    device_status.work_status = 0;
-                    check_stamp_cnt = 0;
-                }
-                //当前时间大于结束时间
-                else {
-                    LOG_I("当前时间大于结束时间,不工作!!!-%d-%d",mktime(&nowtime),mktime(&starttime));
-                    device_status.work_status = 0;
-                    check_stamp_cnt = 0;
-                }
-                #if LAMP_EN == 1
-                //如果当前时间超过20点,未到21点
-                if((difftime(mktime(&nowtime), mktime(&starttime)) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+3600)<0))
-                {
-                    LOG_I("3led:20~21");
-                    device_status.lamp_status = 1;
-                    device_status.lamp1_status = 0;
-                    device_status.lamp2_status = 0;
-                }
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)+3600) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+7200)<0)) {
-                    LOG_I("3led:21~22");
-                    device_status.lamp1_status = 1;
-                    device_status.lamp_status = 0;
-                    device_status.lamp2_status = 0;
-                }
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)+7200) >=0) && (difftime(mktime(&nowtime),mktime(&starttime)+10800)<0)) {
-                    LOG_I("3led:22~23");
-                    device_status.lamp2_status = 1;
-                    device_status.lamp_status = 0;
-                    device_status.lamp1_status =0;
-                }
-                #endif
-            }
-            //如果结束时间是第二天
-            else if (device_status.startBar>device_status.stopBar) {
-                time_t now;
-                time(&now);
-                static struct tm nowtime;   //现在
-                static struct tm starttime; //开始
-                static struct tm endtime;   //结束
-                //获取当前时间戳
-                nowtime =*localtime(&now);
-                nowtime.tm_hour = nowtime.tm_hour-8;
-                //获取定时开始的时间戳
-                starttime = *localtime(&now);
-                starttime.tm_hour = device_status.startBar-8;
-                starttime.tm_min = 0;
-                starttime.tm_sec = 0;
-                //获取定时结束的时间戳
-                endtime = *localtime(&now);
-                endtime.tm_hour = device_status.stopBar-8;
-                endtime.tm_min = 0;
-                endtime.tm_sec = 0;
-                LOG_I("工作结束在第二天:现在时间:%d-开始时间:%d-结束时间:%d!!!",mktime(&nowtime),mktime(&starttime),mktime(&endtime));
-                //如果当前时间大于开始时间,且没有开始工作 ,注意时间戳日期加1
-                if((difftime(mktime(&nowtime), mktime(&starttime)) > 0 ))
-                {
-                    //获取定时结束的时间戳
-                    endtime = *localtime(&now);  //将获取到的时间转换为时间戳
-                    endtime.tm_hour = device_status.stopBar-8;  //这里需减8用于时区转换
-                    endtime.tm_min = 0;
-                    endtime.tm_sec = 0;
-                    device_status.work_status = 1;
-                    LOG_I("当前前时间大于开始时间,且没有开始工作");
-                }
-                //当前时间小于开始时间
-                else if ((difftime(mktime(&nowtime), mktime(&starttime)) < 0))
-                {
-                    //获取定时结束的时间戳
-                    endtime = *localtime(&now);  //将获取到的时间转换为时间戳
-                    endtime.tm_hour = device_status.stopBar-8;  //这里需减8用于时区转换
-                    endtime.tm_min = 0;
-                    endtime.tm_sec = 0;
-                    //如果当前时间戳小于结束时间戳
-                    if(difftime(mktime(&nowtime),mktime(&endtime)) < 0)
-                    {
-                        LOG_I("当前时间大于开始时间,且没有开始工作,当前时间小于结束时间的情况:计算工作时间:从当前时间工作第二天的结束时间");
-                        device_status.work_status = 1;
-                    }
-                    else
-                    {
-                        LOG_I("当前时间小于开始时间,且没有开始工作,不是重启引起的,即还没到开始时间");
-                        device_status.work_status = 0; //不在工作时间,待机
-                    }
-                }
-            }
-        }
-        else {
-                LOG_I("光控定时模式!");
-
-                if(device_status.sun_status==0&&device_status.light_over_tim!=0)
-                {
-
-                    device_status.light_over_tim--;
-                    light_timeout = 3600;
-                    #if LAMP_EN == 1
-                    Led_Check(device_status.sunBar);
-                    #else
-                    device_status.work_status = 1;;
-                    LOG_I("光控定时,计时中>>>>>>>>>:%d",device_status.light_over_tim);
-                    #endif
-                }
-                else
-                {
-                    light_timeout --;
-                    //没有在测试并且没有在自检
-                    if(device_status.test_flag==0&&device_status.selfcheck_ws==0)
-                    {
-                        ctr_lamp(OFF,1);
-                        #if LAMP_EN == 1
-                        ctr_lamp(OFF,2);
-                        ctr_lamp(OFF,3);
-                        #endif
-                    }
-                    device_status.work_status = 0;
-                    if(light_timeout==0) device_status.light_over_tim = 0;  //持续1小时白天,清除光控计时,20250519
-                    if(device_status.light_over_tim==0&&device_status.sun_status==1) device_status.light_over_tim = device_status.sunBar * 3600;
-                    LOG_I("光控中,白天:%d!!!",device_status.sun_status);
-                }
-        }
-        rt_thread_delay(1000);
-    }
-    LOG_I("雨控状态,温控状态,电压状态:%d-%d-%d",device_status.rain_status,device_status.temp_status,device_status.bat_status);
-    device_status.work_status = 0;
-    rt_thread_delay(1000);
-}
-#endif
-//工作任务流程s
-void WorkTask(void)
-{
-    static int clt_time = 0; //收集时间差秒数
-    static int heat_time = 0;
-    LOG_I("工作状态:%d",device_status.work_status);
-    LOG_I("开关机状态:%d",device_status.ds);
-    while(device_status.work_status==1&&device_status.temp_status==0&&device_status.bat_status==0&&device_status.rain_status==0&&device_status.ds==1&&device_status.clear_status==0)
-    {
-        device_status.work_done = 0;
-        if(clt_time==0)
-        {
-            #if 0
-            if(device_status.version_type==41&&atoi(device_status.power)<350)
-            {
-                LOG_W("相机电流不足!");
-                char *ctr_hk_p_warn = makeJson_Warn("电流不足", "相机");
-                DTU_Write("%s",ctr_hk_p_warn);
-                rt_free(ctr_hk_p_warn);
-            }
-            #endif
-            #if 0//LAMP_EN == 0
-            ctr_Fan_PUT(ON);
-            #endif
-            DTU_Write("workstart.mp3");
-            if(device_status.debug_ws==1)
-            {
-                time_t stamp=time(RT_NULL);
-                static struct tm tm;
-                gmtime_r(&stamp, &tm);
-                rt_sprintf(device_status.stamp,"%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);
-                char* debug_str = makeJson_Warn("Work start!", device_status.stamp);
-                DTU_Write(debug_str);
-                rt_free(debug_str);
-            }
-        }
-        //1.打开灯管
-        #if LAMP_EN == 1
-        if(device_status.lamp_status==1&&device_status.sun_status==0)   //光控状态不亮灯
-        {
-            ctr_lamp(ON,1);
-            ctr_lamp(OFF,2);
-            ctr_lamp(OFF,3);
-        }
-        else if (device_status.lamp1_status==1&&device_status.sun_status==0) {
-            ctr_lamp(OFF,1);
-            ctr_lamp(ON,2);
-            ctr_lamp(OFF,3);
-        }
-        else if (device_status.lamp2_status==1&&device_status.sun_status==0) {
-            ctr_lamp(OFF,1);
-            ctr_lamp(OFF,2);
-            ctr_lamp(ON,3);
-        }
-        #else
-            ctr_lamp(ON,1);
-        #endif
-        LOG_I("打开灯管!!!");
-        #if 0
-        rt_thread_delay(2000);
-        if(atoi(device_status.power)<450)
-        {
-            LOG_I("Current is:%d",atoi(device_status.power));
-            if(atoi(device_status.power)>50&&atoi(device_status.power)<5000)        //过滤电流检测芯片损坏导致电流异常
-            {
-                char* lamp_err_warn = makeJson_Warn("电流不足", "灯管");
-                DTU_Write("%s",lamp_err_warn);
-                rt_free(lamp_err_warn);
-            }
-        }
-        #endif
-        if(device_status.version_type!=5)
-        {
-            rt_thread_delay(1000);  //待灯管启动再往下执行,否则会触发电机过流
-            //2.打开上仓门
-            LOG_I("打开上仓门!!!");
-            device_status.ctr_up_motor = 1;
-            //3.收集
-            clt_time = device_status.clt_time * 60;
-
-            while(clt_time!=1)
-            {
-                #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(ON);
-                #endif
-                clt_time --;
-                rt_thread_delay(1000);
-                #if 0//LAMP_EN == 0
-                    if(clt_time%30==0)
-                    ctr_Fan_PUT(OFF);
-                #endif
-                rt_kprintf("正在收集.....剩余时间:%d分-%d秒\n",device_status.clt_time,clt_time);
-                //如果触发异常
-                if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-                {
-                    ctr_lamp(OFF,1);
-                    #if LAMP_EN == 1
-                    ctr_lamp(OFF,2);
-                    ctr_lamp(OFF,3);
-                    #endif
-                    #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(OFF);
-                    #endif
-                    rt_kprintf("异常退出!!!\n");
-                    break;
-                }
-                if(device_status.timeSwitch==0&&device_status.sun_status==1)
-                {
-                    ctr_lamp(OFF,1);
-                    #if LAMP_EN == 1
-                    ctr_lamp(OFF,2);
-                    ctr_lamp(OFF,3);
-                    #endif
-                    #if 0//LAMP_EN == 0
-                    ctr_Fan_IN(OFF);
-                    #endif
-                    rt_kprintf("异常退出!!!\n");
-                    break;
-                }
-            }
-            clt_time = 1;
-            if(device_status.bat_status == 1 || device_status.temp_status == 1|| device_status.rain_status==1)
-            {
-                ctr_lamp(OFF,1);
-                #if LAMP_EN == 1
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                #endif
-                #if 0//LAMP_EN == 0
-                ctr_Fan_IN(OFF);
-                #endif
-                rt_kprintf("异常退出!!!\n");
-                break;
-            }
-            if(device_status.timeSwitch==0&&device_status.sun_status==1)
-            {
-                ctr_lamp(OFF,1);
-                #if LAMP_EN == 1
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                #endif
-                #if 0//LAMP_EN == 0
-                ctr_Fan_IN(OFF);
-                #endif
-                rt_kprintf("异常退出!!!\n");
-                break;
-            }
-            #if 0//LAMP_EN == 0
-            ctr_Fan_IN(OFF);
-            #endif
-            //4.关闭上仓门
-            device_status.ctr_up_motor = 2;
-            rt_kprintf("关闭上仓门!!!\n");
-            while(device_status.ctr_up_motor!=0)
-            {
-                rt_thread_delay(100);
-                LOG_I("等待上仓门关闭!!!");
-            }
-            //5.加热
-            if(device_status.heat_sw==0)
-            {
-                calorstat(device_status.heattime*60);
-            }
-            else {
-                heat_time = device_status.heattime * 60;
-                while(heat_time!=0)
-                {
-                    heat_time--;
-                    LOG_I("正在加热状态!!!");
-                    rt_thread_delay(1000);
-                }
-            }
-            //6.打开下仓门
-            if(device_status.rain_status==0)
-            {
-                device_status.ctr_down_motor =1;
-            }
-            else {
-                device_status.ctr_down_motor = 2;
-                device_status.ctr_up_motor = 2;
-            }
-            //待下仓门完全打开
-            while(device_status.ctr_down_motor!=0)
-            {
-                rt_thread_delay(100);
-                rt_kprintf("等待下仓门打开!!!\n");
-            }
-            rt_thread_delay(3000);
-            //关闭下仓门
-            device_status.ctr_down_motor = 2;
-            while(device_status.ctr_down_motor!=0)
-            {
-                rt_thread_delay(100);
-                rt_kprintf("等待下仓门关闭!!!\n");
-            }
-            //2022-04-12add:
-             LOG_I("打开上仓门!!!");
-             device_status.ctr_up_motor = 1;
-            if(device_status.version_type==4||device_status.version_type==41)
-            {
-                //震动
-                ctr_shake(ON, device_status.shake_sec);
-                //补光&&拍照
-                LOG_I("拍照!!!");
-                ctr_led(ON);
-                HK_TakePhoto();
-                //清扫
-                device_status.clear_status=1;
-                //清扫失效则使用震动
-                //ctr_shake(ON, 100);
-            }
-        }
-   }
-    if(device_status.bat_status == 1 || device_status.temp_status == 1 || device_status.rain_status==1 || device_status.ds==0)
-    {
-        LOG_I("-------------------not work--------------------");
-        device_status.work_status = 0;
-    }
-    //工作结束
-    if(device_status.work_done==0&&device_status.work_status==0)
-    {
-        DTU_Write("workdone");
-        if (device_status.version_type==1) {
-            turnzp();  //2024-03-21 :开机不再转仓
-        }
-        ResetInit();
-        clt_time = 0;
-    }
-    rt_kprintf("***not work-device status:%d\n",device_status.ds);
-}
-
-
 void guanshan_on(void *args)
 {
     LOG_W("guanshan_on!");
@@ -2153,11 +1603,6 @@ static void Work_Loop_thread_entry(void *parameter)
     ResetInit();
     while(1)
     {
-        if(device_status.version_type!=5&&device_status.dtype==3)
-        {
-            WorkTask();
-        }
-
         if(device_status.version_type==5)
         {
             WorkTask_CB5();
@@ -2199,13 +1644,6 @@ static void Control_Check_thread_entry(void *parameter)
     {
         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);
-            rt_thread_delay(10000);
-            calorstat(device_status.heattime*60);
-        }
-        else
         {
             if(device_status.selfcheck_ws==2)
             {

+ 60 - 103
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -1249,9 +1249,48 @@ int Parse_Cam_Param(cJSON *param_msg)
     return 0;
 }
 
+// 分割拼接的JSON对象,返回分割后的对象数量(需配合parse_json_objects使用)
+int split_json_objects(const char *input, char **output, int max_count) {
+    int count = 0;
+    int len = strlen(input);
+    int brace_level = 0;       // 大括号嵌套层级({ 加1,} 减1)
+    int start_pos = -1;        // 当前对象的起始位置
+
+    for (int i = 0; i < len; i++) {
+        if (input[i] == '{') {
+            if (brace_level == 0) {
+                start_pos = i;  // 记录新对象的起始位置
+            }
+            brace_level++;
+        } else if (input[i] == '}') {
+            if (brace_level > 0) {
+                brace_level--;
+                // 当层级回到0时,找到一个完整的JSON对象
+                if (brace_level == 0 && start_pos != -1) {
+                    if (count >= max_count) break;  // 防止数组越界
+                    int obj_len = i - start_pos + 1;  // 对象长度(包含{})
+                    output[count] = (char *)malloc(obj_len + 1);  // +1 for '\0'
+                    if (!output[count]) {
+                        perror("malloc failed");
+                        return -1;
+                    }
+                    strncpy(output[count], input + start_pos, obj_len);
+                    output[count][obj_len] = '\0';  // 字符串结尾
+                    count++;
+                    start_pos = -1;  // 重置起始位置
+                }
+            }
+        }
+        // 可选:忽略非{}的其他字符(如空格、换行等)
+    }
+    return count;
+}
+
 //JSON数据解析
 int parseDtu(char *json_string)
 {
+    const int MAX_OBJECTS = 10;  // 最大预期对象数(根据实际情况调整)
+    char *objects[MAX_OBJECTS];   // 存储分割后的子串
     extern int rt_hw_rtc_init(void);
     char* json_s = NULL;
     cJSON* item_cmd = NULL;    //嵌套ext
@@ -1293,16 +1332,26 @@ int parseDtu(char *json_string)
     cJSON* link_sta = NULL;
     cJSON* link_ip = NULL;
     cJSON* value_commn= NULL;
-
-    cJSON *root = cJSON_Parse(json_string);
-    if(!root)
-    {
-        cJSON_Delete(root);
-        LOG_E("parse json err:%s",json_string);
-        return -1;
-    }
-    else
+    cJSON *root = NULL;
+    // 步骤1:分割拼接的JSON对象
+    int obj_count = split_json_objects(json_string, objects, MAX_OBJECTS);
+    if (obj_count <= 0) {
+        LOG_E("No valid JSON objects found\n");
+        return -2;
+    }
+    for (int i = 0; i < obj_count; i++)
     {
+        root = cJSON_Parse(objects[i]);
+
+        //cJSON *root = cJSON_Parse(json_string);
+        if(!root)
+        {
+            cJSON_Delete(root);
+            LOG_E("parse json err:%s",json_string);
+            return -1;
+        }
+        else
+        {
           LOG_W("parseData:%s\n",json_string);
           #if UART_TEST_EN == 1
           DTU_Write(json_string);
@@ -1815,16 +1864,6 @@ int parseDtu(char *json_string)
               }
               else if (strstr(item_cmd->valuestring,"synchronization")!=RT_NULL)
               {
-//                  #if Color_EN == 0
-//                  if(device_status.dtype==7)
-//                  {
-//                      DTU_Write("%s","SwversionV7");
-//                  }
-//                  else if (device_status.dtype==3)
-//                  {
-//                      DTU_Write("%s","SwversionV4");
-//                  }
-//                  #endif
                   device_status.refresh_timeout=0;
                   //driver_4g =  cJSON_GetObjectItem(item_ext,"version");
                   driver_4g = cJSON_GetObjectItem(item_ext,"dver");
@@ -1919,29 +1958,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);
@@ -2235,66 +2251,6 @@ int parseDtu(char *json_string)
                                       LOG_E("收集时间collt设置失败参数错误!!!");
                                   }
                               }
-                              else if (collt->type==cJSON_Array) {
-                                 int icnt = 0;
-                                 for(icnt=0;icnt < cJSON_GetArraySize(collt);icnt++)
-                                 {
-                                     cJSON *pSub = cJSON_GetArrayItem(collt, icnt);
-                                     if(NULL==pSub) break;
-                                     char ivalue[10];
-                                     rt_sprintf(ivalue,"%s",pSub->valuestring);
-                                     if(icnt==0)
-                                     {
-                                         if(ivalue[1]=='-')
-                                         {
-                                             device_status.collecting_sh1 = atoi(&ivalue[0]);
-                                             if(strlen(ivalue)==3)
-                                                 device_status.collecting_eh1 = atoi(&ivalue[2]);
-                                             if(strlen(ivalue)==4)
-                                                 device_status.collecting_eh1 = atoi(&ivalue[3])<<8|atoi(&ivalue[2]);
-                                             ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1));
-                                             ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1));
-                                         }
-                                         if(ivalue[2]=='-')
-                                         {
-                                             device_status.collecting_sh1 = atoi(&ivalue[1])<<8|atoi(&ivalue[0]);
-                                             if(strlen(ivalue)==3)
-                                                 device_status.collecting_eh1 = atoi(&ivalue[3]);
-                                             if(strlen(ivalue)==5)
-                                                 device_status.collecting_eh1 = atoi(&ivalue[4])<<8|atoi(&ivalue[3]);
-                                             ef_set_env_blob("collecting_sh1", &device_status.collecting_sh1, sizeof(device_status.collecting_sh1));
-                                             ef_set_env_blob("collecting_eh1", &device_status.collecting_eh1, sizeof(device_status.collecting_eh1));
-                                         }
-                                         LOG_I("开始结束时间1:%d-%d",device_status.collecting_sh1,device_status.collecting_eh1);
-                                     }
-                                     else if (icnt==1)
-                                     {
-                                         if((ivalue[1]=='-'))
-                                         {
-                                             device_status.collecting_sh2 = atoi(&ivalue[0]);
-                                             if(strlen(ivalue)==3)
-                                                 device_status.collecting_eh2 = atoi(&ivalue[2]);
-                                             if(strlen(ivalue)==4)
-                                                 device_status.collecting_eh2 = atoi(&ivalue[3])<<8|atoi(&ivalue[2]);
-                                             ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2));
-                                             ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2));
-                                         }
-                                         if((ivalue[2]=='-'))
-                                         {
-                                             device_status.collecting_sh2 = atoi(&ivalue[1])<<8|atoi(&ivalue[0]);
-                                             if(strlen(ivalue)==3)
-                                                 device_status.collecting_eh2 = atoi(&ivalue[2]);
-                                             if(strlen(ivalue)==5)
-                                                 device_status.collecting_eh2 = atoi(&ivalue[4])<<8|atoi(&ivalue[3]);
-                                             ef_set_env_blob("collecting_sh2", &device_status.collecting_sh2, sizeof(device_status.collecting_sh2));
-                                             ef_set_env_blob("collecting_eh2", &device_status.collecting_eh2, sizeof(device_status.collecting_eh2));
-                                         }
-                                         LOG_I("开始结束时间2:%d-%d",device_status.collecting_sh2,device_status.collecting_eh2);
-                                     }
-                                     LOG_I("下发设置收集:%d-%s",icnt,ivalue);
-                                 }
-                              }
-
                           }
                           if(datt!=NULL)
                           {
@@ -2618,7 +2574,8 @@ int parseDtu(char *json_string)
                           rt_thread_delay(1000);
                }
           }
-        cJSON_Delete(root);
+          cJSON_Delete(root);
+        }
     }
     return 0;
 }

+ 3 - 33
Application_cbd_apm32f1/applications/hmi.c

@@ -1772,40 +1772,10 @@ void Check_ParamConfig(void)
         if(device_status.heattime==0) device_status.heattime = 10;
         if(device_status.tph==0) device_status.tph = 70;
         if(device_status.heatvalue==0) device_status.heatvalue = 100;
+        device_status.dtype = 3;
+        device_status.version_type = 5;
+        rt_sprintf(device_status.driver, "%s",VERSION_V5);
 
-        /*设备类型,7孢子仪,3测报灯,默认设置测报灯*/
-        if(device_status.dtype!=7)
-        {
-            device_status.dtype = 3;
-        }
-        else {
-            device_status.version_type = 7;
-        }
-        if(device_status.version_type==0)
-        {
-            app_partion_backup();   //固件备份至df_area
-            device_status.version_type = 41;
-            rt_sprintf(device_status.driver, "%s",VERSION_HK);
-            ef_set_env_blob("version_type",&device_status.version_type,sizeof(device_status.version_type));
-        }
-        else if(device_status.version_type==1)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_ZP);
-        }
-        else if (device_status.version_type==11)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_GK);
-        }
-        else if (device_status.version_type==4)
-        {
-            rt_sprintf(device_status.driver, "%s",VERSION_HK_2000W);
-        }
-        else if (device_status.version_type==41) {
-            rt_sprintf(device_status.driver, "%s",VERSION_HK);
-        }
-        else if (device_status.version_type==5) {
-            rt_sprintf(device_status.driver, "%s",VERSION_V5);
-        }
         /*定制三色光源*/
         #if LAMP_EN == 1
             if(device_status.sunBar%3!=0)

+ 2 - 3
Application_cbd_apm32f1/applications/sht30_collect.c

@@ -19,7 +19,7 @@
 
 #define DBG_ENABLE
 #define DBG_COLOR
-#define DBG_TAG "control"
+#define DBG_TAG "adc"
 #define DBG_LEVEL  DBG_LOG
 #include <rtdbg.h> //must after of DBG_LVL, DBG_TAG or other options
 
@@ -314,13 +314,12 @@ static void Power_ReadCheck(void *parameter)
             else {
                 rain_cnt++;
                 //雨控消抖,1分钟
-                if(rain_cnt%10==0)
-                    LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
                 if(rain_cnt==600&&Read_Rain_Voltage()<250)
                 {
                     rain_cnt = 0;
                     device_status.rain_status = 0;
                     device_status.C01 &= ~(1<<5);
+                    LOG_D("雨控触发ADC值:%d",Read_Rain_Voltage());
                 }
             }
         }

+ 2 - 2
Application_cbd_apm32f1/packages/ota_downloader-v1.0.0/src/ymodem_ota.c

@@ -44,7 +44,7 @@ static enum rym_code ymodem_on_begin(struct rym_ctx *ctx, rt_uint8_t *buf, rt_si
     file_name = (char *)&buf[0];
     file_size = (char *)&buf[rt_strlen(file_name) + 1];
     update_file_total_size = atol(file_size);
-    rt_kprintf("Ymodem file_size:%d\n", update_file_total_size);
+    //rt_kprintf("Ymodem file_size:%d\n", update_file_total_size);
 
     update_file_cur_size = 0;
 
@@ -61,7 +61,7 @@ static enum rym_code ymodem_on_begin(struct rym_ctx *ctx, rt_uint8_t *buf, rt_si
         return RYM_CODE_CAN;
     }
 
-    LOG_I("Start erase. Size (%d)", update_file_total_size);
+    //LOG_I("Start erase. Size (%d)", update_file_total_size);
 
     /* erase DL section */
     if (fal_partition_erase(dl_part, 0, update_file_total_size) < 0)

+ 9 - 1
Application_cbd_apm32f1/rt-thread/components/utilities/ymodem/ymodem.c

@@ -193,7 +193,7 @@ static rt_err_t _rym_do_handshake(
     rt_uint16_t recv_crc, cal_crc;
     rt_size_t data_sz;
     rt_tick_t tick;
-
+    rt_uint16_t update_timeout = 0;
     ctx->stage = RYM_STAGE_ESTABLISHING;
     /* send C every second, so the sender could know we are waiting for it. */
     for (i = 0; i < tm_sec; i++)
@@ -203,14 +203,22 @@ static rt_err_t _rym_do_handshake(
                               RYM_CHD_INTV_TICK);
         if (code == RYM_CODE_SOH)
         {
+            update_timeout = 0;
             data_sz = _RYM_SOH_PKG_SZ;
             break;
         }
         else if (code == RYM_CODE_STX)
         {
+            update_timeout = 0;
             data_sz = _RYM_STX_PKG_SZ;
             break;
         }
+        //超时重启
+        update_timeout++;
+        if(update_timeout==30)
+        {
+            rt_hw_cpu_reset();
+        }
     }
     if (i == tm_sec)
     {