forked from Blendman974/faceclaw
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ead474e2 | ||
|
|
e4d3286b3d | ||
|
|
a9df3de59b | ||
|
|
3eb9b09e3d
|
||
|
|
3dd307483d |
No files matched your search
@@ -231,17 +231,16 @@ class FaceclawBleManager(context: Context) {
|
|||||||
fun connect(address: String?, timeoutMs: Int): Boolean = connect(address, timeoutMs, false)
|
fun connect(address: String?, timeoutMs: Int): Boolean = connect(address, timeoutMs, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPERIMENTAL (2026-09-11): the ring specifically needs autoConnect=true.
|
* autoConnect=true is used for the ring and both glasses arms. The ring specifically
|
||||||
* Even's own vendor app connects the ring with Android's autoConnect flag
|
* needs it (Even's own vendor app connects the ring with Android's autoConnect flag
|
||||||
* set (confirmed via its own BLE debug log, "connect() - device: ...,
|
* set, confirmed via its own BLE debug log, "connect() - device: ...,
|
||||||
* auto: true"), while every other faceclaw connection (both glasses arms)
|
* auto: true"). A live test showed a ring-only direct connection dying almost
|
||||||
* uses autoConnect=false. Direct connect (false) is faster to establish
|
* exactly 5 seconds in, repeatedly, with nothing else competing for it, and the
|
||||||
* but Android supervises it less patiently; a live test showed the
|
* glasses arms showed the same "less patiently supervised" direct-connect drop.
|
||||||
* ring-only direct connection dying almost exactly 5 seconds in,
|
* Direct connect (false) is faster to establish but Android supervises it less
|
||||||
* repeatedly, with nothing else competing for it. autoConnect=true can
|
* patiently. autoConnect=true can take much longer to actually complete (Android
|
||||||
* take much longer to actually complete (Android manages it as a
|
* manages it as a background reconnect, not an immediate attempt), so it needs its
|
||||||
* background reconnect, not an immediate attempt), so this needs its own
|
* own longer timeout. Like [connect], waits on an attempt already pending.
|
||||||
* longer timeout. Like [connect], waits on an attempt already pending.
|
|
||||||
*/
|
*/
|
||||||
fun connect(address: String?, timeoutMs: Int, autoConnect: Boolean): Boolean {
|
fun connect(address: String?, timeoutMs: Int, autoConnect: Boolean): Boolean {
|
||||||
val key = requireAddress(address)
|
val key = requireAddress(address)
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ export function createEvenHubWindow(
|
|||||||
})),
|
})),
|
||||||
// Glasses-first: the app runs without the phone showing it; this reveals
|
// Glasses-first: the app runs without the phone showing it; this reveals
|
||||||
// its phone UI (config pages, etc.) over the dashboard on demand.
|
// its phone UI (config pages, etc.) over the dashboard on demand.
|
||||||
{ label: "Show phone UI", onSelect: (ctx: LayerContext) => { ctx.stack.pop(); onShowPhone(); } },
|
...(session.manifest.packageId === "dev.guillaume.evenanchor" && session.contextMenuItems().length > 0
|
||||||
|
? [] : [{ label: "Show phone UI", onSelect: (ctx: LayerContext) => { ctx.stack.pop(); onShowPhone(); } }]),
|
||||||
],
|
],
|
||||||
actions: options.actions,
|
actions: options.actions,
|
||||||
baseLayer: appLayer,
|
baseLayer: appLayer,
|
||||||
|
|||||||
+6
@@ -12,6 +12,12 @@ class ConnectionOptions {
|
|||||||
// giving up. Both are dialed at once, so a slow or missing arm gets the whole
|
// giving up. Both are dialed at once, so a slow or missing arm gets the whole
|
||||||
// window (it stays under Android's own ~30 s direct-connect timeout).
|
// window (it stays under Android's own ~30 s direct-connect timeout).
|
||||||
const val ARM_CONNECT_WINDOW_MS = 20_000
|
const val ARM_CONNECT_WINDOW_MS = 20_000
|
||||||
|
// When autoConnect (background reconnect) fails to reach an arm, a direct connect
|
||||||
|
// is retried: its aggressive scan can catch an arm that advertises only briefly,
|
||||||
|
// and the cached bond can sometimes recover a half-open link that stopped
|
||||||
|
// advertising after a dropped link. This is the direct retry's own window,
|
||||||
|
// independent of ARM_CONNECT_WINDOW_MS (already spent on the autoConnect attempt).
|
||||||
|
const val DIRECT_CONNECT_FALLBACK_TIMEOUT_MS = 15_000
|
||||||
const val SERVICES_TIMEOUT_MS = 5_000
|
const val SERVICES_TIMEOUT_MS = 5_000
|
||||||
const val DESCRIPTOR_TIMEOUT_MS = 5_000
|
const val DESCRIPTOR_TIMEOUT_MS = 5_000
|
||||||
const val RING_DESIRED_MTU = 247
|
const val RING_DESIRED_MTU = 247
|
||||||
|
|||||||
+18
-7
@@ -2339,9 +2339,12 @@ class GlassesSessionCore(
|
|||||||
try {
|
try {
|
||||||
// Dial both arms at once, so the left arm's attempt is already pending (and
|
// Dial both arms at once, so the left arm's attempt is already pending (and
|
||||||
// can land) while the right arm is being set up; they share one window.
|
// can land) while the right arm is being set up; they share one window.
|
||||||
|
// autoConnect=true for both arms: a direct connection is supervised less
|
||||||
|
// patiently by Android's stack and was observed dropping the link shortly
|
||||||
|
// after it came up (the same failure that made the ring require autoConnect).
|
||||||
val deadlineMs = now() + ConnectionOptions.ARM_CONNECT_WINDOW_MS
|
val deadlineMs = now() + ConnectionOptions.ARM_CONNECT_WINDOW_MS
|
||||||
link.beginConnect(rightAddress, false)
|
link.beginConnect(rightAddress, true)
|
||||||
link.beginConnect(leftAddress, false)
|
link.beginConnect(leftAddress, true)
|
||||||
connectArm(rightAddress, true, deadlineMs)
|
connectArm(rightAddress, true, deadlineMs)
|
||||||
connectArm(leftAddress, true, deadlineMs)
|
connectArm(leftAddress, true, deadlineMs)
|
||||||
if (!sleepDuringConnectSettling(800)) {
|
if (!sleepDuringConnectSettling(800)) {
|
||||||
@@ -2450,8 +2453,16 @@ class GlassesSessionCore(
|
|||||||
|
|
||||||
internal fun connectArm(address: String, enableRenderNotify: Boolean, deadlineMs: Long) {
|
internal fun connectArm(address: String, enableRenderNotify: Boolean, deadlineMs: Long) {
|
||||||
val timeoutMs = maxOf(deadlineMs - now(), ConnectionOptions.CONNECT_TIMEOUT_MS.toLong())
|
val timeoutMs = maxOf(deadlineMs - now(), ConnectionOptions.CONNECT_TIMEOUT_MS.toLong())
|
||||||
if (!link.connect(address, timeoutMs.toInt())) {
|
if (!link.connect(address, timeoutMs.toInt(), true)) {
|
||||||
throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address)
|
// autoConnect only connects on a fresh advertisement; an arm stuck in a
|
||||||
|
// half-open state (it stopped advertising after a dropped link) never
|
||||||
|
// produces one. Retry direct: the aggressive scan plus the cached bond
|
||||||
|
// can recover it. Still unreachable after that is a real failure.
|
||||||
|
logLine("autoConnect timed out for " + address + "; retrying direct connect")
|
||||||
|
ConnectionCounters.increment("g2.connect-fallback-direct")
|
||||||
|
if (!link.connect(address, ConnectionOptions.DIRECT_CONNECT_FALLBACK_TIMEOUT_MS, false)) {
|
||||||
|
throw ArmUnreachableException(if (address.equals(leftAddress, ignoreCase = true)) "left" else "right", address)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// requestConnectionPriority has no callback in this Android compile target, so there is
|
// requestConnectionPriority has no callback in this Android compile target, so there is
|
||||||
// no reliable completion point to keep it in the global GATT operation pipeline. But it's
|
// no reliable completion point to keep it in the global GATT operation pipeline. But it's
|
||||||
@@ -2538,9 +2549,9 @@ class GlassesSessionCore(
|
|||||||
logLine("connecting direct ring $ringAddress")
|
logLine("connecting direct ring $ringAddress")
|
||||||
// autoConnect=true (see SessionLink.connect's 3-arg overload) -
|
// autoConnect=true (see SessionLink.connect's 3-arg overload) -
|
||||||
// matches what Even's own app does for this device specifically.
|
// matches what Even's own app does for this device specifically.
|
||||||
// Direct connect (false, the default used for the glasses) was
|
// Direct connect (false) was measured dying ~5s into an
|
||||||
// measured dying ~5s into an otherwise-idle ring connection,
|
// otherwise-idle ring connection, repeatedly, with nothing else
|
||||||
// repeatedly, with nothing else competing for it.
|
// competing for it.
|
||||||
if (!link.connect(ringAddress, ConnectionOptions.RING_CONNECT_TIMEOUT_MS, true)) {
|
if (!link.connect(ringAddress, ConnectionOptions.RING_CONNECT_TIMEOUT_MS, true)) {
|
||||||
throw IllegalStateException("connect failed: $ringAddress")
|
throw IllegalStateException("connect failed: $ringAddress")
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -18,7 +18,8 @@ interface SessionLink {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [connect] with the platform's background-reconnect mode (Android's autoConnect) when
|
* [connect] with the platform's background-reconnect mode (Android's autoConnect) when
|
||||||
* [autoConnect] is set. The R1 ring needs it; platforms without the distinction ignore it.
|
* [autoConnect] is set. The R1 ring and the G2 glasses arms both need it; platforms
|
||||||
|
* without the distinction ignore it.
|
||||||
*/
|
*/
|
||||||
fun connect(address: String, timeoutMs: Int, autoConnect: Boolean): Boolean = connect(address, timeoutMs)
|
fun connect(address: String, timeoutMs: Int, autoConnect: Boolean): Boolean = connect(address, timeoutMs)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user