forked from Blendman974/faceclaw
Partial support for Rayneo iO
This commit is contained in:
1 parent
742a5a3f81
commit
4d101eefe1
23 files changed
+1954
-69
No files matched your search
@@ -56,7 +56,7 @@ import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from "../apps/onb
|
||||
import { beginRenderPass, endRenderPass } from "../util/render-freshness";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
import { voiceActivity } from "../ui/shell/voice-activity";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage, RAYNEO_IO_HEIGHT, RAYNEO_IO_WIDTH } from "../graphics/image";
|
||||
import { flattenPlanesWithDraws, planesFingerprint, type Plane } from "../graphics/plane";
|
||||
import { prepareFrameDraws } from "../graphics/glyph-wire";
|
||||
import { createLockScreenImage, LOCK_SCREEN_SURFACE_ID } from "./lock-screen";
|
||||
@@ -78,7 +78,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
|
||||
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -1479,12 +1479,15 @@ class DashboardController {
|
||||
// address disables every direct-ring code path in the communicator.
|
||||
const ringMode = ringConnectionModeSetting.get();
|
||||
this.ringModeAtConnect = ringMode;
|
||||
const ringAddress = ringMode !== "glasses" ? addresses.ring : "";
|
||||
// A RayNeo iO is one link (its address in both arm slots) and has no ring.
|
||||
const glassesType = glassesTypeSetting.get();
|
||||
const ringAddress = ringMode !== "glasses" && glassesType === "g2" ? addresses.ring : "";
|
||||
// Direct mode may unpair the ring from the glasses; remember to hand it
|
||||
// back once a later session runs in another mode.
|
||||
if (ringMode === "direct" && ringAddress) setBooleanSetting(RING_TAKEN_FROM_GLASSES_KEY, true);
|
||||
this.appendLog(
|
||||
`Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
this.appendLog(glassesType === "rayneo-io"
|
||||
? `Using configured RayNeo iO: ${addresses.right}`
|
||||
: `Using configured arms: R=${addresses.right} L=${addresses.left}${ringAddress ? ` ring=${ringAddress}` : ""}`,
|
||||
);
|
||||
|
||||
let communicator: FaceclawCommunicatorBridge | null = null;
|
||||
@@ -1506,6 +1509,7 @@ class DashboardController {
|
||||
// sync needs the phone role, which the session borrows briefly for
|
||||
// each pull (GlassesSessionRing.beginRingHealthWindowLocked).
|
||||
ringRole: ringMode === "direct" ? "glasses" : "phone",
|
||||
glassesType,
|
||||
});
|
||||
this.communicator = communicator;
|
||||
// Size the compositor before anything else is awaited: windows opened
|
||||
@@ -1513,7 +1517,10 @@ class DashboardController {
|
||||
// configure their surfaces through this.communicator, and the Java call
|
||||
// queue is FIFO, so enqueuing the screen size first guarantees it lands
|
||||
// ahead of them. Mirrors ensurePreviewDisplay.
|
||||
await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
// The iO shows 540x220: the layout stays the G2's and is cropped at the right and
|
||||
// bottom (geometry.ts pins the band to the top-left while an iO is configured).
|
||||
if (glassesType === "rayneo-io") await communicator.configureCompositorScreen(RAYNEO_IO_WIDTH, RAYNEO_IO_HEIGHT);
|
||||
else await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
|
||||
await communicator.configureBrightness(getBrightnessPreferences());
|
||||
this.offState = communicator.onStateChange((state) => {
|
||||
if (state.phase !== "connected") resetRingInputFilter();
|
||||
|
||||
@@ -30,7 +30,7 @@ export { bytesToHex, hexToBytes };
|
||||
/** Even Realities' manufacturer-data company identifier (`"ER"` read little-endian). */
|
||||
export const EVEN_COMPANY_IDENTIFIER = 0x5245;
|
||||
|
||||
export type EvenDeviceRole = "left" | "right" | "ring";
|
||||
export type EvenDeviceRole = "left" | "right" | "ring" | "rayneo-io";
|
||||
|
||||
/** True when the manufacturer data opens with Even's `"ER"` marker. */
|
||||
export function hasEvenManufacturerSignature(mfg: Uint8Array): boolean {
|
||||
@@ -71,6 +71,14 @@ export function extractG2AdvertisementFlag(mfg: Uint8Array): number | null {
|
||||
return mfg[22]!;
|
||||
}
|
||||
|
||||
/** RayNeo iO manufacturer data (company 0x5716, little-endian first): `[07][MAC x6]...`, outside pairing mode. */
|
||||
export const RAYNEO_COMPANY_IDENTIFIER = 0x5716;
|
||||
|
||||
export function extractRayNeoMac(mfg: Uint8Array): string | null {
|
||||
if (mfg.length < 9 || mfg[0] !== 0x16 || mfg[1] !== 0x57 || mfg[2] !== 0x07) return null;
|
||||
return Array.from(mfg.subarray(3, 9), (byte) => byte.toString(16).padStart(2, "0").toUpperCase()).join(":");
|
||||
}
|
||||
|
||||
/**
|
||||
* Which side a G2 temple advertisement belongs to, from the local name.
|
||||
* Null when the name carries neither or both markers.
|
||||
@@ -230,8 +238,32 @@ export function classifyAdvertisement(raw: RawAdvertisement): EvenAdvertisement
|
||||
const hasSignature = hasEvenManufacturerSignature(mfg);
|
||||
const looksLikeRing = /^EVEN R1([_ ]|$)/.test(upper);
|
||||
const looksLikeG2 = upper.includes("G2");
|
||||
const rayneoMac = extractRayNeoMac(mfg);
|
||||
const looksLikeRayNeo = upper.startsWith("RAYNEO") || rayneoMac !== null;
|
||||
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature) return null;
|
||||
if (!looksLikeRing && !looksLikeG2 && !hasSignature && !looksLikeRayNeo) return null;
|
||||
|
||||
if (looksLikeRayNeo && !hasSignature) {
|
||||
const address = normalizeMacAddress(raw.address);
|
||||
return {
|
||||
address,
|
||||
name,
|
||||
role: "rayneo-io",
|
||||
serial: null,
|
||||
embeddedMac: rayneoMac,
|
||||
embeddedMacMismatch: !!rayneoMac && rayneoMac !== address,
|
||||
flag: null,
|
||||
ringSerialSuffix: null,
|
||||
rssi: raw.rssi,
|
||||
txPower: raw.txPower,
|
||||
connectable: raw.connectable,
|
||||
bonded: raw.bonded,
|
||||
source: raw.source,
|
||||
seenAtMs: raw.seenAtMs,
|
||||
manufacturerData: raw.manufacturerData ?? "",
|
||||
note: null,
|
||||
};
|
||||
}
|
||||
|
||||
const base = {
|
||||
address: normalizeMacAddress(raw.address),
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
type ProximityZone,
|
||||
} from "./ble-proximity";
|
||||
import { classifyAdvertisement, normalizeMacAddress, type EvenAdvertisement, type RawAdvertisement } from "./even-advertisement";
|
||||
import { glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import { GENERIC_G2_IMAGE_PATH, glassesImagePath, R1_IMAGE_PATH } from "./glasses-artwork";
|
||||
import {
|
||||
colorwayDisplayName,
|
||||
colorwaySwatchHex,
|
||||
@@ -56,6 +56,15 @@ export type GlassesPairCandidate = {
|
||||
mismatchWarning: string | null;
|
||||
};
|
||||
|
||||
/** A RayNeo iO: one device, one address (no arms to join). */
|
||||
export type RayNeoCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
rssi: number | null;
|
||||
proximity: ProximityEstimate | null;
|
||||
lastSeenMs: number;
|
||||
};
|
||||
|
||||
export type RingCandidate = {
|
||||
id: string;
|
||||
advertisement: EvenAdvertisement;
|
||||
@@ -176,7 +185,7 @@ export class DiscoveryAggregator {
|
||||
pairs(): GlassesPairCandidate[] {
|
||||
const groups = new Map<string, { left: (EvenAdvertisement & { smoothedRssi: number | null }) | null; right: (EvenAdvertisement & { smoothedRssi: number | null }) | null }>();
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role === "ring") continue;
|
||||
if (record.role === "ring" || record.role === "rayneo-io") continue;
|
||||
const canonical = serialKey(record.serial);
|
||||
const key = canonical ? `serial:${canonical}` : `arm:${record.address}`;
|
||||
const group = groups.get(key) ?? { left: null, right: null };
|
||||
@@ -225,6 +234,22 @@ export class DiscoveryAggregator {
|
||||
}
|
||||
|
||||
/** Every R1 ring seen, closest first. */
|
||||
rayneos(): RayNeoCandidate[] {
|
||||
const found: RayNeoCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
if (record.role !== "rayneo-io") continue;
|
||||
const rssi = record.smoothedRssi != null ? Math.round(record.smoothedRssi) : null;
|
||||
found.push({
|
||||
id: `rayneo:${record.address}`,
|
||||
advertisement: stripSmoothing(record),
|
||||
rssi,
|
||||
proximity: estimateProximity(rssi, GLASSES_CALIBRATION),
|
||||
lastSeenMs: record.seenAtMs,
|
||||
});
|
||||
}
|
||||
return sortedByProximity(found, (candidate) => candidate.proximity, (candidate) => candidate.id);
|
||||
}
|
||||
|
||||
rings(): RingCandidate[] {
|
||||
const rings: RingCandidate[] = [];
|
||||
for (const record of this.byAddress.values()) {
|
||||
@@ -281,7 +306,7 @@ export function isPreviouslyPaired(name: string | null | undefined, pairedSerial
|
||||
|
||||
export type PairingRowPresentation = {
|
||||
id: string;
|
||||
kind: "glasses" | "ring";
|
||||
kind: "glasses" | "ring" | "rayneo-io";
|
||||
/** "Even G2 B" / "Even R1" / fallback product name. */
|
||||
modelTitle: string;
|
||||
/** The serial (glasses) or local name (ring). */
|
||||
@@ -416,6 +441,28 @@ export function ringRow(ring: RingCandidate, context: RowContext = {}): PairingR
|
||||
};
|
||||
}
|
||||
|
||||
export function rayneoRow(candidate: RayNeoCandidate, context: { pairedAddress?: string; nearestId?: string | null } = {}): PairingRowPresentation {
|
||||
const ad = candidate.advertisement;
|
||||
const isPaired = !!context.pairedAddress && normalizeMacAddress(context.pairedAddress) === ad.address;
|
||||
const isNearest = !!context.nearestId && context.nearestId === candidate.id;
|
||||
const warnings: string[] = [];
|
||||
if (ad.embeddedMacMismatch) warnings.push(`It advertises ${ad.embeddedMac} but was heard as ${ad.address}.`);
|
||||
return {
|
||||
id: candidate.id,
|
||||
kind: "rayneo-io",
|
||||
modelTitle: "RayNeo iO",
|
||||
deviceName: ad.name || ad.address,
|
||||
variantSummary: null,
|
||||
colorway: null,
|
||||
swatchHex: null,
|
||||
imagePath: GENERIC_G2_IMAGE_PATH,
|
||||
hasVariantImage: false,
|
||||
...presentationBase(candidate.proximity, isNearest, isPaired, warnings),
|
||||
armsSummary: "Needs the Faceclaw custom firmware. First time: put it in pairing mode (on the charger, hold the button ~5 s until the light blinks blue).",
|
||||
canSelect: true,
|
||||
};
|
||||
}
|
||||
|
||||
/** Convenience: a colourway's display text, for rows that show the swatch alone. */
|
||||
export function colorwayLabel(colorway: GlassesColorway | null): string {
|
||||
return colorway ? colorwayDisplayName(colorway) : "";
|
||||
|
||||
Reference in new issue
Block a user