Skip to content

Advertise faults, survive garbled messages and stale connections - #22

Merged
ps2 merged 4 commits into
mainfrom
simulator-faults-and-reconnect
Oct 12, 2026
Merged

ps2 merged 4 commits into
mainfrom
simulator-faults-and-reconnect

Conversation

@ps2

@ps2 ps2 commented Oct 12, 2026

Copy link
Copy Markdown
  • Reject a garbled message instead of exiting. The pod told the phone the transfer failed, then exited, relying on run.sh to restart it. Nothing restarts it in the Simulator. The phone now just sends the message again.
  • Advertise the pod's fault and alerts. The 2nd service UUID becomes C00A on a fault (C005 for a firing alert), and the manufacturer data carries the fault code and alert slots, as real pods do. Loop's background scan for C00A now sees a simulated fault and wakes the app.
  • Give each connection its own packets. When the phone went away mid-message (Loop suspended in the background), the old message loop stayed blocked reading and took the first packet of the next connection's next message. The new loop then failed its checksum, and every later session failed the same way. Each connection now gets its own input channels, and a stopped loop's reads end. pkg/bluetooth/bluetooth_test.go covers it, and fails on the old code.
  • README: Loop treats a fault as final, so after clearing one from the control panel, relaunch Loop before testing another.

The first two commits were pushed to #21 after it had been merged, so they never reached main.

go test -race ./... passes, and it builds for GOARCH=arm. Tested against Loop in the Simulator through ImpossiBLE: a fault woke the suspended app, and sessions and status reads work after Loop is suspended mid-message.

ps2 added 4 commits October 12, 2026 11:59
The pod told the phone the transfer failed, then exited, relying on
run.sh to restart it. With nothing to restart it in the Simulator, a
relaunched Loop that sent a message the pod read garbled lost its pod.
The phone sends it again.
A paired pod's 2nd service UUID is C001 normally, C005 while an alert
fires and C00A on a fault, and its manufacturer data carries a status
word with the fault code and alert slots, as captured from real pods in
OmnipodKit. The simulator advertised neither, so Loop's connectionless
fault detection (a background scan for C00A, which wakes the app) never
saw a simulated fault. Faults and alerts set from the control panel or
by commands now show in the advertisement. paypal/gatt advertises no
manufacturer data, so over Bluetooth only the UUID changes.
Connected() stopped the message loop, but a loop blocked inside a
message only checked for that between messages. When the phone went
away mid-message (an app suspended in the background), the old loop
stayed blocked in ReadData and took the first packet of the next
connection's next message. The new loop read the rest out of step,
failed its checksum and told the phone FAIL, and every session after
that failed the same way.

Each connection now gets its own input channels, and the loop's reads
end when it is stopped.
OmnipodKit quiets its C00A fault scan once it detects a fault and only
lifts that when alerts clear or it pairs a new pod. A fault cleared from
the control panel leaves the scan off, so a second fault test needs a
relaunched Loop.
@ps2
ps2 merged commit 1ace0cf into main Oct 12, 2026
1 check passed
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.

1 participant