Device-info probe: frame tracing, query retry, push acceptance, left-lens fallback
On stock 2.2.9 the settings read on the right lens goes unanswered even after a successful security-auth exchange and fresh pairing. Since no 2.2.9-era capture of a settings read exists (g2flash only exercises auth + OTA), turn the probe into an experiment that a single on-device run can settle: - Log every control-channel frame (sid/flag/type/magic/frag/payload prefix) and every write under the FaceclawDeviceInfo logcat tag. - Retry the settings read once before concluding a lens is silent. - Accept a sid-0x09 frame carrying firmware versions on the device's own magic (an unsolicited push) as an answer, not just the awaited ack. - If the right lens stays silent, run the same connect/auth/prelude/read against the LEFT lens and use its answer, logging which lens replied, to test whether 2.2.9 moved the settings endpoint. The probe now takes both arm addresses; the firmware-check page passes them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ZqzwmRQ3HQxasBz5rYyZV
No files matched your search
@@ -23,6 +23,7 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
|
||||
private final Context context;
|
||||
private final String rightAddress;
|
||||
private final String leftAddress;
|
||||
private final FaceclawBleManager bleManager;
|
||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@@ -35,13 +36,21 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
private byte[] awaitPb = null;
|
||||
private CountDownLatch awaitLatch = null;
|
||||
|
||||
/**
|
||||
* A sid-0x09 frame that carried firmware versions without matching the
|
||||
* awaited magic — some firmware pushes the settings snapshot on a magic it
|
||||
* picked itself instead of (or in addition to) acking the read.
|
||||
*/
|
||||
private volatile byte[] unsolicitedSettingsPb;
|
||||
|
||||
private volatile FaceclawDeviceInfoProbeListener listener;
|
||||
private volatile Thread worker;
|
||||
private volatile boolean cancelled = false;
|
||||
|
||||
public FaceclawDeviceInfoProbe(Context context, String rightAddress) {
|
||||
public FaceclawDeviceInfoProbe(Context context, String rightAddress, String leftAddress) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.rightAddress = rightAddress == null ? "" : rightAddress;
|
||||
this.leftAddress = leftAddress == null ? "" : leftAddress;
|
||||
this.bleManager = new FaceclawBleManager(this.context);
|
||||
this.bleManager.setListener(this);
|
||||
}
|
||||
@@ -83,44 +92,28 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
return;
|
||||
}
|
||||
|
||||
emitState("connecting", "");
|
||||
connectArm(rightAddress);
|
||||
byte[] ack = probeArm(rightAddress, "right");
|
||||
// The right lens is the documented control endpoint, but a silent
|
||||
// right lens has been observed on stock 2.2.9 even after a
|
||||
// successful security auth — run the same probe against the left
|
||||
// lens rather than giving up, and log which lens answered.
|
||||
if (ack == null && !cancelled && !leftAddress.trim().isEmpty()
|
||||
&& !leftAddress.equalsIgnoreCase(rightAddress)) {
|
||||
emitLog("right lens did not answer the settings query; probing the left lens");
|
||||
try {
|
||||
ack = probeArm(leftAddress, "left");
|
||||
} catch (Exception e) {
|
||||
emitLog("left-lens probe failed: " + (e.getMessage() == null ? e.toString() : e.getMessage()));
|
||||
}
|
||||
}
|
||||
if (cancelled) {
|
||||
emitError("Cancelled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Firmware 2.2.9 answers no queries until the security-auth
|
||||
// exchange completes over an encrypted link; on a phone with no
|
||||
// existing bond this is also what triggers SMP pairing (and its
|
||||
// OS prompt), so it must come before the prelude and query. Soft:
|
||||
// this probe also runs against the custom firmware, whose response
|
||||
// to the exchange is not yet hardware-verified, so an unconfirmed
|
||||
// auth falls through to the query and only enriches its error.
|
||||
emitState("authenticating", "");
|
||||
boolean authenticated = authenticate(rightAddress);
|
||||
if (cancelled) {
|
||||
emitError("Cancelled.");
|
||||
return;
|
||||
}
|
||||
|
||||
emitState("querying", "");
|
||||
// Session prelude, then a settings/device-info read (both arms'
|
||||
// versions and the CFW capability string ride back in one response).
|
||||
if (writeAndAwaitAck(rightAddress, BleProtocol.PRELUDE_ACK_SID, BleProtocol.FLAG_REQUEST,
|
||||
BleProtocol.PRELUDE_ACK_MAGIC, BleProtocol.PRELUDE_F5872_PAYLOAD,
|
||||
ConnectionOptions.PRELUDE_TIMEOUT_MS) == null) {
|
||||
throw new IllegalStateException("session prelude not acked");
|
||||
}
|
||||
|
||||
int magic = allocMagic();
|
||||
byte[] ack = writeAndAwaitAck(rightAddress, BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST,
|
||||
magic, BleProtocol.buildSettingsQuery(magic), QUERY_TIMEOUT_MS);
|
||||
if (ack == null) {
|
||||
throw new IllegalStateException(authenticated
|
||||
? "no response to the device-info query"
|
||||
: "no response to the device-info query — authentication with the glasses did not complete;"
|
||||
+ " if Android shows a Bluetooth pairing request, accept it and try again");
|
||||
throw new IllegalStateException(
|
||||
"no response to the device-info query on either lens — check `adb logcat -s "
|
||||
+ TAG + "` for the frame trace");
|
||||
}
|
||||
|
||||
BleProtocol.FirmwareInfo info = BleProtocol.parseSettingsFirmwareInfo(ack);
|
||||
@@ -140,6 +133,64 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect + authenticate + prelude + settings read on one lens. Returns the
|
||||
* settings ack protobuf, an unsolicited settings push that carried firmware
|
||||
* versions, or null when the lens never answered the read. Throws on
|
||||
* connect or prelude failure; the caller wraps the fallback lens's attempt
|
||||
* so its failure cannot mask the primary lens's outcome.
|
||||
*/
|
||||
private byte[] probeArm(String address, String label) throws InterruptedException {
|
||||
emitState("connecting", label);
|
||||
connectArm(address);
|
||||
if (cancelled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Firmware 2.2.9 answers no queries until the security-auth exchange
|
||||
// completes over an encrypted link; on a phone with no existing bond
|
||||
// this is also what triggers SMP pairing (and its OS prompt), so it
|
||||
// must come before the prelude and query. Soft: this probe also runs
|
||||
// against the custom firmware, whose response to the exchange is not
|
||||
// yet hardware-verified, so an unconfirmed auth falls through.
|
||||
emitState("authenticating", label);
|
||||
boolean authenticated = authenticate(address);
|
||||
if (cancelled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
emitState("querying", label);
|
||||
// Session prelude, then a settings/device-info read (both arms'
|
||||
// versions and the CFW capability string ride back in one response).
|
||||
if (writeAndAwaitAck(address, BleProtocol.PRELUDE_ACK_SID, BleProtocol.FLAG_REQUEST,
|
||||
BleProtocol.PRELUDE_ACK_MAGIC, BleProtocol.PRELUDE_F5872_PAYLOAD,
|
||||
ConnectionOptions.PRELUDE_TIMEOUT_MS) == null) {
|
||||
throw new IllegalStateException("session prelude not acked (" + label + " lens)"
|
||||
+ (authenticated ? "" : "; authentication did not complete —"
|
||||
+ " if Android shows a Bluetooth pairing request, accept it and try again"));
|
||||
}
|
||||
|
||||
// Two attempts: the first read straight after a fresh pairing has been
|
||||
// seen to go unanswered while a later one succeeds.
|
||||
for (int attempt = 0; attempt < 2 && !cancelled; attempt++) {
|
||||
int magic = allocMagic();
|
||||
byte[] ack = writeAndAwaitAck(address, BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST,
|
||||
magic, BleProtocol.buildSettingsQuery(magic), QUERY_TIMEOUT_MS);
|
||||
if (ack != null) {
|
||||
return ack;
|
||||
}
|
||||
// A push with the firmware versions on the device's own magic is
|
||||
// as good as the ack we asked for.
|
||||
byte[] pushed = unsolicitedSettingsPb;
|
||||
if (pushed != null) {
|
||||
emitLog("using unsolicited settings push instead of the read ack (" + label + " lens)");
|
||||
return pushed;
|
||||
}
|
||||
emitLog("settings query attempt " + (attempt + 1) + " unanswered (" + label + " lens)");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean authenticate(String address) throws InterruptedException {
|
||||
int magic = allocMagic();
|
||||
byte[] ack = writeAndAwaitAck(address, BleProtocol.SID_SECURITY_AUTH, BleProtocol.FLAG_SECURITY_AUTH,
|
||||
@@ -176,10 +227,13 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
synchronized (lock) {
|
||||
seq = nextSeq++ & 0xff;
|
||||
}
|
||||
emitLog(String.format("tx %s sid=0x%02x flag=0x%02x magic=%d seq=0x%02x len=%d",
|
||||
address, sid, flag, magic, seq, payload.length));
|
||||
List<byte[]> frames = BleProtocol.framePb(payload, sid, flag, seq);
|
||||
boolean written = bleManager.writeFrames(
|
||||
address, BleProtocol.WRITE_CHAR_UUID, frames, ConnectionOptions.WRITE_TYPE, ConnectionOptions.WRITE_TIMEOUT_MS);
|
||||
if (!written) {
|
||||
emitLog("tx write FAILED sid=0x" + Integer.toHexString(sid));
|
||||
synchronized (lock) {
|
||||
awaitLatch = null;
|
||||
}
|
||||
@@ -199,8 +253,22 @@ public class FaceclawDeviceInfoProbe implements FaceclawBleListener {
|
||||
}
|
||||
BleProtocol.ParsedFrame frame = BleProtocol.parseFrame(data);
|
||||
if (!frame.ok) {
|
||||
emitLog("rx " + address + " unparseable frame len=" + data.length
|
||||
+ " head=" + FaceclawFirmwareUtil.bytesToHex(java.util.Arrays.copyOf(data, Math.min(16, data.length))));
|
||||
return;
|
||||
}
|
||||
// Log every control frame while diagnosing 2.2.9: sid/flag/type/magic
|
||||
// plus a payload prefix is enough to reconstruct what the lens said.
|
||||
emitLog(String.format("rx %s sid=0x%02x flag=0x%02x type=%d magic=%d frag=%d/%d len=%d pb=%s",
|
||||
address, frame.sid, frame.flag, frame.msgType, frame.msgSeq,
|
||||
data.length > 5 ? data[5] & 0xff : 0, data.length > 4 ? data[4] & 0xff : 0, frame.pb.length,
|
||||
FaceclawFirmwareUtil.bytesToHex(java.util.Arrays.copyOf(frame.pb, Math.min(40, frame.pb.length)))));
|
||||
if (frame.sid == BleProtocol.SID_UI_SETTING
|
||||
&& BleProtocol.parseSettingsFirmwareInfo(frame.pb) != null) {
|
||||
// Any settings frame carrying firmware versions answers the probe's
|
||||
// question, whether or not it matches the magic we asked with.
|
||||
unsolicitedSettingsPb = frame.pb;
|
||||
}
|
||||
if (frame.flag == BleProtocol.FLAG_NOTIFY || frame.flag == BleProtocol.FLAG_NOTIFY_ALT) {
|
||||
return; // async event, not an ack
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 22 KiB |
@@ -1,8 +1,8 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="fill">
|
||||
<item>
|
||||
<bitmap android:gravity="fill" android:src="@drawable/background" />
|
||||
<color android:color="#F6F6F6" />
|
||||
</item>
|
||||
<item>
|
||||
<bitmap android:gravity="center" android:src="@drawable/logo" />
|
||||
</item>
|
||||
</layer-list>
|
||||
</layer-list>
|
||||
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 256 KiB |
@@ -29,6 +29,12 @@ Button.-primary {
|
||||
font-size: 18;
|
||||
}
|
||||
|
||||
/* Body/explanatory text in the onboarding flow; the theme default is too
|
||||
* small to comfortably read paragraphs of legalese, especially on tablets. */
|
||||
.body-text {
|
||||
font-size: 18;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stands in for the lens preview when showing it would be misleading (silent
|
||||
* mode, or a disconnect explained by a flat battery). Sized by the view model
|
||||
|
||||
|
After Width: | Height: | Size: 20 KiB |
@@ -25,11 +25,11 @@ export class DeviceInfoProbe {
|
||||
private resolveFn: ((info: DeviceInfo) => void) | null = null;
|
||||
private rejectFn: ((error: Error) => void) | null = null;
|
||||
|
||||
constructor(rightAddress: string) {
|
||||
constructor(rightAddress: string, leftAddress = "") {
|
||||
const context = Utils.android.getApplicationContext();
|
||||
if (!context) throw new Error("Android application context unavailable");
|
||||
|
||||
this.probe = new com.faceclaw.app.FaceclawDeviceInfoProbe(context, rightAddress);
|
||||
this.probe = new com.faceclaw.app.FaceclawDeviceInfoProbe(context, rightAddress, leftAddress);
|
||||
this.listenerProxy = new com.faceclaw.app.FaceclawDeviceInfoProbeListener({
|
||||
onLog: (line: string) => this.emit(this.logListeners, String(line)),
|
||||
onState: (state: string, detail: string) =>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ActionBar title="Configure Devices" />
|
||||
|
||||
<GridLayout rows="auto,auto,auto,auto,auto,auto,auto,auto,*" class="p-20">
|
||||
<Label row="0" text="Configure the MAC addresses for the G2 headset arms and optional R1 ring. This page does not test a connection." textWrap="true" />
|
||||
<Label row="0" text="Configure the MAC addresses for the G2 headset arms and optional R1 ring. This page does not test a connection." class="body-text" textWrap="true" />
|
||||
|
||||
<GridLayout row="1" columns="96,*" class="pairing-row m-t-12" visibility="{{ identityVisibility }}">
|
||||
<Image col="0" src="{{ identityImagePath }}" stretch="aspectFit" width="90" height="34" />
|
||||
@@ -34,7 +34,7 @@
|
||||
<Button col="1" text="Scan for glasses" tap="{{ onScanTap }}" class="-primary" isEnabled="{{ canDiscover }}" />
|
||||
</GridLayout>
|
||||
|
||||
<Label row="6" text="{{ status }}" class="m-t-16" textWrap="true" />
|
||||
<Label row="6" text="{{ status }}" class="body-text m-t-16" textWrap="true" />
|
||||
|
||||
<GridLayout row="7" columns="*,*" class="m-t-16">
|
||||
<Button col="0" text="{{ saveLabel }}" tap="{{ onSaveTap }}" class="-primary" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<StackLayout>
|
||||
<Label text="{{ headline }}" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<ActivityIndicator busy="{{ busy }}" visibility="{{ busyVisibility }}" class="m-t-16" />
|
||||
<Label text="{{ status }}" class="m-t-16 text-center" textWrap="true" />
|
||||
<Label text="{{ status }}" class="body-text m-t-16 text-center" textWrap="true" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ export class OnboardingFirmwareCheckViewModel extends Observable {
|
||||
}
|
||||
|
||||
this.disposeProbe();
|
||||
const probe = new DeviceInfoProbe(stored.right);
|
||||
const probe = new DeviceInfoProbe(stored.right, stored.left);
|
||||
this.probeInstance = probe;
|
||||
probe.onStateChange((state) => this.reportProbeState(state));
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Label text="{{ headline }}" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<ActivityIndicator busy="{{ busy }}" visibility="{{ busyVisibility }}" class="m-t-16" />
|
||||
<Progress value="{{ progress }}" maxValue="100" visibility="{{ progressVisibility }}" class="m-t-16" />
|
||||
<Label text="{{ status }}" class="m-t-16 text-center" textWrap="true" />
|
||||
<Label text="{{ status }}" class="body-text m-t-16 text-center" textWrap="true" />
|
||||
<Label text="{{ log }}" class="m-t-24" textWrap="true" fontSize="12" visibility="{{ logVisibility }}" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<GridLayout rows="*,auto" class="p-20">
|
||||
<ScrollView row="0">
|
||||
<StackLayout>
|
||||
<Image src="res://logo" stretch="aspectFit" height="140" horizontalAlignment="center" visibility="{{ logoVisibility }}" class="m-t-24" />
|
||||
<Label text="{{ headline }}" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<Label text="{{ tagline }}" class="text-center m-t-8" textWrap="true" visibility="{{ taglineVisibility }}" />
|
||||
<Label text="{{ body }}" class="m-t-24" textWrap="true" />
|
||||
<Label text="{{ tagline }}" class="body-text text-center m-t-8" textWrap="true" visibility="{{ taglineVisibility }}" />
|
||||
<Image src="~/images/faceclaw-logo.png" stretch="aspectFit" height="200" horizontalAlignment="center" visibility="{{ logoVisibility }}" class="m-t-24" />
|
||||
<Label text="{{ body }}" class="body-text m-t-24" textWrap="true" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Label text="Disconnect the Even App" class="h1 text-center m-t-24" textWrap="true" />
|
||||
<Label
|
||||
text="Faceclaw and the official Even Realities app can't both be connected to the glasses at once. Before continuing, open the Even app, go to Home, select your glasses, open the Connection submenu, and press Disconnect (or turn off the Even app's Bluetooth)."
|
||||
class="m-t-24" textWrap="true" />
|
||||
class="body-text m-t-24" textWrap="true" />
|
||||
<Button text="Open Even App Settings" tap="{{ onOpenEvenAppSettingsTap }}" class="-primary m-t-24" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||