forked from Blendman974/faceclaw
Add ANCS support to G1
This commit is contained in:
1 parent
0cc263c5d2
commit
6e4515afa5
12 files changed
+199
-19
No files matched your search
@@ -152,8 +152,10 @@ export class AncsClient {
|
||||
if (flags & 2) {
|
||||
const data = new Uint8Array(this.fragments); this.fragments = []; this.packetKind = -1
|
||||
if (kind === 0) {
|
||||
if (data.length !== 1 || data[0] > 2) { this.recover(); return true }
|
||||
if (data.length !== 1 || data[0] > 3) { this.recover(); return true }
|
||||
if (data[0] === 2) { this.recover('Glasses reported a notification relay error. Retrying…'); return true }
|
||||
// Only a G1's firmware looks for ANCS itself, so only it can say the phone isn't offering it.
|
||||
if (data[0] === 3) { this.recover('iPhone is not sharing notifications with the glasses. Enable Share System Notifications in Settings → Bluetooth → right arm. Retrying…'); return true }
|
||||
if (data[0] === 0) { this.resetReceived = true; this.log('Glasses accepted notification relay START; awaiting subscription') }
|
||||
if (data[0] === 1) {
|
||||
if (this.timer !== null) clearTimeout(this.timer)
|
||||
|
||||
@@ -23,6 +23,7 @@ import { weatherBridge } from '../native/weather'
|
||||
import { FaceclawCommunicatorBridge, resolveIosPeripherals, type CommunicatorState, type RawInputEvent } from '../native/faceclaw-communicator.ios'
|
||||
import { PreviewDisplayTarget, type DisplayTarget } from '../native/preview-display.ios'
|
||||
import { AncsClient, ANCS_FIRMWARE_VERSION } from './ancs-client'
|
||||
import { G1V0_IMAGE } from '../g1/firmware/g1v0-image'
|
||||
import { GlanceHost, type GlanceDisplay } from './glance-host'
|
||||
import { createLockScreenImage, LOCK_SCREEN_SURFACE_ID } from './lock-screen'
|
||||
import { OsEventTypeList } from './events'
|
||||
@@ -984,6 +985,8 @@ export class IosPreviewController {
|
||||
// (or re-pairs / installs the custom firmware, which lift the suppression).
|
||||
if (isHaltedSessionPhase(state.phase)) suppressAutoReconnect()
|
||||
const phase: SessionPhase = state.phase === 'charging' ? 'connected' : isHaltedSessionPhase(state.phase) ? 'error' : state.phase
|
||||
// The relay ends with the link, so a reconnected session has to ask for it again (syncNotifications).
|
||||
if (phase !== 'connected' && this.notifications && this.notifications.state !== 'disconnected') this.notifications.stop()
|
||||
// Wear state is a per-transport snapshot: ask again on every new session.
|
||||
if (phase !== 'connected') this.wearDetectionRequested = false
|
||||
this.update(phase, state.status)
|
||||
@@ -1027,6 +1030,11 @@ export class IosPreviewController {
|
||||
if (this.state.capabilities) notifications.stop(`Update glasses to Faceclaw firmware ${ANCS_FIRMWARE_VERSION} or newer for iPhone notifications.`)
|
||||
return
|
||||
}
|
||||
// A G1 reports no revision that says so: its session knows from what the right arm answered.
|
||||
if (!communicator.ancsRelayAvailable()) {
|
||||
notifications.stop(`Update the glasses to Faceclaw's firmware ${G1V0_IMAGE.version} for iPhone notifications, then reconnect.`)
|
||||
return
|
||||
}
|
||||
if (notifications.state !== 'disconnected') return
|
||||
notifications.start((Date.now() ^ Math.floor(Math.random() * 0xffffffff)) >>> 0, communicator.rightWriteLimit())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user