Skip to content

[Part 3/6] fix(session): notification routing, sensorEnd on user stop, expiry guard, discovery timeout - #3

Open
ETolboom wants to merge 4 commits into
trioneer-dev:mainfrom
ETolboom:feat/transmitter-session-fixes
Open

ETolboom wants to merge 4 commits into
trioneer-dev:mainfrom
ETolboom:feat/transmitter-session-fixes

Conversation

@ETolboom

@ETolboom ETolboom commented Sep 24, 2026 •

Copy link
Copy Markdown

Five small correctness fixes from DexKit's G6 stack (running there with on-device testers, no reported issues):

  • Notification routing (PeripheralManager.didUpdateValueFor): the condition match shadowed the characteristic parameter, so any characteristic's update could satisfy a pending command; and unclaimed notifications (backfill frames) were dropped while a command was in flight.
  • .sensorEnd event when the user stops a session (simulator drain mirrors it).
  • transmitterExpirationDate stays nil until the first version read — a 180-day Anubis would alert as expired at day 90 against the fallback.
  • Discovery timeout 2 s → 10 s.
  • Nits: battery re-arm reads persisted state.lastBatteryReadDate; UInt16(clamping:) on the persisted expiry-days fallback.

Stacked on #2; only the top commit is new.

Testing

  • swift test: 80 tests passing.
  • The BLE routing and timeout changes merit a sanity pass on real hardware: normal connect cycle, backfill mid-command, user-initiated sensor stop.

Copilot AI lite review requested due to automatic review settings September 24, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ETolboom ETolboom changed the title [Part 3/N] fix(session): notification routing, sensorEnd on user stop, expiry guard, discovery timeout [Part 3/6] fix(session): notification routing, sensorEnd on user stop, expiry guard, discovery timeout Sep 24, 2026
OSLog.log handed the [CVarArg] array to os_log for 6+ arguments, which
reads garbage pointers for each %@ and segfaults in
_os_log_fmt_flatten_object_impl. The seven-argument "Backfill
acknowledged" line hit this on every backfill, crash-looping the app.

The fallback now asserts in debug and logs the pre-rendered line as a
single argument in release. The backfill ack line is collapsed to one
argument.
…ensor work in the simulator

Extract the pending-command logic into a pure CommandQueue value type
(supersede-on-enqueue, 5-minute stale-calibration drop, raw-value
persistence round-trip) with unit tests, and mirror didComplete into
enqueue on the simulator, where no link will ever drain the queue.

Also: stop simulated readings once no session is active, and mark
Locked.mutate @discardableResult (both copies).
…ard, discovery timeout

PeripheralManager.didUpdateValueFor: bind the condition's characteristic
and compare with == instead of shadowing the parameter (any
characteristic's update could satisfy a pending command's condition),
and forward unclaimed notifications to the delegate even while a
command is in flight (backfill frames were dropped mid-command).

didComplete(.stopSensor): emit a .sensorEnd persisted event before
clearing the session dates; the simulator drain path mirrors it.

transmitterExpirationDate stays nil until the first version read: the
fallback lifetime is a guess and a 180-day Anubis would alert as
expired at day 90.

Service discovery timeout 2s -> 10s. Battery re-arm reads the persisted
state.lastBatteryReadDate instead of a transient ivar that was nil after
every relaunch. UInt16(clamping:) for the persisted expiry-days Int
fallback, matching G6CGMManagerState.
@ETolboom
ETolboom force-pushed the feat/transmitter-session-fixes branch from 1138015 to 7762e90 Compare September 29, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants