提交一次暂存

This commit is contained in:
小马_666 2025-05-21 13:13:34 +08:00
parent 4aff0a236e
commit ef5987d0ff
8 changed files with 95 additions and 67 deletions

View File

@ -18,9 +18,9 @@
}
],
"files.associations": {
"*.dbclient-js": "javascript",
"*.sqlbook": "sql",
"*.ndjson": "jsonl",
"*.dbclient-js": "javascript",
"rtthread.h": "c",
"user_sys.h": "c",
"bsp_led.h": "c",
@ -76,6 +76,7 @@
"signal.h": "c",
"xtr1common": "c",
"stddef.h": "c",
"netdev_ipaddr.h": "c"
"netdev_ipaddr.h": "c",
"stdint.h": "c"
}
}

View File

@ -365,7 +365,6 @@ void APP_Handle(void)
Flash_Write_Record(kRecordFault);
LED_Y_FAULT;
// BEEP_FAULT;
#if (IOT_MODULE_SWITCH == 1)
Ml307_Send_Event(kMl307FaultEvent);

View File

@ -18,8 +18,8 @@
#define MAX_EXPIRATION_DAYS (uint16_t)(365 * 5 + 30 * 3)
#define SYS_HW_VERSION (0X11U)
#define SYS_SW_VERSION (0X11U)
#define SYS_HW_VERSION (0X13U)
#define SYS_SW_VERSION (0X12U)
#define SYS_IOT_UPLOAD_CYCLE_MIN (0X003CU) // 高位在后,低位在前
#define SYS_IOT_RETRY (0X03U)
#define SYS_TEMP_ALARM_THRESHOLD (0X32U)

View File

@ -2,7 +2,7 @@
* @Author: mbw
* @Date: 2024-11-30 15:46:21
* @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-04-16 10:10:33
* @LastEditTime: 2025-05-21 11:18:55
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\at_device_ml307.c
* @Description:
*
@ -927,7 +927,7 @@ static void ml307_init_thread_entry(void *parameter)
goto __exit;
}
/*设置包模式*/
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"autofree\",0,0") != RT_EOK)
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"autofree\",0,1") != RT_EOK)
{
result = -RT_ERROR;
goto __exit;

View File

@ -13,7 +13,7 @@
#include <ulog.h>
#ifdef BUTTON_USE_THREAD
ALIGN(RT_ALIGN_SIZE)
ALIGN (RT_ALIGN_SIZE)
static char button_thread_stack[BUTTON_THREAD_STACK_SIZE];
static struct rt_thread button_thread;
#else
@ -29,7 +29,7 @@ typedef enum
static flex_button_t user_button[USER_BUTTON_MAX];
static uint8_t _CommonBtnRead(void *arg)
static uint8_t _CommonBtnRead (void *arg)
{
uint8_t value = 0;
flex_button_t *btn = (flex_button_t *)arg;
@ -37,37 +37,63 @@ static uint8_t _CommonBtnRead(void *arg)
switch (btn->id)
{
case USER_BUTTON_0:
value = rt_pin_read(BUTTON_0);
value = rt_pin_read (BUTTON_0);
break;
case USER_BUTTON_1:
value = rt_pin_read(BUTTON_1);
value = rt_pin_read (BUTTON_1);
break;
default:
RT_ASSERT(0);
RT_ASSERT (0);
}
return value;
}
static void _CommonBtnEvtCb(void *arg)
static void _CommonBtnEvtCb (void *arg)
{
// static rt_uint8_t button_cnt = 0;
if (flex_button_event_read(&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_DOUBLE_CLICK)
if (flex_button_event_read (&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_DOUBLE_CLICK)
{
if ( SysControl.status > kPreheatingEvent)
if (SysControl.status > kPreheatingEvent)
{
Send_Laser_Alarm_Event(kSelfCheckEvent);
Send_Laser_Alarm_Event (kSelfCheckEvent);
}
}
else if (flex_button_event_read(&user_button[USER_BUTTON_0]) == FLEX_BTN_PRESS_CLICK)
else if (flex_button_event_read (&user_button[USER_BUTTON_0]) == FLEX_BTN_PRESS_CLICK)
{
if (SysControl.status == kAlarmEvent)
{
Send_Laser_Alarm_Event(KMuteEvent);
}
// if (button_cnt == 1)
// {
// LED_OFF (y);
// LED_OFF (r);
// LED_ON (g);
// LOG_D ("GREEN ON");
// }
// else if (button_cnt == 2)
// {
// LED_OFF (g);
// LED_OFF (r);
// LED_ON (y);
// LOG_D ("Yellow ON");
// }
// else if (button_cnt == 3)
// {
// LED_OFF (g);
// LED_OFF (y);
// LED_ON (r);
// LOG_D ("RED ON");
// }
// else if (button_cnt >= 4)
// {
// button_cnt = 0;
// }
// button_cnt++;
}
// else if ((flex_button_event_read(&user_button[USER_BUTTON_0]) == FLEX_BTN_PRESS_REPEAT_CLICK) && (flex_button_event_read(&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_LONG_HOLD))
else if (flex_button_event_read(&user_button[USER_BUTTON_1]) == FLEX_BTN_PRESS_LONG_HOLD)
{
LOG_I("本地清除阀门信息");
@ -99,14 +125,14 @@ static void _CommonBtnEvtCb(void *arg)
}
}
static void _BUTTON_Process(void *param)
static void _BUTTON_Process (void *param)
{
#ifdef BUTTON_USE_THREAD
LOG_D("BSP_BUTTON_thread");
LOG_D ("BSP_BUTTON_thread");
while (1)
{
flex_button_scan();
rt_thread_mdelay(20);
rt_thread_mdelay (20);
}
#else
flex_button_scan();
@ -114,13 +140,13 @@ static void _BUTTON_Process(void *param)
#endif // !BUTTON_USE_THREAD
}
int BSP_BUTTON_Init(void)
int BSP_BUTTON_Init (void)
{
rt_uint8_t ret = 0;
rt_memset(&user_button[0], 0x0, sizeof(user_button));
rt_memset (&user_button[0], 0x0, sizeof (user_button));
rt_pin_mode(BUTTON_0, PIN_MODE_INPUT_PULLUP); /* set KEY pin mode to input */
rt_pin_mode(BUTTON_1, PIN_MODE_INPUT_PULLUP); /* set KEY pin mode to input */
rt_pin_mode (BUTTON_0, PIN_MODE_INPUT_PULLUP); /* set KEY pin mode to input */
rt_pin_mode (BUTTON_1, PIN_MODE_INPUT_PULLUP); /* set KEY pin mode to input */
for (uint8_t i = 0; i < USER_BUTTON_MAX; i++)
{
@ -128,47 +154,47 @@ int BSP_BUTTON_Init(void)
user_button[i].usr_button_read = _CommonBtnRead;
user_button[i].cb = _CommonBtnEvtCb;
user_button[i].pressed_logic_level = PIN_LOW;
user_button[i].short_press_start_tick = FLEX_MS_TO_SCAN_CNT(1000);
user_button[i].long_press_start_tick = FLEX_MS_TO_SCAN_CNT(3000);
user_button[i].long_hold_start_tick = FLEX_MS_TO_SCAN_CNT(5000);
user_button[i].short_press_start_tick = FLEX_MS_TO_SCAN_CNT (1000);
user_button[i].long_press_start_tick = FLEX_MS_TO_SCAN_CNT (3000);
user_button[i].long_hold_start_tick = FLEX_MS_TO_SCAN_CNT (5000);
flex_button_register(&user_button[i]);
flex_button_register (&user_button[i]);
}
#ifdef BUTTON_USE_THREAD
ret = rt_thread_init(&button_thread,
ret = rt_thread_init (&button_thread,
"button_thread",
_BUTTON_Process,
RT_NULL,
&button_thread_stack[0],
sizeof(button_thread_stack),
sizeof (button_thread_stack),
BUTTON_THREAD_PRIORITY,
BUTTON_THREAD_TICKS);
if (ret == RT_EOK)
{
rt_thread_startup(&button_thread);
rt_thread_startup (&button_thread);
return RT_EOK;
}
else
{
LOG_E("button_thread create failed");
LOG_E ("button_thread create failed");
return -RT_ERROR;
}
#else
button_timer = rt_timer_create("button_timer", _BUTTON_Process,
button_timer = rt_timer_create ("button_timer", _BUTTON_Process,
RT_NULL, 20,
RT_TIMER_FLAG_PERIODIC);
if (button_timer != RT_NULL)
{
rt_timer_start(button_timer);
rt_timer_start (button_timer);
}
else
{
LOG_E("create button_timer fail");
LOG_E ("create button_timer fail");
return -RT_ERROR;
}
#endif // !BUTTON_USE_THREAD
LOG_I("BSP_BUTTON_Init!");
LOG_I ("BSP_BUTTON_Init!");
return -RT_ERROR;
}

View File

@ -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(kSysGasCalibStatus); // 标定状态
Flash_Set_Calibration_State(kNotCalibrated); // 标定状态
Flash_Set_Valve_Num(0);
sci.hw_ver = SYS_HW_VERSION;
sci.sw_ver = SYS_SW_VERSION;

View File

@ -2,7 +2,7 @@
* @Author: mbw
* @Date: 2024-11-30 15:46:21
* @LastEditors: mbw && 1600520629@qq.com
* @LastEditTime: 2025-04-25 08:41:52
* @LastEditTime: 2025-05-21 11:37:02
* @FilePath: \ble_bjq_ch303rct6_ml307\bsp\src\bsp_ml307.c
* @Description:
*
@ -314,7 +314,7 @@ int _Update_Valve_Data(struct Ml307_Ops *ops)
{
LOG_D("valve_num: %d", ops->body->valve_num);
rt_memcpy(&ops->body->valve_data[0], &valve[0], sizeof(struct valve_t));
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)); // 清空阀门包数据,等待下次更新,如果没更新说明断开了
}
return RT_EOK;
}
@ -359,7 +359,7 @@ int Ml307_Send_Data(struct Ml307_Ops *ops, rt_uint8_t data_num, rt_uint8_t cmd,
rt_memset(ops->body, 0, sizeof(struct DataBody));
rt_mutex_take(ml307_mutex, RT_WAITING_FOREVER);
ret = ml307_ops.update_data(ops, device_type, event_type);
ret = ops->update_data(ops, device_type, event_type);
if (ret == RT_EOK)
{
if (ops->body->valve_num == 0)
@ -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));//当掉电事件时,直接清空阀门结构体,这样连接状态就为断开
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);
@ -1091,12 +1091,14 @@ rt_err_t Handle_Close_Valve(struct Ml307_Ops *ops)
if (rt_sem_take(&bt_ctr_sem, 10000) != RT_EOK) // 等待十秒获取信号量
{
LOG_E("获取信号量失败\n");
rt_sem_control(&bt_ctr_sem, RT_IPC_CMD_RESET, 0);
ops->Resp(ops, DATA_SERIAL_NUM, CMD_TYPE_INSTRUCTION_REPLY, DEVICE_TYPE_ML307, INSTRUCTION_DOWN_CLOSE_VALVE, temp, RESPONSE_CODE_ACTION_FAILURE);
return RT_ERROR;
}
else
{
LOG_D("关阀成功\n");
rt_sem_control(&bt_ctr_sem, RT_IPC_CMD_RESET, 0);
ops->Resp(ops, DATA_SERIAL_NUM, CMD_TYPE_INSTRUCTION_REPLY, DEVICE_TYPE_ML307, INSTRUCTION_DOWN_CLOSE_VALVE, temp, RESPONSE_CODE_SUCCESS);
return RT_EOK;
}
@ -1839,7 +1841,7 @@ static void Ml307_Life_Thread_Entry(void *parameter)
{
LOG_D("重连网络中...\n");
ml307_connect_sever_flag = 0;
resp = at_create_resp(128, 0, 5000);
resp = at_create_resp(256, 0, 5000);
if (resp == RT_NULL)
{
LOG_E("No memory for response structure!");
@ -1884,7 +1886,7 @@ static void Ml307_Life_Thread_Entry(void *parameter)
goto __exit;
}
/*设置包模式*/
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"autofree\",0,0") != RT_EOK)
if (at_obj_exec_cmd(device->client, resp, "AT+MIPCFG=\"autofree\",0,1") != RT_EOK)
{
result = -RT_ERROR;
goto __exit;

View File

@ -510,7 +510,7 @@ int rt_hw_usart_init(void)
uart_obj[i].serial.ops = &ch32_uart_ops;
uart_obj[i].serial.config = config;
if (uart_obj[i].config->name == "uart1")
if (uart_obj[i].config->Instance == USART1)
{
uart_obj[i].serial.config.baud_rate = BAUD_RATE_460800;
}