Serialize G2 GATT ops for reliable packet delivery - #5
Open
aheschl1 wants to merge 1 commit into
Open
Conversation
Serialize every GATT op — characteristic writes on both legs and the descriptor writes that enable notifications — on one op thread, issuing each only after the stack reports the previous one retired. Replaces the fixed 8 ms pacing, which never covered single-packet command bursts and still lost packets on multi-packet ones (8.65% measured; 40% during connect+auth). Zero lost writes measured after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve G2 bluetooth reliability
Android GATT client
com.android.bluetoothallows only one packet in flight per connection. On boot-up, or heavy utilization times, many important packets don't get sent.The solution is to centralise and enqueue packets, and tick when the GATT stack.
Symptom
On boot about 50% of the times, it was noticed that calendar events didn't appear. Packets never got sent. This was due to a stampede at connect time.
Logs
Logs collected on G2 smart glasses
Comparison
flow both runs: connect, auth, dashboard, calendar sync, Mentra Maps.
Notes:
failcounter is now stricter: it counts writes refused by the stack or neverretired, versus refused-only before.
Raw log lines -
grep -E "BGCAP:|G2/GATT:"Before (HEAD)
Totals: ok=264 fail=25 (8.65% lost). First three lines are the connect+auth window: 12 of 30
writes lost (40%) while CCC descriptor writes and the auth sequence raced for the GATT slot.
After (this PR)
Totals: ok=300 fail=0 (0.00% lost). Connect+auth window is a single clean
ok=23 fail=0, andsustained bursts run at 35-38 writes/s with zero loss — throughput up, loss gone.
the large elapsed on each run's first line is a logging artifact