固件 0.1.14~0.1.16-c5:Hub 按需启停(hubctl)、开机长按统一 5 s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
@@ -12,6 +12,7 @@
|
||||
#include "evlog.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_time.h"
|
||||
#include "hubctl.h"
|
||||
#include "ota.h"
|
||||
#include "pca9555.h"
|
||||
#include "phonerail.h"
|
||||
@@ -102,6 +103,17 @@ static void thermal_obj(cj_writer_t *w, const thermal_snap_t *t)
|
||||
cj_w(w, "]},\"derate\":%s", b(t->derate));
|
||||
}
|
||||
|
||||
/* 0.1.14:`"hub":{"on":true,"mode":"auto","why":"vbus","hold":0,"idle":0}`(hubctl.h)。
|
||||
`why` 是上一拍开着的理由(关着是 "off");`hold` = 保持窗口剩余秒数;
|
||||
`idle` = 只剩 idle 这一条理由时,离自动关还有几秒(否则 0)。 */
|
||||
void cmd_report_hub(cj_writer_t *w)
|
||||
{
|
||||
const uint32_t now = hal_time_now_ms();
|
||||
cj_w(w, ",\"hub\":{\"on\":%s,\"mode\":\"%s\",\"why\":\"%s\",\"hold\":%lu,\"idle\":%lu}",
|
||||
b(hubctl_is_on()), hub_mode_str(hubctl_mode()), hub_why_str(hubctl_why()),
|
||||
(unsigned long)hubctl_hold_left_s(now), (unsigned long)hubctl_idle_left_s(now));
|
||||
}
|
||||
|
||||
void cmd_report_status(cj_writer_t *w, const cmd_env_t *env)
|
||||
{
|
||||
const safety_snap_t *s = env->safety;
|
||||
@@ -114,6 +126,7 @@ void cmd_report_status(cj_writer_t *w, const cmd_env_t *env)
|
||||
} else {
|
||||
cj_w(w, ",\"host\":null");
|
||||
}
|
||||
cmd_report_hub(w);
|
||||
if (s != NULL) {
|
||||
if (s->input_ok) {
|
||||
cj_w(w, ",\"in\":{\"mv\":%ld,\"ua\":%ld}", (long)s->input.bus_mv,
|
||||
|
||||
在新工单中引用
屏蔽一个用户