From 5005c126d8dd7f1f4b689366cf621263a5a5b9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=A9=AC=5F666?= <13089258+pony-six-hundred-and-sixty-six@user.noreply.gitee.com> Date: Wed, 21 May 2025 16:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=9C=AA=E6=A0=87=E5=AE=9A=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E7=BA=A2=E7=81=AF=E5=B8=B8=E4=BA=AE=EF=BC=8C=E5=B0=86?= =?UTF-8?q?AT=E6=8C=87=E4=BB=A4free=20=E5=8F=82=E6=95=B0=E6=94=B9=E4=B8=BA?= =?UTF-8?q?0,2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mrs/launch.json | 6 +++--- applications/main.c | 6 +++--- ble_bjq_ch303rct6_ml307.wvproj | 4 +--- bsp/src/at_device_ml307.c | 14 +++++++------- bsp/src/bsp_flash.c | 2 +- bsp/src/bsp_ml307.c | 16 +++++++++++++++- bsp/src/bsp_mq.c | 2 +- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/.mrs/launch.json b/.mrs/launch.json index e17263f..57356d5 100644 --- a/.mrs/launch.json +++ b/.mrs/launch.json @@ -5,7 +5,7 @@ "type": "mrs-debugger", "request": "launch", "name": "ble_bjq_ch303rct6_ml307", - "cwd": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307", + "cwd": "c:\\Users\\1\\Desktop\\yhq\\ble_-tyq_-bjq_-ch32-v303", "openOCDCfg": { "useLocalOpenOCD": true, "executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe", @@ -39,8 +39,8 @@ "additionalCommands": [] }, "loadedFiles": { - "executableFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf", - "symbolFile": "d:\\SXDT\\Project\\CH32\\ble_bjq_ch303rct6_ml307\\obj\\ble_bjq_ch303rct6_ml307.elf", + "executableFile": "c:\\Users\\1\\Desktop\\yhq\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf", + "symbolFile": "c:\\Users\\1\\Desktop\\yhq\\ble_-tyq_-bjq_-ch32-v303\\obj\\ble_bjq_ch303rct6_ml307.elf", "executableFileOffset": 0, "symbolFileOffset": 0 }, diff --git a/applications/main.c b/applications/main.c index 510d5a5..6a299d9 100644 --- a/applications/main.c +++ b/applications/main.c @@ -156,10 +156,10 @@ int APP_Calibration_Handle(void) // 定义超时时间,单位为毫秒 #define TIMEOUT_MS (3 * 60 * 1000) - LED_STOP(r); + LED_STOP(g); LED_STOP(y); - LED_CTRL(g, "1000,500", -1); - LED_START(g); + LED_ON(r); + LED_START(r); uint32_t ticks = 0, gas_calibration_voltage; LOG_D("标定开始"); diff --git a/ble_bjq_ch303rct6_ml307.wvproj b/ble_bjq_ch303rct6_ml307.wvproj index 11d5b06..766de64 100644 --- a/ble_bjq_ch303rct6_ml307.wvproj +++ b/ble_bjq_ch303rct6_ml307.wvproj @@ -855,10 +855,8 @@ "ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2, "GdbServerAllocateConsole": true, "GdbServerAllocateTelnetConsole": false, - "SkipDownloadBeforeDebug": false, "StartGdbCLient": true, - "UPDATE_THREADLIST_ON_SUSPEND": false, - "DebugInRam": false + "UPDATE_THREADLIST_ON_SUSPEND": false } } } \ No newline at end of file diff --git a/bsp/src/at_device_ml307.c b/bsp/src/at_device_ml307.c index a39297c..7ea9a43 100644 --- a/bsp/src/at_device_ml307.c +++ b/bsp/src/at_device_ml307.c @@ -89,7 +89,7 @@ static rt_err_t ml307_power_on(struct at_device *device) rt_pin_write(ml307->pwr_en_pin, PIN_HIGH); rt_thread_mdelay(RT_TICK_PER_SECOND); - + rt_pin_write(ml307->power_pin, PIN_HIGH); rt_thread_mdelay(ML307_POWER_ON_TIME * RT_TICK_PER_SECOND); rt_pin_write(ml307->power_pin, PIN_LOW); @@ -302,7 +302,7 @@ static int at_device_ml307_connect_tcp(struct at_device *device) flash_sever_info sever_info = {0}; rt_err_t ret = RT_ERROR; ASSERT(device); - at_response_t resp = at_create_resp(64, 2, 5000); + at_response_t resp = at_create_resp(256, 2, 10000); if (resp == RT_NULL) { LOG_E("No memory for response structure!"); @@ -878,7 +878,7 @@ static void ml307_init_thread_entry(void *parameter) struct at_device *device = (struct at_device *)parameter; struct at_client *client = device->client; - resp = at_create_resp(128, 0, rt_tick_from_millisecond(ML307_AT_DEFAULT_TIMEOUT * 2)); + resp = at_create_resp(256, 0, rt_tick_from_millisecond(ML307_AT_DEFAULT_TIMEOUT * 2)); if (resp == RT_NULL) { LOG_E("no memory for resp create."); @@ -1159,10 +1159,10 @@ static void ml307_init_thread_entry(void *parameter) /* check and create link staus sync thread */ ml307_netdev_check_link_status(device->netdev); LOG_I("%s device network initialize success.", device->name); - while (Flash_Get_Calibration_State() == kNotCalibrated) - { - rt_thread_mdelay(1000); // we need wait for calibration finish - } + // while (Flash_Get_Calibration_State() == kNotCalibrated) + // { + // rt_thread_mdelay(1000); // we need wait for calibration finish + // } rt_completion_done(&ml307_init_complate); // 通知初始化完成 } else diff --git a/bsp/src/bsp_flash.c b/bsp/src/bsp_flash.c index 1241e9f..a8e6f2c 100644 --- a/bsp/src/bsp_flash.c +++ b/bsp/src/bsp_flash.c @@ -895,7 +895,7 @@ int BSP_Flash_Init (void) Flash_SetProductTimeLimit (2025, 2, 10, 13, 50, 20, kFactoryTimeId); Set_ExpirationTime (MAX_EXPIRATION_DAYS); - Flash_Set_Calibration_State(kNotCalibrated); // 标定状态 + Flash_Set_Calibration_State(kSysGasCalibStatus); // 标定状态 Flash_Set_Valve_Num(0); sci.hw_ver = SYS_HW_VERSION; sci.sw_ver = SYS_SW_VERSION; diff --git a/bsp/src/bsp_ml307.c b/bsp/src/bsp_ml307.c index 1fc25ce..fe19a85 100644 --- a/bsp/src/bsp_ml307.c +++ b/bsp/src/bsp_ml307.c @@ -737,7 +737,7 @@ int Ml307_Send_Power_Off(struct at_device *device, void *param) LOG_E("ml307 param error\n"); return RT_ERROR; } - rt_memset(&valve[0].valve_connct_status, 0, (sizeof(struct valve_t) - 7));//当掉电事件时,直接清空阀门结构体,这样连接状态就为断开 + rt_memset(&valve[0].valve_connct_status, 0, (sizeof(struct valve_t) - 7)); // 当掉电事件时,直接清空阀门结构体,这样连接状态就为断开 if (ml307_ops->send(ml307_ops, DATA_SERIAL_NUM, CMD_TYPE_DEVICE_EVENT_REPORT, DEVICE_TYPE_ML307, EVENT_TYPE_POWER_OFF)) { LOG_E("ml307 send cmd[%X] failed\n", EVENT_TYPE_POWER_OFF); @@ -1972,6 +1972,20 @@ static void Ml307_Life_Thread_Entry(void *parameter) result = -RT_ERROR; goto __exit; } + int link_stat = 0; + if (at_resp_parse_line_args_by_kw(resp, "+MIPCALL:", "+MIPCALL: %d,%*d,%*s", &link_stat) > 0) + { + if (link_stat == 1) + { + result = RT_EOK; + } + } + else + { + LOG_E("AT+MIPCALL error."); + result = -RT_ERROR; + goto __exit; + } if (device->class->device_ops->control(device, AT_DEVICE_CTRL_NET_CONN, RT_NULL) == RT_EOK) { LOG_D("重连网络成功\n"); diff --git a/bsp/src/bsp_mq.c b/bsp/src/bsp_mq.c index f088451..536484c 100644 --- a/bsp/src/bsp_mq.c +++ b/bsp/src/bsp_mq.c @@ -47,7 +47,7 @@ uint16_t Get_Gas_VoltageInt1000x(void) uint16_t Get_Gas_VoltageAdcInt1000x(void) { rt_uint16_t voltage_adc = (Get_ADC_Average(kGasAdc) * 3.3 / 4096) * 1000; - LOG_D("Get_Gas_VoltageAdcInt1000x = %04d", voltage_adc); + // LOG_D("Get_Gas_VoltageAdcInt1000x = %04d", voltage_adc); return voltage_adc; }