Merge branch 'idempotent-evenhub-connect' of https://github.com/jimrandomh/faceclaw into idempotent-evenhub-connect

This commit is contained in:
James Babcock committed 2026-10-06 09:37:27 -07:00
commit f210489fd4
7 files changed
+102 -36

No files matched your search

@@ -35,5 +35,6 @@ const val CFW_MSG_SET_ROOT_DISPLAY_LIST = 27
const val CFW_MSG_PRESENT = 28
const val CFW_MSG_CREATE_SURFACE = 29
const val CFW_MSG_BRIGHTNESS = 30
const val CFW_MSG_ENTER_EVENHUB = 31
const val CFW_MSG_TYPE_MASK = 127
const val CFW_MSG_FLAG_LENSES_DIFFER = 128
@@ -187,6 +187,20 @@ class MessageBuilder {
)
}
/**
* CFW mode 31: the firmware queues its own copy of [createLayout]'s page, and ACKs whether
* or not that page already existed. Stock firmware never ACKs a repeated create.
*/
fun enterEvenHub(leftArm: Boolean): OutboundMessage {
return customMessage(
"enter-evenhub",
byteArrayOf(CFW_MSG_ENTER_EVENHUB.toByte()),
"enter EvenHub",
-1,
leftArm,
)
}
fun startupTextProbe(): OutboundMessage {
var magic: Int = magicPool.allocate()
return OutboundMessage(
@@ -646,6 +646,10 @@ internal fun GlassesSessionCore.enqueueCreateLayoutLocked() {
// New session: re-assert the firmware-debug-flags overlay once
// the layout is ready (the mode-7 send is gated on this having reset).
firmwareDebugFlagsLastSent = -1
if (customFirmwareDetected) {
enqueueEnterEvenHubLocked()
return
}
val message = messageBuilder.createLayout()
message.onAck = MessageCallback {
startupProbePending = false
@@ -667,6 +671,25 @@ internal fun GlassesSessionCore.enqueueCreateLayoutLocked() {
logLine("queue create layout")
}
/**
* The custom-firmware replacement for the stock create layout (CFW mode 31).
* A reconnect can find the page from the previous session still up, and stock
* firmware never ACKs a repeated create; the CFW ACKs whatever state the
* glasses were in. A lost message goes through the CFW replay window like any
* other private message, which is safe because this one is idempotent. The
* settings query that sets customFirmwareDetected is ahead of this in the
* queue on every session.
*/
private fun GlassesSessionCore.enqueueEnterEvenHubLocked() {
val message = messageBuilder.enterEvenHub(connectionOptions.sendImagesToLeft)
message.onAck = MessageCallback {
fixedLayoutCreated = true
displayedFingerprint = ""
}
pendingMessages.addLast(message)
logLine("queue enter EvenHub")
}
internal fun GlassesSessionCore.enqueueStartupProbeLocked() {
enqueueCreateLayoutLocked()