This commit is contained in:
yrx
2026-08-12 14:59:13 +08:00
parent 165eeff64e
commit dc5da0294f
14 changed files with 202 additions and 15 deletions
+25 -2
View File
@@ -179,6 +179,11 @@ def charging_shutdown_monitor():
if current_ma < -abs(threshold_ma):
confirm_count += 1
if logger:
logger.warning(
f"[CHARGE-TIMING] sample tick_ms={maix_time.ticks_ms()} "
f"current={current_ma:.1f}mA confirm={confirm_count}/{confirm_required}"
)
if logger:
logger.info(
f"[CHARGE] INA226 充电电流 {current_ma:.1f}mA "
@@ -209,12 +214,30 @@ def charging_shutdown_monitor():
0,
int(getattr(config, "CHARGING_NOTIFY_TIMEOUT_MS", 30000)),
)
notification_sent = network_manager.safe_enqueue_and_wait(
notify_start_ms = maix_time.ticks_ms()
if logger:
logger.warning(
f"[CHARGE-TIMING] enqueue_start tick_ms={notify_start_ms} "
f"network={network_manager.network_type} "
f"tcp_connected={network_manager.tcp_connected} "
f"timeout_ms={notify_timeout_ms}"
)
notification_sent = network_manager.safe_terminal_send_and_wait(
{"poweroff": "充电中"},
2,
high=True,
timeout_ms=notify_timeout_ms,
)
notify_end_ms = maix_time.ticks_ms()
notify_elapsed_ms = abs(
maix_time.ticks_diff(notify_end_ms, notify_start_ms)
)
if logger:
logger.warning(
f"[CHARGE-TIMING] enqueue_done tick_ms={notify_end_ms} "
f"elapsed_ms={notify_elapsed_ms} sent={bool(notification_sent)} "
f"network={network_manager.network_type} "
f"tcp_connected={network_manager.tcp_connected}"
)
if notification_sent:
if logger:
logger.info("[CHARGE] 充电状态已发送到服务器")