forked from Blendman974/faceclaw
Refuse the flash with a reason when the glasses are in silent mode
Silent mode blanks the display and stops the firmware dispatching input while BLE and GATT stay up, so the create-prompt page is written, accepted, and never rendered. There is no touchpad event available to answer it with, and the flash ends after four attempts on "prompt page not acked", which tells the wearer nothing about what is wrong or what to do about it. readBattery was already performing a sid-0x09 settings read whose ack carries silentMode next to the battery, and the field was being discarded. readSettings is factored out so one read serves both callers, and requireNotSilent runs it before the prompt page is written. A positive report throws, and the existing error path turns the message into what the wearer sees: that the glasses are in silent mode, and that long-pressing both touchpads leaves it. It refuses only on a positive report. An arm that does not answer, and firmware whose ack omits the field, both fall through to the prompt exactly as before, so older firmware is unaffected and a missing answer can never block a flash. This replaces the phone-side confirmation fallback that was here before. An unacked page is not by itself evidence that the prompt was never displayed, and the on-lens step is what proves the glasses being flashed are the ones in front of you, so overriding it on a timeout gave up more than it was worth.
This commit is contained in:
3 files changed
+55
-95
No files matched your search
@@ -56,8 +56,6 @@ 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();
|
||||
@@ -176,7 +174,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
case "flashed":
|
||||
return "Finish";
|
||||
case "error":
|
||||
return this.primaryLabelOverride ?? "Retry";
|
||||
return "Retry";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -331,25 +329,6 @@ 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;
|
||||
}
|
||||
@@ -590,13 +569,7 @@ export class OnboardingFlashViewModel extends Observable {
|
||||
});
|
||||
}
|
||||
|
||||
private toError(
|
||||
message: string,
|
||||
retry: () => void,
|
||||
headline = "Something Went Wrong",
|
||||
primaryLabel: string | null = null,
|
||||
): void {
|
||||
this.primaryLabelOverride = primaryLabel;
|
||||
private toError(message: string, retry: () => void, headline = "Something Went Wrong"): void {
|
||||
this.retryAction = retry;
|
||||
this.status = message;
|
||||
this.setPhase("error");
|
||||
|
||||
Reference in new issue
Block a user