V1.4:修复串口RESET/OTA命令复位丢失;补回ota_simulate_fail回退测试开关(默认关);WiFi OTA与回退实测通过
This commit is contained in:
parent
680362202c
commit
308119a45c
|
|
@ -57,7 +57,7 @@ void app_init(void)
|
|||
{
|
||||
log_info("");
|
||||
log_info("* * * * * * * * * * * * * * * * * *");
|
||||
log_info("* Version: 1.4.0 (RTOS) *");
|
||||
log_info("* Version: 1.4.3 (RTOS) *");
|
||||
log_info("* * * * * * * By Helei * * * *");
|
||||
|
||||
/* EEPROM 中的 MQTT/版本配置 */
|
||||
|
|
@ -110,6 +110,8 @@ static void app_task(void *arg)
|
|||
|
||||
/* 主循环状态变量 */
|
||||
static uint8_t ota_confirmed = 0;
|
||||
static uint8_t ota_simulate_fail = 0; /* =1测试:模拟 OTA 确认失败(验证回退) */
|
||||
static uint8_t ota_fail_logged = 0;
|
||||
static uint32_t ota_confirm_tick = 0;
|
||||
static uint32_t mqtt_ready_tick = 0;
|
||||
static uint8_t mqtt_ready_recorded = 0;
|
||||
|
|
@ -135,10 +137,18 @@ static void app_task(void *arg)
|
|||
/* 首次发布成功后延迟 3s 再 OTA 确认 */
|
||||
if (!ota_confirmed && g_net_mqtt_ready && g_net_first_publish_ok &&
|
||||
(HAL_GetTick() - ota_confirm_tick) > 3000) {
|
||||
if (ota_simulate_fail) {
|
||||
if (!ota_fail_logged) {
|
||||
ota_fail_logged = 1;
|
||||
log_info("> OTA confirm skipped (simulate fail for rollback test)");
|
||||
}
|
||||
/* 不置位 ota_confirmed,让 1 分钟健康超时触发复位 */
|
||||
} else {
|
||||
ota_confirmed = 1;
|
||||
NET_ota_confirm();
|
||||
log_info("> OTA confirmed (MQTT ready + first publish ok + 3s delay)");
|
||||
}
|
||||
}
|
||||
|
||||
/* MQTT 就绪后 1 分钟仍未首次 MPUB,主动复位 */
|
||||
if (!ota_confirmed && mqtt_ready_recorded &&
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ void process_usart1_command(void)
|
|||
|
||||
if (cmd_is(cmd, "RESET")) {
|
||||
log_warn("> USART1 RESET command received, rebooting...");
|
||||
HAL_Delay(100);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
else if (cmd_is(cmd, "INFO")) {
|
||||
log_info("> BT INFO: ver=%u, server=%s:%d, client=%s",
|
||||
|
|
@ -86,6 +88,8 @@ void process_usart1_command(void)
|
|||
}
|
||||
else if (cmd_is(cmd, "OTA")) {
|
||||
log_info("> BT OTA: reboot to bootloader for OTA check");
|
||||
HAL_Delay(100);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
else if (cmd_is(cmd, "RECOVERY")) {
|
||||
/* WiFi 模块 AT+RESTORE 恢复出厂(忘掉已保存的热点),用于测试 SmartConfig;
|
||||
|
|
|
|||
Loading…
Reference in New Issue