|
@@ -1494,8 +1494,9 @@ class BambuMQTTClient:
|
|
|
# True once the printer has sent `cfg`; from then on AMS Filament Backup
|
|
# True once the printer has sent `cfg`; from then on AMS Filament Backup
|
|
|
# is read from cfg only, never from home_flag (#3259).
|
|
# is read from cfg only, never from home_flag (#3259).
|
|
|
self._backup_cfg_seen: bool = False
|
|
self._backup_cfg_seen: bool = False
|
|
|
- # Last home_flag written by the #3259 probe log below.
|
|
|
|
|
- self._backup_home_flag_logged: int | None = None
|
|
|
|
|
|
|
+ # True once a full status report arrived without `cfg`; from then on
|
|
|
|
|
+ # home_flag bit 10 is read from every status frame (#3259).
|
|
|
|
|
+ self._backup_home_flag_trusted: bool = False
|
|
|
|
|
|
|
|
# Track last requested tray ID for H2D dual-nozzle printers
|
|
# Track last requested tray ID for H2D dual-nozzle printers
|
|
|
# H2D only reports slot number (0-3) in tray_now, not global tray ID
|
|
# H2D only reports slot number (0-3) in tray_now, not global tray ID
|
|
@@ -2319,12 +2320,14 @@ class BambuMQTTClient:
|
|
|
# and live H2D ON/OFF capture 2026-06-20.
|
|
# and live H2D ON/OFF capture 2026-06-20.
|
|
|
#
|
|
#
|
|
|
# Families without cfg (P1S, P1P, A1, A1 Mini) carry it in home_flag
|
|
# Families without cfg (P1S, P1P, A1, A1 Mini) carry it in home_flag
|
|
|
- # bit 10 (#3259). That's read only from a full status report (the
|
|
|
|
|
- # same >30-key test as the developer-mode probe) and only while the
|
|
|
|
|
- # printer has never sent cfg: H2D firmware also sends small
|
|
|
|
|
- # heartbeat frames with a partial home_flag (bits 8-9 clear with a
|
|
|
|
|
- # card inserted, which is why the SD-card badge was removed), and
|
|
|
|
|
- # printers that send cfg must keep reading it alone.
|
|
|
|
|
|
|
+ # bit 10 (#3259). Trusted once a full status report (the same
|
|
|
|
|
+ # >30-key test as the developer-mode probe) arrived without cfg;
|
|
|
|
|
+ # from then on every status frame that carries home_flag is read,
|
|
|
|
|
+ # so a toggle in the slicer shows up without a Force Refresh (P1S
|
|
|
|
|
+ # capture: each toggle came in a 4-6 key update frame). Before
|
|
|
|
|
+ # that nothing is read from small frames, so a cfg printer can't
|
|
|
|
|
+ # be misread from a frame that arrives ahead of its first cfg.
|
|
|
|
|
+ # Printers that send cfg keep reading it alone.
|
|
|
#
|
|
#
|
|
|
# Hold-timer guard: when the user just toggled via the badge, the
|
|
# Hold-timer guard: when the user just toggled via the badge, the
|
|
|
# next 1-2 push_status frames may still carry the printer's OLD cfg
|
|
# next 1-2 push_status frames may still carry the printer's OLD cfg
|
|
@@ -2339,27 +2342,11 @@ class BambuMQTTClient:
|
|
|
if "cfg" in print_data:
|
|
if "cfg" in print_data:
|
|
|
self._backup_cfg_seen = True
|
|
self._backup_cfg_seen = True
|
|
|
new_backup = parse_ams_filament_backup_from_cfg(print_data["cfg"])
|
|
new_backup = parse_ams_filament_backup_from_cfg(print_data["cfg"])
|
|
|
- elif not self._backup_cfg_seen and len(print_data) > 30:
|
|
|
|
|
- new_backup = parse_ams_filament_backup_from_home_flag(print_data.get("home_flag"))
|
|
|
|
|
- # Probe for #3259: does bit 10 stay right in the small update
|
|
|
|
|
- # frames these printers send between full reports? Logged on
|
|
|
|
|
- # every change, so a heartbeat that clears bit 10 shows up as
|
|
|
|
|
- # a flip. Remove once a P1S capture answers it.
|
|
|
|
|
- home_flag = print_data.get("home_flag")
|
|
|
|
|
- if (
|
|
|
|
|
- not self._backup_cfg_seen
|
|
|
|
|
- and isinstance(home_flag, int)
|
|
|
|
|
- and not isinstance(home_flag, bool)
|
|
|
|
|
- and home_flag != self._backup_home_flag_logged
|
|
|
|
|
- ):
|
|
|
|
|
- self._backup_home_flag_logged = home_flag
|
|
|
|
|
- logger.debug(
|
|
|
|
|
- "[%s] home_flag probe: 0x%08X bit10=%d keys=%d",
|
|
|
|
|
- self.serial_number,
|
|
|
|
|
- home_flag & 0xFFFFFFFF,
|
|
|
|
|
- (home_flag >> 10) & 1,
|
|
|
|
|
- len(print_data),
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ elif not self._backup_cfg_seen:
|
|
|
|
|
+ if len(print_data) > 30:
|
|
|
|
|
+ self._backup_home_flag_trusted = True
|
|
|
|
|
+ if self._backup_home_flag_trusted:
|
|
|
|
|
+ new_backup = parse_ams_filament_backup_from_home_flag(print_data.get("home_flag"))
|
|
|
if new_backup is not None and new_backup != self.state.ams_filament_backup:
|
|
if new_backup is not None and new_backup != self.state.ams_filament_backup:
|
|
|
hold_start = self._xcam_hold_start.get("print_option_auto_switch_filament")
|
|
hold_start = self._xcam_hold_start.get("print_option_auto_switch_filament")
|
|
|
if hold_start is not None and (time.time() - hold_start) <= self._xcam_hold_time:
|
|
if hold_start is not None and (time.time() - hold_start) <= self._xcam_hold_time:
|