Pairing, re-pairing and the full new-cartridge setup¶
Bench hardware only. Never connect TwiistOff to a pump that is attached to a person. Saline/water only for any delivery test. This is an unofficial research app, not a medical device.
This is the complete procedure for getting a Twiist pump from "nothing" to a working, basal-running TwiistOff session, including the part that happens outside TwiistOff (registration) and the parts that are still unknown.
Related: Bonding and export Β· Bench testing Β· REST API Β· What a driver needs.
1. What TwiistOff can and cannot do¶
| Stage | TwiistOff | Evidence / note |
|---|---|---|
| Enter pairing mode | π€ you do it physically | Cassette off + battery reset (power cycle); see Β§2. A button hold only opens an advertising window; it does not start pairing. |
| Scan + connect | β | Pump appears in the scan (often tens of seconds after the scan starts); serial-shaped name / company ID 0x026B. |
| Bond (label PIN) | β | LE Secure Connections Passkey Entry; ~7-8 s OS-level pairing. Verified live from the bridge 2026-11-27. |
| Registration (LTSS + replacement blob) | β external | Done by the vendor's app and service, which issue the pump a signed credential blob and its key (LTSS). TwiistOff has no network path and must not be given cloud credentials. The stage is shown as an external BLOCKED step with the reason. |
| Import the resulting blob + LTSS | β | Blob saved in app prefs, LTSS in prefs; POST /setup/blob?confirm=true, POST /setup/arm; see Β§4. |
| Arm the encrypted session | β | MTU 247, e5332024 salt + e5332023 start sequence, arm byte, sealed pumpStatus handshake. |
| Attach the cassette (self-test) | π observed | Pump-driven, started by attaching a cassette (no command): pumpStatus byte 15 ramps to 100 % in ~11 s, pumpState 0x0009 while running / 0x0029 complete on an unconfigured pump. There is no separate self-test notify protocol: byte 15 is the whole signal (Β§3). |
| Declare fill (new cassette) | β verified | resetPrime 0x8903 then setStartingCassetteVolume 0x8003; 300 U = wire 30 75. The pump shows 10 U less than declared (300 U reads as 290.00 U); 0x8002 corrects the volume later. Bench-verified from TwiistOff 2026-12-02 (POST /setup/fill). |
| Prime / stop prime / prime complete | β verified | 0x8900 β 0x8901 β 0x8902; primingStatus 2 β 3 β idle, pumpState 0x0029 β 0x0039. Prime complete is accepted only at priming state 3 (minimum volume met); otherwise prime more. Bench-verified from TwiistOff 2026-12-02 (~1.76 U per 5 s push). |
| Configure pump (20 settings writes) | β wizard step | Pairing mode clears the pump's settings (and its prime), so this is needed after every pairing, not only on a new pump. A pump answers verify 00 until its settings are written (configurationState 0 β 0x1FFF). Configure pump writes all 20 of the app's stored settings in one run and re-verifies (Setup and recovery Β§6.0). |
| Verify settings + start basal | β verified | 0x800F must answer 01, then 0x8100 with the 42-byte record; basal running confirmed by the reservoir counting down (2026-12-02). Starting at a rate that differs from the stored basal pattern first rewrites the pattern to that rate all day, after a confirmation. |
| Recover after a cassette removal / occlusion | β verified | alarmReset β restart β automatic re-arm β verify β startBasal, no fill, no prime on the same cassette; the Alarm recovery wizard walks it (Setup and recovery Β§6.2β6.3). |
| Optional cannula fill / stop | π§ͺ commands built, not bench-tested | 0x820A (0.70 U = 46 00 00) and stop 0x8202 (not bench-verified). |
| Registration / obtaining the LTSS | β | External; see Β§7. |
| A blob written by TwiistOff being adopted | π§ͺ built, not bench-tested | The write format is known (Β§9); TwiistOff's framed write has not been run on the pump yet. |
Everything above is shown live on the Connect page and the Cassette set-up wizard, which follow the passive
pumpStatus stream and are peer drivers of the same stages as the REST bridge β tap on the phone
or script it over HTTP and the other side sees the same state. Ordering is enforced by the state
machine (pump/PairingFlow.kt), not by the driver.
2. Physical pairing mode (what actually happens)¶
Entering pairing mode has four visible signs:
- The pump power-cycles. The battery reading jumps (a fresh or reinserted cell) and the pump's clock comes back unset.
- The pump appears late in the scan β often tens of seconds after the scan starts, because it does not advertise until it has rebooted.
- The cassette is off, and the pump reports it (
Cassette removed in unexpected state) as the self-test starts. - The pump drops its old bond. On the next connect the phone reports that the peer removed its pairing information.
So: remove the cassette, then remove/reinsert the battery. The pump boots into its pairing/onboarding state, self-tests, and only then advertises. A plain button hold opens an advertising window on an already-paired pump, but it is not how the full setup starts. After a link drop a bonded phone reconnects to the pump directly, with no scan and no button press (Β§7).
Materials / physical steps:
- Pump with a charged battery (a fresh cell makes the power-cycle signature obvious).
- Cassette OFF for pairing mode and bonding. Attach it once the session is armed: attaching it starts the pump's self-test.
- The pump label with its serial and 6-digit PIN (the label barcode encodes them as
21+ serial +24+ PIN). No command carries the barcode to the pump; TwiistOff cannot scan it, so type the serial/PIN from the label by hand. - For the cartridge phase: a new cassette + saline, an infusion set (or skip cannula fill on the bench), and the cassette's GS1 label (app-side only, never sent to the pump).
- To re-pair, remember: a pump-side pairing reset erases the old bond for every phone, including the vendor's app. TwiistOff can only remove its own Android bond ("Forget bond"). Re-pairing with the vendor's app later typically uses up a cassette β plan it with a cassette change.
The pump advertises in windows, so start the scan promptly after the reset and keep the link alive once connected.
3. The two phases of a first pairing¶
A first/forced pairing is two phases, not one:
Phase A β pair, bond, register:
physical battery/cassette reset (cassette off)
-> scan (pump appears late) -> connect
-> GATT discovery (DFU FE59 + app service E5331FE0), CCCDs
-> bond: OS-level LE SC passkey entry with the label PIN (~7-8 s)
-> registration (external): the pump receives a signed credential blob, and the phone holds the
matching key (LTSS)
-> session up: read the session salt (e5332024) + starting sequence (e5332023), arm, sealed pumpStatus
The blob is stored on the pump and can be read back over e5332027 (243/243/123-byte packets plus a
packet-255 status byte) before any session key exists, on the bonded but unarmed link.
Phase B β cassette set-up:
attach the cassette -> self-test: pumpStatus byte 15 10 -> 100 %, pumpState 0x0009 while running
-> fill the cassette, declare 300 U:
resetPrime 0x8903 -> setStartingCassetteVolume 0x8003 (wire 30 75)
confirmation: reservoir jump (e.g. 240.78 -> 290.00 U), cassetteAge 0, insulinRemaining 96 %
-> startCassettePrime 0x8900 (primingStatus 2; primeVolume ramps ~1.76 U per status)
-> drops at the cannula end -> stopPrime 0x8901 (primingStatus 3 = minimum volume met;
1 = not met yet: prime more) -> primeComplete 0x8902 (pumpState 0x0029 -> 0x0039)
-> configure: all 20 settings writes (configurationState 0 -> 0x1FFF), see
Setup and recovery Β§6.0
-> verifyTherapySettings 0x800F -> 01 -> startBasal 0x8100 with the 42-byte record
(pumpState -> 0x007B)
-> optional cannula fill 0x820A
What TwiistOff does with this: phase A's local parts (scan/connect/bond, LTSS import, arm) are
implemented; registration is external and shown as such. Phase B is the Cassette set-up wizard
(Β§5), confirm-gated, and was walked end to end on the bench on 2026-12-02. The self-test is
passive: TwiistOff shows byte 15 from pumpStatus, and the self-test itself starts when the
cassette is attached.
4. Getting your blob and LTSS into the app¶
TwiistOff cannot create these values (phase A registration is external). They are per-pump material from your own pump's registration. They are deliberately not in this repo, never committed, and no route returns them once imported. Do not post them publicly.
Import on the phone (Connect page / Advanced) or from a computer through the debug bridge β both persist locally in prefs and survive restarts:
adb forward tcp:8090 tcp:8090
# 1. Replacement blob (608-610 bytes hex). Preview first, then save IN THE APP (no pump write):
curl -s -X POST "http://127.0.0.1:8090/setup/blob?blob=$(cat replacement_blob.hex)"
# -> {"ok":true,"stage":"preview","stored":false,"requires":"confirm=true","blob":{...}}
curl -s -X POST "http://127.0.0.1:8090/setup/blob?blob=$(cat replacement_blob.hex)&confirm=true"
# -> {"ok":true,"stage":"stored","stored":true,"blob":{...},"snapshot":{...}}
# 2. LTSS (16 or 32 bytes hex; stored and used to arm):
curl -s -X POST --data "$LTSS" "http://127.0.0.1:8090/setup/arm"
# -> 200 {"ok":true,"action":"arm","result":"armed (startSeq=...)", "snapshot":{...}}
# or 409 {"ok":false,"error":"blocked at BOND: ...", "snapshot":{...}} until connected+bonded
# 3. Check what the app holds (metadata only; never returns the blob or the LTSS):
curl -s http://127.0.0.1:8090/setup
In the app: the Arm (LTSS) block on the Connect page takes the LTSS, and Advanced β Provisioning
blob reviews a replacement blob and writes it under a two-step confirm (POST /setup/blob is the
import-and-persist route). Saving the blob touches nothing on the pump. Without these values,
TwiistOff cannot arm a session with the pump (see Β§7).
5. Setup in the app, step by step (what a user experiences)¶
The Connect page is one vertical list of gated blocks (Scan β Connect β Bond β MTU 247 β Registration β Arm β Ready). The Cassette set-up wizard (Menu β Cassette set-up) carries the cassette steps. Pairing mode clears the pump's settings and its prime, so after a pairing the pump is unconfigured and unprimed: once the session is armed and the first status shows that, Connect hands straight into the cassette set-up wizard.
GET /setup reports wizardStep / wizardStepCount on an 11-stage numbering: 1 pairing mode +
connect, 2 bond, 3 check registration, 4 arm, 5 attach the cassette (self-test), 6 fill, 7 prime and
prime complete, 8 configure pump, 9 verify and start basal, 10 cannula fill (optional), 11 ready. Each
control calls the same SetupRunner method as its REST endpoint, so a later action is disabled on screen
and refused by REST with 409 blocked at <STAGE>: <reason> until the earlier stage is done.
The cassette set-up wizard¶
One page, one card per step; the current step is highlighted and the page opens on the step the pump is actually at (after an app restart, a re-arm or a pairing), because each step reads the pump's own state. A Where the pump is now card shows pump state, configuration, reservoir and basal.
- Attach the cassette (pump self-test). Attach it firmly; the pump self-tests it by itself (it
beeps; about 10 s;
pumpState0x0009while it runs). TwiistOff sends nothing here. In cassette-change mode (0x0400) the pump does not self-test until it restarts: use the cassette-change recovery. - Fill: declare the cassette volume. Fill the cassette, enter how much you put in (default
300 U) and Declare fill:
resetPrime 0x8903thensetStartingCassetteVolume 0x8003. The pump cannot measure the fill; it counts down from this number, and it shows 10 U less than you declare (300 U shows as 290 U). The page shows that figure before you confirm. - Prime. Hold the tubing end over a tissue and Start prime (
0x8900). The prime runs until you stop it, at about 0.35 U per second. - Drops β stop, then prime complete. The live primed volume is shown large, with a large
DROPS β STOP button (
stopPrime 0x8901): press it as soon as drops form at the cannula end. Then Drops formed: prime complete (0x8902) β accepted only at priming state 3 (stopped with the pump's minimum volume met). At state 1 (stopped too early), or if no drops formed, No drops yet: prime more starts the prime again. - Configure pump. Writes this app's stored settings, all 20, in order, then re-verifies, and lists
each write as accepted or refused (Setup and recovery Β§6.0).
Review settings opens Therapy settings. Done when
configurationStateis0x1FFFand verify did not answer00. - Verify and start basal. Verify sends
verifyTherapySettings 0x800F, which must answer01. Enter the basal rate (prefilled when the stored pattern is one rate all day) and Start basal: if the rate differs from the stored basal pattern, the confirmation says so and the app first sets the pattern to that rate all day (one0x8019write), then verifies and sendsstartBasal 0x8100. Nothing is rewritten without that confirmation. - Fill cannula (optional). After basal starts: Fill cannula 0.70 U (
0x820A) for a newly inserted infusion set, STOP CANNULA FILL (0x8202), or Skip on the bench.
On a cassette that is already set up, the page offers Suspend delivery and Change cassetteβ¦
(cassetteChange 0x8804, then the cassette-change recovery: the pump takes a new cassette after it
restarts). When the pump is not primed it offers Start a new-cassette set-up, which makes fill and prime
required even if the pump later reports an old prime.
Stage reference¶
| Stage | You do physically | Where in the app | REST equivalent | Succeeds when |
|---|---|---|---|---|
| Pairing mode + connect | Remove the cassette, remove/reinsert the battery (pump power-cycles), then pick the pump | Connect β Scan, Connect blocks | POST /setup/scan, POST /setup/connect?address= |
Link CONNECTED |
| Bond | Enter the 6-digit label PIN in the dialog | Connect β Bond (label PIN) | POST /setup/bond?pin=NNNNNN |
bond state BONDED |
| MTU | β | Connect β MTU 247 (already 247 on a bonded reconnect: nothing to do) | POST /mtu?value=247 |
MTU 247 |
| Check registration | Nothing (or register the pump with the vendor's app if it is fresh) | Connect β Registration: Detect (read-only), Read blob back, or Skip β already registered | POST /setup/registration?detect=true, POST /setup/registration?ack=true®istered=true/false, POST /setup/blob?...&confirm=true, POST /setup/write-blob?confirm=true |
Detected via e5332027 packet-255 status (0x00 registered / 0x09,0x0A fresh); advances only after your explicit choice β never silently skipped |
| Arm | Paste your LTSS (from the pump's own registration) | Connect β Arm (LTSS) β Arm channel | POST /setup/arm (body LTSS, or empty = stored LTSS) |
armed:true; a sealed pumpStatus arrives |
| Attach the cassette | Attach the cassette; hands away, wait | Cassette set-up β step 1 | POST /setup/selfcheck (passive) |
byte 15 = 100 %; pumpState 0x0029 (unconfigured) or 0x002B (configured) |
| Fill | Cassette attached and filled with saline | Cassette set-up β Declare fill | POST /setup/fill?units=300 (sends resetPrime 0x8903 then 0x8003) |
reservoir reads ~290.00 U, cassette age 0 |
| Prime | Tubing end over a tissue; keep DROPS β STOP reachable | Cassette set-up β Start prime β DROPS β STOP β Drops formed: prime complete (or prime more) | POST /setup/prime, POST /setup/stop-prime, POST /setup/prime-complete |
primingStatus 2 β 3 β idle; prime-done bit set |
| Configure pump | β | Cassette set-up β Configure pump (also Therapy settings β Rewrite all settings to the pump) | POST /setup/configure |
configurationState 0x1FFF; verify answers 01 |
| Verify and start basal | β | Cassette set-up β Verify, Start basal at the chosen rate | POST /setup/verify, POST /setup/basal[?rate=&setPattern=true] |
verify 0x800F = 01 then 0x8100 accepted; basal > 0; pumpState 0x007B |
| Fill Cannula (optional) | Attach an infusion set if used | Cassette set-up step 7, or Pump Menu β Fill Cannula 0.70 U | POST /setup/cannula-fill?units=0.7, /setup/stop-cannula-fill |
handled or skipped (never blocks) |
| Ready | Disconnect; never leave armed | Connect β Ready block / Disconnect | POST /disconnect |
DISCONNECTED; GET /setup complete:true |
A wrong LTSS never leaves a session armed: the pump's frames simply do not decrypt and arm reports failure. Prime/basal/fill move the pump β the stop controls are never gated, and pulling the battery always stops delivery.
6. Drive the whole flow over REST (copy-paste script)¶
The UI is a peer driver, not a wrapper: both call the same SetupRunner methods (source ui
vs rest) and the same PairingFlow ordering. Each POST /setup/* returns the new snapshot
({"ok", "action", "result"|"error", "snapshot"}); out-of-order actions return HTTP 409 with a
blocked at <STAGE>: <reason> error, so a script can chain and inspect instead of guessing.
snapshot.driver shows the last action and whether ui or rest ran it.
BASE=http://127.0.0.1:8090
JS() { curl -s "$1"; }
PJ() { curl -s -X POST "$1"; }
gate() { JS "$BASE/setup" | tr ',' '\n' | grep -A4 "\"$1\":{"; }
# 0. the snapshot: stage, progress, per-action gates, live pump fields, last driver
JS $BASE/setup
# 1. scan + connect (pump was just battery-reset with the cassette off)
PJ $BASE/setup/scan
sleep 20
JS $BASE/setup # devices[] lists candidates; takes tens of seconds to appear
PJ "$BASE/setup/connect?address=AA:BB:CC:DD:EE:FF"
# 2. bond with the label PIN (the passkey dialog may also appear on the phone)
PJ "$BASE/setup/bond?pin=NNNNNN"
sleep 10; JS $BASE/bond # bondState 12 = bonded
# 3. registration PAUSES (never silently skipped): detect the pump's stored-blob state, then
# record the operator's choice. 0x00 = already registered (normal), 0x09/0x0A = fresh pump.
PJ "$BASE/setup/registration?detect=true"
PJ "$BASE/setup/registration?ack=true®istered=true" # "already registered - skip"
# For a fresh pump: register it with the vendor's app first, then ack with registered=false.
# If you hold the pump's LTSS/blob, import them (blob is stored locally; no pump write):
PJ "$BASE/setup/blob?blob=$(cat replacement_blob.hex)&confirm=true"
curl -s -X POST --data "$LTSS" "$BASE/setup/arm" # (POST body = LTSS hex)
# 4. attach the cassette now: that starts the pump's self-test (no command).
# self-check observes it (passive; waits up to 15 s for byte 15 == 100 %)
PJ $BASE/setup/selfcheck
# 5. cassette set-up (cassette attached and self-tested)
PJ "$BASE/setup/fill?units=300"
PJ $BASE/setup/prime
PJ $BASE/setup/stop-prime # when drops form at the cannula end
JS $BASE/setup # pump.primingStatus 3 = minimum volume met; 1 = prime more
PJ $BASE/setup/prime-complete # only after the operator confirms drops formed, at priming state 3
PJ $BASE/setup/configure # all 20 stored settings, then verify; check every write was accepted
PJ $BASE/setup/verify # must say verify=01
PJ $BASE/setup/basal # the stored basal pattern
# or: PJ "$BASE/setup/basal?rate=2.0&setPattern=true" # sets the pattern to 2.00 U/h all day first
PJ "$BASE/setup/cannula-fill?units=0.7" # optional
PJ $BASE/setup/stop-cannula-fill # safety path, always allowed when armed
# 6. release
PJ $BASE/disconnect
Notes: the wizard is a peer driver, not a wrapper β it calls the same SetupRunner methods and
the snapshot's driver line records which side (ui/rest) ran the last action, so you can drive
half from a script and half from the phone. GET /setup never returns the blob or LTSS (metadata
only) and includes wizardStep, registration {detectedState, acknowledged},
therapyVerifyMismatch, and pump.primeVolumeUe2. Stop actions (/setup/stop-cannula-fill) are
never ordering-gated on an armed session β one tap, like the delivery STOP buttons.
POST /setup/write-blob needs confirm=true and an armed session. POST /setup/basal refuses with an
explicit error when 0x800F answers 00 (configure, or import the settings this pump holds, then
retry), and refuses a rate that differs from the stored basal pattern unless setPattern=true.
7. Registration (external)¶
Registration happens outside TwiistOff: the vendor's app and service issue the pump a signed credential blob (stored on the pump) and its key (LTSS), which the phone uses to arm the encrypted session. A pump that has never been registered has no stored blob.
TwiistOff makes no network calls and has no cloud credentials, so registration is impossible here and the wizard pauses instead of guessing. What it does:
- Detect the pump's state read-only: enable the
e5332027notify CCCD and read the stored-blob framing; the packet-255 status byte is0x00when a stored blob exists (already registered) and0x09/0x0A(no data) on a fresh pump. The wizard shows the result and asks you to choose: Skip β already registered (the normal case for a registered pump), or register a fresh pump with the vendor's app first and then continue. It is never silently skipped. - Accept the LTSS (
POST /setup/arm, stored locally) and the blob (POST /setup/blob?confirm=true, stored locally), so you can carry on from the BLE side. - Read the stored blob back, and write a blob to the pump (
POST /setup/write-blobon an armed session;POST /pump/replacement?unarmed=trueorPOST /pump/registration-handshakein pairing mode, MTU 247, fresh bond). The write sends the blob plus its CRC32 as packet-numbered packets (Β§9). TwiistOff's earlier unframed writes were never adopted; the framed write is not yet bench-tested. - Readback rule: treat a write as accepted only when the pump's standalone
FF|statusafter the last packet isFF 00(FF 02= the transfer check failed,FF 01= bad signature; theFF|statusthat ends a stored-blob push is not the ack), and as adopted only when a later readback (trigger write + notify, MTU 247) returns the new blob.
If your pump has never been registered, you cannot finish phase A in TwiistOff. Register it with the vendor's app, then import the LTSS/blob here.
8. Re-pairing the same pump (LTSS already known)¶
Same stages as Β§5, without the registration work if the pump is already registered: physical battery/cassette reset β scan/connect β bond with the label PIN β import/keep LTSS β arm β attach the cassette (self-test) β fill β prime β drops β stop β prime complete β configure β verify / start basal. The LTSS is remembered on the phone. Pairing mode clears the pump's settings and its prime, so configure is part of every re-pairing; Connect hands straight into the cassette set-up wizard.
On 2026-11-30 the same key still armed the pump after the pump was registered again; no LTSS rotation was observed β that is an observation, not proof the key never rotates.
8.1 The settings live only in the app¶
The pump cannot read its therapy settings back. The copy in TwiistOff is the only one, and
verifyTherapySettings only answers whether the pump's settings equal it. So when you change phones
or reinstall the app, bring the settings with you:
- On the old phone: Therapy settings β Export to file (or Share). The export is one JSON
object (
"format": "twiistoff-pump-settings","version": 1, then every setting with patterns as arrays of wire values); it holds no key and no pump identifiers. Over REST:GET /settings/export. - On the new phone: Therapy settings β Import file (or Paste), or
POST /settings/importwith the export as the body. Importing changes only the app. On a new phone every setting is marked "not written", because nothing is known yet about what the pump holds. - Connect and arm, then Verify.
01means the pump already holds these settings, and it clears the mark of the 11 settings verify proves. The other nine (the pump-idle alert, low-insulin and walk-away alerts, audio, CGM signal-loss alert, cassette reminder, CGM sleep schedule, closed loop, CGM info) verify cannot check: Write N unwritten writes them, and the pump takes them while basal runs.00means the pump's settings differ: Rewrite all settings to the pump (Configure), or find the export that matches.
Without an export, the app starts from its bench defaults, and verify answers 00 on a pump that was
configured with other values. If the pump was set up with the bench replay values, load that preset
instead of rewriting.
8.2 A new phone or a reinstall¶
The New phone or reinstall wizard (Menu β Set-up & recovery wizards) walks it:
- A reinstall on a phone that is still bonded only needs the key: enter the pump's LTSS (16 bytes, 32 hex characters; stored on this phone only), arm, import the settings export, verify, start basal.
- A new phone has to bond, and bonding needs the pump's pairing mode (cassette off, battery out and in). Pairing mode clears the pump's settings and prime, so after bonding, entering the key and arming, the full cassette set-up follows, with Configure writing the imported settings.
8.3 Reconnecting after an app restart¶
The pump keeps delivering on its own while the app is closed, updated or restarted; only the link and the session end. TwiistOff remembers the pump it last armed (its Bluetooth address and advertised name, stored on the phone next to the key), and when it starts with a remembered pump and a stored key it reconnects and re-arms by itself:
- Connect to the remembered pump: the bonded device first (the bond holds the pump's identity address; the advertising address rotates), a short scan only if that fails, taking only a pump that advertises the remembered name.
- Registration: recorded as already registered.
- Arm with the stored key (the arm requests MTU 247).
- First status, then readiness: Connect shows the verdict, e.g.
CAN DELIVER; delivering basal 2.00 U/h.
This is link set-up only. Nothing that changes delivery or settings is sent: a running basal, a temp basal or an alarm on the pump carries on and is shown as it is. If the first status shows the pump unconfigured or unprimed (after pairing mode, for example), the app hands over to the cassette set-up wizard, as it does after a manual arm.
A failed try is followed by a wait of 20 s, 60 s, then 180 s; after four tries it stops and a
Reconnect failed banner says why, with a Reconnect button. While it runs, a banner shows the
stage and the try. On Connect, the Previous session block shows the remembered pump, each stage as
it runs, Reconnect (run it now), Stop, the Reconnect at start-up switch (on by default; off
means the app waits for you after a start) and Forget this pump (the app stops reconnecting to it;
the key and the bond stay, and arming once remembers it again). Over REST: POST /setup/reconnect,
POST /setup/auto-reconnect?enabled=, POST /setup/forget-pump, and the reconnect object in
GET /setup and GET /status (REST API).
When it turns itself off. A reconnect that finds the pump no longer matching this phone's session stops at once and turns Reconnect at start-up off, so a fresh pairing can go ahead without the app reconnecting over it:
- Android no longer holds a bond with the pump, or the pump asks the phone to pair again (pairing mode, the bond was removed, the pump was reset or paired with another phone). The app declines the pairing request it would otherwise leave waiting.
- The pump answers with a GATT authentication or encryption refusal (bonding required).
- The pump does not accept the stored key on two tries in a row (the arm gets no status sealed with the new session keys): it was reset, re-paired or registered elsewhere, or the key is for another pump. One refusal alone is retried after the usual wait.
- No valid key is stored.
A banner, Automatic reconnect turned itself off, says which of these it saw, with Turn back on and Keep off (keeps it off and clears the banner). The Previous session block on Connect shows the same reason. A pump that is only out of range, a connect that times out, or a link that drops does not turn it off: those are retried with the waits above and end in Reconnect failed.
Turning it off by hand. Some tests need the link to stay down after a restart (walking away from the
pump, for example). Switch Reconnect at start-up off on Connect (Previous session) or on the Menu
(Session), or POST /setup/auto-reconnect?enabled=false; GET /setup shows autoReconnectEnabled. A
manual scan, connect or bond (on Connect or over REST) also stops a run that is in progress, without
changing the setting.
A phone that stored the key before the app remembered pumps adopts its one bonded pump at the first start of a build that does, so it reconnects without a manual arm. This check runs once, so a pump forgotten later stays forgotten.
9. Open questions: blob adoption and pump binding¶
| Question | Status | Note |
|---|---|---|
| How must a blob be written for the pump to adopt it? | ANSWERED | Packet-numbered writes [n \| data], n from 1, with response, over the blob plus its CRC32 (IEEE, little-endian): 244/244/128 bytes for 609. The pump answers FF 00, and a readback then returns the new blob. Without the packet numbers the first byte reads as the readback trigger; without the CRC32 the pump answers FF 02. |
| Does TwiistOff's framed write get adopted? | OPEN | Built (ReplacementData.framedChunks); not yet run on the bench pump. Its earlier unframed writes (armed 2026-11-30, pairing mode 2026-12-01 and 2026-12-04) were not adopted. |
| Does the pump bind its credentials (blob + LTSS) to one unit? | OPEN | Unknown. |
10. Troubleshooting¶
Moved to Troubleshooting.
11. What TwiistOff does not do¶
- Registration (LTSS + replacement blob) for a first/forced pairing: Β§7. Always external.
- Read the pump's settings back β the pump cannot report them; keep the app's export (Β§8.1).
- Write settings silently. When verify answers
00, TwiistOff says so and offers Configure; it never rewrites the pump's settings, or the basal pattern, without the operator's confirmation. - A bench-proven blob write β the framed write is built but not yet run on the pump (Β§9).
12. Evidence trail¶
- Physical pairing mode (Β§2): observed on the bench pump.
- Live bench writes from TwiistOff: a 609-byte blob written unframed on an armed session
(2026-11-30) and in pairing mode (2026-12-01, 2026-12-04), off-body saline bench; none adopted.
The framed format (packet numbers + CRC32) answered
FF 00and read back as the new blob on the same bench pump on 2026-12-04. - Fresh pair β running and cassette/occlusion recovery: walked on the saline bench on 2026-12-02
over the
/setup/*and/pump/*routes (Setup and recovery Β§6.1β6.2). - Pump binding: open (Β§9).
- TwiistOff implementation:
pump/PairingFlow.kt(stage list + ordering gates),pump/SetupRunner.kt(shared executor for UI and bridge),pump/PumpSettings.kt+pump/SettingsStore.kt(the stored settings, configure writes, export / import),ui/pages/SetUpScreen.kt(the cassette set-up wizard),ui/pages/RecoveryScreen.kt(recovery hub and wizards),bridge/RestBridge.kt(GET /setup,POST /setup/*,/settings*,/recovery*),pump/PumpLink.kt(arm/status),pump/ReplacementData.kt.