forked from Blendman974/faceclaw
Read the charging case battery (sid 0x81 GlassesCaseInfo)
The glasses relay the charging case's state on UX_GLASSES_CASE_APP_ID
(sid 0x81): GlassesCaseDataPackage{commandId=CASE_INFO, magicRandom,
caseInfo{soc, chargeStatus, lidStatus, inCaseStatus, errorCode}}, the
schema in g2-kit-unofficial's glasses_case.proto. The Even app reads it
with an empty caseInfo (ProtoBaseSettings.getGlassesCaseInfo).
Observed on G2 2.3.0.24 / Faceclaw/38: while docked the right temple
pushes a GlassesCaseInfo (flag 0x01, its own magic) on every change --
docking, lid, USB, each 1% -- and answers a read with full data; out of
the case a read comes back with an empty caseInfo. Docking pushes
{inCaseStatus=1} before the level, and proto3 drops zero fields, so a
missing soc means no level rather than 0%.
So read it once at session start (docked glasses may be fully charged
and never enter charging mode) and again on entering charging mode,
which clears the queue; pushes carry every later change. Every 0x81
frame is taken as state in onNotification (pushes skip the ack path by
flag). New readings reach TypeScript through
FaceclawBleCommunicatorListener.onCaseState (level, case-charging), on
Android and iOS. Captured frames are tests.
This commit is contained in:
1 parent
a4adb73182
commit
acfcf79787
10 files changed
+234
No files matched your search
@@ -42,6 +42,9 @@ export type HeadsetBatteryState = {
|
||||
ringChargingStatus?: number;
|
||||
};
|
||||
|
||||
/** See the Android communicator's CaseBatteryState. */
|
||||
export type CaseBatteryState = { battery: number; charging: boolean };
|
||||
|
||||
export type FrameMetrics = {
|
||||
paintMs: number;
|
||||
transmitMs: number;
|
||||
@@ -120,6 +123,9 @@ class SessionListener extends NSObject {
|
||||
onBatteryStateHeadsetBatteryHeadsetChargingRingBatteryRingCharging(headsetBattery: number, headsetCharging: number, ringBattery: number, ringCharging: number): void {
|
||||
this.bridge.handleBatteryState(Number(headsetBattery), Number(headsetCharging), Number(ringBattery), Number(ringCharging));
|
||||
}
|
||||
onCaseStateCaseBatteryCaseCharging(caseBattery: number, caseCharging: number): void {
|
||||
this.bridge.handleCaseState(Number(caseBattery), Number(caseCharging) === 1);
|
||||
}
|
||||
onSilentModeSilent(silent: boolean): void { this.bridge.handleSilentMode(Boolean(silent)); }
|
||||
onWearStateWearing(wearing: boolean): void { this.bridge.handleWearState(Boolean(wearing)); }
|
||||
onPhoneLockStateLocked(locked: boolean): void { this.bridge.handlePhoneLockState(Boolean(locked)); }
|
||||
@@ -215,6 +221,7 @@ export class FaceclawCommunicatorBridge {
|
||||
private readonly stateListeners = new Set<(state: CommunicatorState) => void>();
|
||||
private readonly ringListeners = new Set<(event: RawInputEvent) => void>();
|
||||
private readonly batteryListeners = new Set<(state: HeadsetBatteryState) => void>();
|
||||
private readonly caseListeners = new Set<(state: CaseBatteryState) => void>();
|
||||
private readonly silentModeListeners = new Set<(silent: boolean) => void>();
|
||||
private readonly wearStateListeners = new Set<(wearing: boolean) => void>();
|
||||
private readonly phoneLockStateListeners = new Set<(locked: boolean) => void>();
|
||||
@@ -280,6 +287,11 @@ export class FaceclawCommunicatorBridge {
|
||||
this.emitAsync(this.batteryListeners, { battery, chargingStatus, ringBattery, ringChargingStatus });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
handleCaseState(battery: number, charging: boolean): void {
|
||||
this.emitAsync(this.caseListeners, { battery, charging });
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
handleSilentMode(silent: boolean): void { this.emitAsync(this.silentModeListeners, silent); }
|
||||
|
||||
@@ -371,6 +383,11 @@ export class FaceclawCommunicatorBridge {
|
||||
return () => this.batteryListeners.delete(listener);
|
||||
}
|
||||
|
||||
onCaseState(listener: (state: CaseBatteryState) => void): () => void {
|
||||
this.caseListeners.add(listener);
|
||||
return () => this.caseListeners.delete(listener);
|
||||
}
|
||||
|
||||
onSilentMode(listener: (silent: boolean) => void): () => void {
|
||||
this.silentModeListeners.add(listener);
|
||||
return () => this.silentModeListeners.delete(listener);
|
||||
|
||||
@@ -29,6 +29,9 @@ export type HeadsetBatteryState = {
|
||||
ringChargingStatus?: number;
|
||||
};
|
||||
|
||||
/** The charging case's level (0..100) and whether it is itself charging, as the glasses relay it. */
|
||||
export type CaseBatteryState = { battery: number; charging: boolean };
|
||||
|
||||
export type FrameMetrics = {
|
||||
paintMs: number;
|
||||
transmitMs: number;
|
||||
@@ -151,6 +154,7 @@ export class FaceclawCommunicatorBridge {
|
||||
private readonly stateListeners = new Set<(state: CommunicatorState) => void>();
|
||||
private readonly ringListeners = new Set<(event: RawInputEvent) => void>();
|
||||
private readonly batteryListeners = new Set<(state: HeadsetBatteryState) => void>();
|
||||
private readonly caseListeners = new Set<(state: CaseBatteryState) => void>();
|
||||
private readonly silentModeListeners = new Set<(silent: boolean) => void>();
|
||||
private readonly wearStateListeners = new Set<(wearing: boolean) => void>();
|
||||
private readonly phoneLockStateListeners = new Set<(locked: boolean) => void>();
|
||||
@@ -212,6 +216,9 @@ export class FaceclawCommunicatorBridge {
|
||||
};
|
||||
this.emitAsync(this.batteryListeners, state);
|
||||
},
|
||||
onCaseState: (caseBattery: number, caseCharging: number) => {
|
||||
this.emitAsync(this.caseListeners, { battery: Number(caseBattery), charging: Number(caseCharging) === 1 });
|
||||
},
|
||||
onSilentMode: (silent: boolean) => {
|
||||
this.emitAsync(this.silentModeListeners, Boolean(silent));
|
||||
},
|
||||
@@ -332,6 +339,12 @@ export class FaceclawCommunicatorBridge {
|
||||
return () => this.batteryListeners.delete(listener);
|
||||
}
|
||||
|
||||
/** Charging-case readings: read on docking, then pushed by the glasses on every change. */
|
||||
onCaseState(listener: (state: CaseBatteryState) => void): () => void {
|
||||
this.caseListeners.add(listener);
|
||||
return () => this.caseListeners.delete(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Silent mode, toggled on the glasses by long-pressing both touchpads. While
|
||||
* it is on the firmware ignores all input and blanks the display.
|
||||
|
||||
Reference in new issue
Block a user