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
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user