forked from Blendman974/faceclaw
G1 support: Preserve connections after flashing, debug
This commit is contained in:
1 parent
595b462b2e
commit
b353483ac2
38 files changed
+1291
-178
No files matched your search
@@ -4,13 +4,21 @@ import { G1ArmScanner } from "../g1/arm-scanner";
|
||||
import { G1V0_IMAGE } from "../g1/firmware/g1v0-image";
|
||||
import { buildG1Firmware, type BuiltG1Firmware, type G1BuildProgress } from "../g1/firmware-builder";
|
||||
import { saveG1Arm, saveG1Pair } from "../g1/addresses";
|
||||
import { G1_CASE_INSTRUCTIONS, G1_INSTALL_NOTICE, G1_SIDES, g1FlashPercent, type G1FlashResult, type G1Side } from "../g1/flash-plan";
|
||||
import {
|
||||
G1_CASE_DELAY_HINT,
|
||||
G1_CASE_INSTRUCTIONS,
|
||||
G1_INSTALL_NOTICE,
|
||||
G1_SIDES,
|
||||
g1FlashPercent,
|
||||
type G1FlashResult,
|
||||
type G1Side,
|
||||
} from "../g1/flash-plan";
|
||||
import { loadDeviceAddresses, loadPairedGlassesIdentity } from "../g2/device-addresses";
|
||||
import { downloadAndExtractEvenHubFonts, hasExtractedEvenHubFonts } from "../g2/firmware-builder";
|
||||
import { type GlassesPairCandidate } from "../g2/pairing-candidates";
|
||||
import { resumeAutoReconnect, suppressAutoReconnect } from "../g2/reconnect-policy";
|
||||
import { ensureBlePermissions } from "../native/ble-permissions";
|
||||
import { G1Flasher, type G1FlasherOptions } from "../native/g1-flasher";
|
||||
import { forgetG1Pairing, G1Flasher, type G1FlasherOptions } from "../native/g1-flasher";
|
||||
import { formatErrorMessage } from "../util/format-error";
|
||||
import { finishOnboardingNavigation } from "./onboarding-navigation";
|
||||
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
@@ -190,11 +198,16 @@ export class G1FlashViewModel extends Observable {
|
||||
"open: an interrupted install finishes by itself. Then retry.");
|
||||
}
|
||||
saveG1Arm(side, back);
|
||||
// Coming from firmware before 0.5.66, which had an address of its own: the phone needn't remember that one.
|
||||
if (back.address !== arm.address) forgetG1Pairing(arm.address);
|
||||
if (back.g1Firmware === "g1v0-safe") {
|
||||
throw new Error(`The ${side} arm came back in safe mode: the new firmware restarted repeatedly. Retry to install it again.`);
|
||||
}
|
||||
|
||||
this.setStatus(`Pairing with the ${side} arm. If your phone asks, accept it.`);
|
||||
this.setStatus(`Checking the ${side} arm. If your phone asks to pair, accept it. ${G1_CASE_DELAY_HINT}`);
|
||||
// An arm at a new address has no bond yet (coming from Even's firmware the address is kept from 0.5.66 on, and so is the
|
||||
// bond). It may refuse one for a while: it's installed either way, and the session pairs it later.
|
||||
const newAddress = back.address !== arm.address;
|
||||
let running: G1FlashResult;
|
||||
try {
|
||||
running = await this.flash({
|
||||
@@ -202,10 +215,10 @@ export class G1FlashViewModel extends Observable {
|
||||
side,
|
||||
firmwarePath: "",
|
||||
mode: "probe",
|
||||
connectWindowMs: fromStock ? FIRST_PAIRING_MS : RETURN_MS,
|
||||
connectWindowMs: newAddress ? FIRST_PAIRING_MS : RETURN_MS,
|
||||
});
|
||||
} catch (error) {
|
||||
if (!fromStock || !live()) throw error;
|
||||
if (!newAddress || !live()) throw error;
|
||||
// Installed, as its advertising shows; it just won't pair yet. The next connection pairs it.
|
||||
this.appendLog(`${side} arm not paired yet: ${formatErrorMessage(error)}`);
|
||||
this.unpairedArm = true;
|
||||
|
||||
@@ -22,7 +22,15 @@ import { G1Flasher } from "../native/g1-flasher";
|
||||
import { saveG1Pair } from "../g1/addresses";
|
||||
import { G1ArmScanner } from "../g1/arm-scanner";
|
||||
import { G1V0_IMAGE } from "../g1/firmware/g1v0-image";
|
||||
import { G1_CASE_INSTRUCTIONS, G1_INSTALL_NOTICE, g1FirmwareState, type G1FlashResult, type G1Side } from "../g1/flash-plan";
|
||||
import {
|
||||
G1_CASE_DELAY_HINT,
|
||||
G1_CASE_INSTRUCTIONS,
|
||||
G1_INSTALL_NOTICE,
|
||||
g1FirmwareState,
|
||||
g1StateFromAdvertising,
|
||||
type G1FlashResult,
|
||||
type G1Side,
|
||||
} from "../g1/flash-plan";
|
||||
import { loadPairedGlassesIdentity } from "../g2/device-addresses";
|
||||
import { glassesTypeSetting } from "../ui/dashboard-settings";
|
||||
import { setOnboardingCompleted, setPreviewOnlyMode } from "./onboarding-state";
|
||||
@@ -213,8 +221,8 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
}
|
||||
|
||||
/**
|
||||
* What each arm's name says first, as that needs no connection: Even's firmware can't be asked in the same way, and an
|
||||
* arm that is about to be replaced shouldn't have to pair. Only arms on g1v0 are asked which version they run.
|
||||
* What the arms advertise first, as that needs no connection or pairing. Only firmware from before it advertised its
|
||||
* version (0.5.66) has to be asked.
|
||||
*/
|
||||
private async checkG1(generation: number): Promise<void> {
|
||||
this.status = "Listening for your glasses...";
|
||||
@@ -229,13 +237,12 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
return;
|
||||
}
|
||||
saveG1Pair(pair);
|
||||
const named = [pair.left!.g1Firmware, pair.right!.g1Firmware];
|
||||
if (named.includes("stock")) {
|
||||
this.showG1Install({ firmware: "stock" });
|
||||
return;
|
||||
}
|
||||
if (named.includes("g1v0-safe")) {
|
||||
this.showG1Install({ safeMode: true });
|
||||
const advertised = g1StateFromAdvertising(pair, G1V0_IMAGE.version);
|
||||
if (advertised) {
|
||||
if (advertised.state === "current") this.applyClassification("custom", advertised.version, { kind: "none" });
|
||||
else if (advertised.state === "stock") this.showG1Install({ firmware: "stock" });
|
||||
else if (advertised.state === "safe-mode") this.showG1Install({ safeMode: true });
|
||||
else this.showG1Install({ version: advertised.version });
|
||||
return;
|
||||
}
|
||||
const arms: G1FlashResult[] = [];
|
||||
@@ -245,7 +252,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
flasher.onState((state) => {
|
||||
if (generation !== this.generation) return;
|
||||
if (state === "pairing") {
|
||||
this.status = `Pairing with the ${side} arm. If your phone asks, accept it. A G1 pairs only in its case, with the lid open.`;
|
||||
this.status = `Pairing with the ${side} arm. If your phone asks, accept it. A G1 pairs only in its case, with the lid open. ${G1_CASE_DELAY_HINT}`;
|
||||
} else {
|
||||
this.status = `Checking the ${side} arm...`;
|
||||
}
|
||||
|
||||
@@ -383,9 +383,10 @@ export class PairingViewModel extends Observable {
|
||||
}
|
||||
}
|
||||
this.dispose();
|
||||
if (this.onboarding) {
|
||||
setPreviewOnlyMode(false);
|
||||
// Continue the onboarding chain: check the glasses' firmware next.
|
||||
if (this.onboarding) setPreviewOnlyMode(false);
|
||||
// Onboarding checks the glasses' firmware next. So does choosing a G1 from anywhere: it may run Even's firmware,
|
||||
// and whether it does is known without connecting.
|
||||
if (this.onboarding || pair?.g1Firmware) {
|
||||
Frame.topmost()?.navigate({ moduleName: "phone-ui/onboarding-firmware-check-page" });
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user