固件 0.1.5~0.1.13-c5:刷机模式、多组 WiFi、热插拔初始化、总线锁误判、硬重启断 VBUS
- 0.1.5/0.1.6:刷机模式(flash_mode,最多 2 路,60 分钟可加钟)——窗口内顶高按 4450 mV 绝对值判、不断 VBUS - 0.1.7/0.1.8:反灌断 VBUS 阈值放宽到 -300 mA(adb reboot bootloader 过渡实测 -208 mA) - 0.1.9:WiFi 最多存 4 组,连不上轮换;NVS v1 自动迁移并双写(OTA 回滚仍能上网) - 0.1.10:热插拔进来的刀片重新初始化 PCA9555 + INA226(否则 VBUS 常开、电流恒读 0) - 0.1.11:i2cbus 嵌套检测改看本任务持锁(原全局标志让 key 随机回 busy、vbus 随机回 io) - 0.1.12:硬重启先断 VBUS,开机校验通过 60 s 后再接回(否则假重启 / 误判没开机 / 进关机充电) - 0.1.13:这一路被安全判据断电时一并退出刷机模式(事件 21 arg 254) 26 ctest 全绿;新增用例均先在旧代码上确认变红。板 B 已 OTA 到 0.1.13-c5 并实测。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
这个提交包含在:
+41
-7
@@ -33,14 +33,38 @@ cmd_err_t do_wifi(ctx_t *c)
|
||||
}
|
||||
const char *ssid = NULL;
|
||||
const char *pass = NULL;
|
||||
if (get_str(c, "ssid", true, &ssid) != CMD_OK || get_str(c, "pass", false, &pass) != CMD_OK) {
|
||||
bool del = false;
|
||||
if (get_str(c, "ssid", true, &ssid) != CMD_OK || get_str(c, "pass", false, &pass) != CMD_OK ||
|
||||
cj_get_bool(c->o, "del", &del) < 0) {
|
||||
return CMD_ERR_ARG;
|
||||
}
|
||||
if (!netcfg_wifi_ok(ssid, pass)) {
|
||||
c->bad = (int64_t)strlen(pass); /* 最常见的错是口令长度(<8),记长度不记内容 */
|
||||
return CMD_ERR_RANGE;
|
||||
netcfg_t cfg;
|
||||
netcfg_get(&cfg);
|
||||
hal_err_t e;
|
||||
if (del) {
|
||||
/* 删:`{"cmd":"wifi","ssid":"X","del":true}`。没有这一组 = range(记现有组数)。 */
|
||||
if (netcfg_wifi_find(&cfg, ssid) < 0) {
|
||||
c->bad = netcfg_wifi_count(&cfg);
|
||||
return CMD_ERR_RANGE;
|
||||
}
|
||||
e = netcfg_del_wifi(ssid);
|
||||
} else {
|
||||
if (!netcfg_wifi_ok(ssid, pass)) {
|
||||
c->bad = (int64_t)strlen(pass); /* 最常见的错是口令长度(<8),记长度不记内容 */
|
||||
return CMD_ERR_RANGE;
|
||||
}
|
||||
if (netcfg_wifi_find(&cfg, ssid) < 0 && netcfg_wifi_count(&cfg) >= NETCFG_WIFI_N) {
|
||||
c->bad = NETCFG_WIFI_N; /* 满了:先删一组 */
|
||||
return CMD_ERR_STATE;
|
||||
}
|
||||
e = netcfg_set_wifi(ssid, pass);
|
||||
}
|
||||
return netcfg_set_wifi(ssid, pass) == HAL_OK ? CMD_OK : CMD_ERR_IO;
|
||||
if (e != HAL_OK) {
|
||||
return CMD_ERR_IO;
|
||||
}
|
||||
netcfg_get(&cfg);
|
||||
cj_w(c->w, ",\"n\":%d", netcfg_wifi_count(&cfg));
|
||||
return CMD_OK;
|
||||
}
|
||||
|
||||
cmd_err_t do_mqtt(ctx_t *c)
|
||||
@@ -91,9 +115,19 @@ cmd_err_t do_net(ctx_t *c)
|
||||
|
||||
cj_w(w, ",\"id\":");
|
||||
w_str(w, st.id);
|
||||
/* `ssid` / `pass_set` = 正在连 / 已连上的那一组;`ssids` = 整张表(按轮换顺序)。 */
|
||||
const int n = netcfg_wifi_count(&cfg);
|
||||
const netcfg_wifi_t *cur = (st.wifi_idx < n) ? &cfg.wifi[st.wifi_idx] : &cfg.wifi[0];
|
||||
cj_w(w, ",\"wifi\":\"%s\",\"ssid\":", net_state_str(st.wifi));
|
||||
w_str(w, cfg.ssid);
|
||||
cj_w(w, ",\"pass_set\":%s,\"ip\":", cfg.pass[0] ? "true" : "false");
|
||||
w_str(w, cur->ssid);
|
||||
cj_w(w, ",\"pass_set\":%s,\"ssids\":[", cur->pass[0] ? "true" : "false");
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) {
|
||||
cj_w(w, ",");
|
||||
}
|
||||
w_str(w, cfg.wifi[i].ssid);
|
||||
}
|
||||
cj_w(w, "],\"ip\":");
|
||||
w_str(w, st.ip);
|
||||
cj_w(w, ",\"rssi\":%d,\"wifi_reason\":%u,\"mqtt\":\"%s\",\"uri\":", (int)st.rssi,
|
||||
(unsigned)st.wifi_reason, net_state_str(st.mqtt));
|
||||
|
||||
在新工单中引用
屏蔽一个用户