Repository navigation
Identify beacons by 0x2080 service data; battery, rate colors, UI rework - #5
Merged
jappeace merged 8 commits intoJul 14, 2026
Merged
Conversation
Bump the hatter pin to the advertisement-payload branch (jappeace-sloth/hatter feat/ble-advertisement-payloads, to be repointed at jappeace/hatter master once #239 merges) and use the new payloads: - identifyScanResult now takes the 0x2080 service data payload and treats it as the primary KKM signal, exactly like KKM's own library; the MAC prefix and factory name remain fallbacks for payload-less frames. kkmExtDataBattery and kkmExtDataMac parse the payload per KBAdvPacketHandler.java/.swift (byte 0 battery clamped to 100; bytes 3..5 the MAC's low bytes when byte 1 is 0 and byte 2 the marker 1), which makes renamed beacons configurable from iOS and shows battery without connecting (both former TODO items). UI rework, all requested behaviours: - The app opens on a one-time permission page and moves itself to the scanner page when both permissions are granted; a denial keeps the page up naming the missing permission. - Start Scan checks the adapter first and refuses with a clear status while bluetooth is off/unauthorized/unsupported. - One scan button that toggles between Start Scan and Stop Scan. - Repeated advertisements refresh a listed beacon (RSSI, battery) and measure its advertisement interval (exponentially smoothed); the row is colored green when the measured rate matches the expected interval input within 25% and red when it deviates. - The "discovered" status is renamed to "found". The scan callback is clock-injected (onScanResultAt) so the tests drive rate measurement with fabricated times; 63 tests pass, including the permission page flow, the toggle, the adapter gate, rate smoothing and coloring, and the renamed-iOS-beacon path. The emulator test grows the permission-page step and a battery-on-row assertion. Prompt: hmmm, the app doesn't list the current pin rate, and didn't the original also show colors somehow (I don't remember). Right if the ping rate is above or below what's expected we'd see the line colored. also what does "discovered" mean? what happens if I press start scan twice? can we change start scan into stop scan after starting? also can we just make a permission page to deal with permission but once you've done them you move on to the next page and the permissons are no longer on screen. if you press start scan you also have to check the adapter, if the adapter is down show a message to the user and just don't start. / I suppose we've to address 238 first to even support this tool / well just go do the second part as well as soon as ci passes I'm going to sleep, we can repoint it at master tomorrow Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Style rule: no crossing wildcards in a pure decision function; the collapsed clauses hid no distinct outcomes but the enumeration is two lines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The emulator job died substituting the NDK toolchain from nix-cache.jappie.me (curl: failure receiving data from the peer); build and build-ios passed on the same commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Attempt 9 of the emulator run passed everything except the battery
assertion: assert_ui_text exact-matches a node's full text, and
battery shared its node with the nondeterministic measured rate
(" | 85% | ~200 ms"). Battery and rate are separate text nodes now,
and the script asserts the deterministic " | 85%".
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Hatter review rounds changed the advertisement API: service data is keyed by uuid-types' binary UUID and serviceDataForUuid takes the UUID value. The KKM ext-data constant becomes a total UUID.fromWords value (no literal can be malformed), replacing the text constant; the pin moves to the current fork head so CI proves the integration before the merge, leaving the post-merge repoint a hash-only change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Hatter's parser now carries the partial advertisement alongside the parse errors; the identity gate reads service data from the salvage too, so a beacon with one garbled structure keeps its valid 0x2080 identity and battery instead of degrading to the MAC-prefix fallback. Hatter's dispatch already logged the defects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review gate finding: the Left-branch salvage in scanResultExtData had no kbeacon-side coverage (hatter's tests cover hatter's parser, not this call site); reverting it to Nothing left the suite green. The new test feeds a malformed advertisement whose salvage carries the only identity source (opaque iOS address, non-factory name) and asserts the beacon lists with the ext-data MAC and battery; verified to fail exactly alone against the reverted branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same tree as the reviewed branch head, now via jappeace/hatter master. All advertisement-payload work this PR builds on is upstream. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Stacked on #4 (includes its commits until that merges). Pins hatter at the jappeace-sloth
feat/ble-advertisement-payloadsbranch (jappeace/hatter#239); repoint the pin at hatter master after #239 merges.Identity via service data (hatter #238 payoff)
identifyScanResultnow takes the0x2080service data payload and treats it as the primary KKM signal, exactly like KKM's own library. MAC-prefix and factory-name fallbacks stay for payload-less frames (e.g. a slot broadcasting pure iBeacon).kkmExtDataBattery/kkmExtDataMacparse the payload perKBAdvPacketHandler.java/.swift: byte 0 battery (clamped to 100), bytes 3..5 the MAC's low bytes when byte 1 is 0 and byte 2 is the marker 1. This makes renamed beacons configurable from iOS and shows battery without connecting, closing both former TODO items.UI rework (as requested)
Tests
onScanResultAt), so rate measurement and smoothing are tested with fabricated times; 63 tests pass covering the permission flow, toggle, adapter gate, coloring (via a widget-tree color walk), ext-data identity including the renamed-iOS path, and all previous behaviour. A sabotage run (EMA replaced by raw delta) failed exactly the smoothing test.Local verification:
cabal buildclean, 63/63 tests, shellcheck + py_compile pass. The emulator job runs in CI.🤖 Generated with Claude Code