forked from Blendman974/faceclaw
Make the firmware upgrade reachable from older custom firmware
Glasses running an older Faceclaw firmware revision cannot be upgraded at all. The flash asks for confirmation on the lens first, and that firmware never shows the prompt, so the one path off it is closed. Measured on revision 13 (base 2.2.9.22). showPrompt writes the EvenHub create-prompt page to the right arm and waits for an ack. The lens accepts the write at the GATT layer and then answers nothing and displays nothing: four attempts, four onWriteCharacteristic status=0 length=165, no reply. buildCreatePromptPage documents its geometry as stock-firmware-safe "so this works before flashing", and that does not hold there. Three faults, each only visible once the previous one is fixed. An unacked prompt page was fatal. Flashing is the only way off that firmware, so failing here leaves the glasses permanently unupgradable. An unacked page now falls back to the phone-side confirmation that the low-battery retry already uses, on a screen that says what is being given up: the on-lens step is what proves the glasses are the wearer's. connectArm made a single attempt. The lens is routinely unavailable for a moment just after a previous link to it closed, which is exactly the state a retry is in, so the fallback failed instantly with "could not connect to the right arm". FaceclawFirmwareFlasher.connectLensResilient already retries within a window for this reason; connectArmResilient mirrors it and reports each attempt. That retry then tripped the lost-connection latch. Disconnecting between attempts fires onConnectionStateChange, which set rightLost AND finished and counted down the selection latch, so a successful second attempt still aborted with "Lost connection to the glasses". The callback now ignores drops while the arms are still being established. Logging, because a failed flash used to leave almost nothing to read. emitLog reached logcat, but emitState, emitProgress and emitComplete on the flasher, and emitState and emitResult on the prompt communicator, went only to the in-app listener, so the line carrying the reason existed only on the phone screen. Seven `catch (Exception ignored)` blocks across the two classes now log with the Throwable, matching the call sites elsewhere that already do. tests/flash-prompt-fallback.test.cjs covers the decision at its seam through the existing load-typescript loader. The first test fails against the current view model and passes with this change; the second is a regression guard and passes either way, so an unrelated failure cannot quietly skip the on-lens confirmation. Verified on hardware: both lenses flashed through this path after it had been a dead end.
This commit is contained in:
4 files changed
+202
-16
No files matched your search
@@ -56,6 +56,8 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
private flasher: FirmwareFlasher | null = null;
|
||||
private flasherUnsubscribers: Array<() => void> = [];
|
||||
private retryAction: () => void = () => this.beginPrompt();
|
||||
/** Overrides the error screen's "Retry" when the action is not a retry. */
|
||||
private primaryLabelOverride: string | null = null;
|
||||
|
||||
constructor(options?: { mode?: FlashMode; fromOnboarding?: boolean; autoStart?: boolean }) {
|
||||
super();
|
||||
@@ -174,7 +176,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
case "flashed":
|
||||
return "Finish";
|
||||
case "error":
|
||||
return "Retry";
|
||||
return this.primaryLabelOverride ?? "Retry";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -329,6 +331,25 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
break;
|
||||
case "error":
|
||||
this.busy = false;
|
||||
// An unacked prompt page is not a connection failure. The lens accepts the
|
||||
// write at the GATT layer and then never answers, which is what firmware
|
||||
// older than the revision this build needs does -- measured on revision 13,
|
||||
// four writes accepted with status 0 and no reply, nothing shown on the lens.
|
||||
// Flashing is the only way OFF that firmware, so failing here leaves the
|
||||
// glasses permanently unupgradable. Fall back to the phone-side confirmation
|
||||
// that the low-battery retry already uses, and say plainly what is being
|
||||
// given up: the on-lens step is what proves these are the wearer's glasses.
|
||||
if (/prompt page not acked/i.test(detail)) {
|
||||
this.toError(
|
||||
"Your glasses are on older firmware that can't show the confirmation prompt, so it can't be " +
|
||||
"confirmed on the lens. You can confirm here instead. Only continue if these are your glasses " +
|
||||
"and you want to install Faceclaw's custom firmware.",
|
||||
() => this.beginPrompt({ skipPrompt: true }),
|
||||
"Confirm On Your Phone",
|
||||
"Confirm & Install",
|
||||
);
|
||||
break;
|
||||
}
|
||||
this.toError(detail || "Connection failed.", () => this.beginPrompt({ skipPrompt }));
|
||||
break;
|
||||
}
|
||||
@@ -569,7 +590,13 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
});
|
||||
}
|
||||
|
||||
private toError(message: string, retry: () => void, headline = "Something Went Wrong"): void {
|
||||
private toError(
|
||||
message: string,
|
||||
retry: () => void,
|
||||
headline = "Something Went Wrong",
|
||||
primaryLabel: string | null = null,
|
||||
): void {
|
||||
this.primaryLabelOverride = primaryLabel;
|
||||
this.retryAction = retry;
|
||||
this.status = message;
|
||||
this.setPhase("error");
|
||||
|
||||
Reference in new issue
Block a user