Prevent beacon deep sleep on USB power, add beacon_gate to metrics

Watch no longer enters deep sleep after beacon TX when on external
power (charging or charged). This keeps the display, USB serial,
and debug tools active during development. On battery only, the
sleep/wake beacon cycle operates normally for power conservation.

Added beacon_gate and hw_ready to metrics output for debugging
beacon activation: gate 1=host active, 2=startup delay, 3=radio
offline, 4=no GPS fix, 5=interval wait, 6=beacon sent.

Verified: radio comes online with "RADIO" mode indicator and
amber "---" LoRa complication when provisioned with GPS fix.
Beacon mode activates after 15s no-host timeout.
pull/129/head
GlassOnTin 2026-03-29 11:58:55 +01:00
parent 2f693131a3
commit d49618a5ab
2 changed files with 7 additions and 3 deletions

6
Gui.h
View File

@ -919,11 +919,13 @@ static void gui_cmd_execute() {
snprintf(buf, sizeof(buf),
"{\"build\":\"%s %s\",\"loop\":%lu,\"radio\":%lu,"
"\"serial\":%lu,\"disp\":%lu,\"pmu\":%lu,"
"\"gps\":%lu,\"bt\":%lu,\"imu\":%lu}\n",
"\"gps\":%lu,\"bt\":%lu,\"imu\":%lu,"
"\"bcn_gate\":%d,\"hw_ready\":%d}\n",
__DATE__, __TIME__,
gui_loop_us_last, prof_radio_us, prof_serial_us,
prof_display_us, prof_pmu_us, prof_gps_us,
prof_bt_us, prof_imu_us);
prof_bt_us, prof_imu_us,
beacon_gate, hw_ready ? 1 : 0);
gui_loop_us_max = 0;
Serial.write((uint8_t *)buf, strlen(buf));
Serial.flush();

View File

@ -2073,10 +2073,12 @@ void loop() {
#endif
// Enter beacon sleep cycle when in standalone mode after beacon TX
// Don't sleep when on external power (USB) — keeps display and debug active
#if BOARD_MODEL == BOARD_TWATCH_ULT
if (beacon_mode_active && beacon_gate == 6 &&
battery_state != BATTERY_STATE_CHARGING &&
battery_state != BATTERY_STATE_CHARGED &&
(last_host_activity == 0 || (millis() - last_host_activity >= BEACON_NO_HOST_TIMEOUT_MS))) {
// Beacon was just sent and no host is connected — sleep until next interval
sleep_now();
}
#endif