Skip to content

Delivery

Bench hardware only. Everything here can start or change insulin delivery. Use it only with pump hardware that is not connected to any living subject. See bench testing.

7. Delivery

All verified on an off-body saline bench. Amounts below are what the pump reported back.

Command Opcode State Notes
startBasal 0x8100 ✅ Verified Therapy; therapy number + 42-byte record
stopBasal 0x8103 ✅ Verified drops basal to zero; also ends a running temp basal and stops a running bolus (see below)
temporaryOverrideBasal 0x8102 ✅ Verified absolute U/h temp basal; verified live 2026-11-30 end to end (the driver primitive)
temporaryModifyBasal 0x8101 ✅ Verified percent temp basal, 0–200 % of the basal pattern; 201 % and above refused 0x13EE
stopTempBasal 0x8104 ✅ Verified cancels either form; verified live 2026-11-30
Bolus calculator / deliver 0x8400 ✅ Verified the calculator message is also the delivery command
stopNormalBolus 0x8200 ✅ Verified stops an in-flight normal bolus
stopExtendedBolus 0x8201 ✅ Verified therapy number only → 0x8281; stops a running extended part. The extended (dual) bolus is started by 0x8401 with its extended amount and minutes; both parts share one bolus id
stopCannulaFillBolus 0x8202 ✅ Verified stops a running cannula fill (answers 0x8282; a no-op when nothing runs). The fill itself is capped at 0.70 U (0.71 U and above are refused 0x13EE)
startCannulaFill 0x820A ✅ Verified Therapy; volume UE2 (e.g. 0.70 U = 0x0046) + u8 reason (0 normal, 1 site replacement) → 0x828A; at most 0.70 U; refused 0x13ED with basal stopped

Temporary basal (0x8102 absolute / 0x8101 percent / 0x8104 stop) — verified live 2026-11-30

All three commands are Therapy commands, so the value below is sent after the 2-byte therapy number. Verified on the bench pump (saline, off-body); every claim here was measured on the bench.

0x8102 temporaryOverrideBasal : token(2) || rate_UE2PerHour(2 LE) || duration_minutes(2 LE)
0x8101 temporaryModifyBasal   : token(2) || adjustmentPercent(2 LE) || duration_minutes(2 LE)
0x8104 stopTempBasal          : token(2)

Responses: 0x8182, 0x8181 and 0x8184, each a 4-byte TherapyResponseMessage (echoTherapyNumber u16 | nextTherapyNumber u16), i.e. the next token is the last two bytes.

Measured pump limits (outside → NACK 0x13EE NackRangeCheckFailed):

Field Accepted Refused (measured) NACK debug fields
absolute rate 0.00 (special zero rate) or 0.10 U/h up to the configured max basal (22.00 U/h at most) 0.01–0.09 U/h, above max basal debug1 = duration, debug2 = rate, debug3 = max basal rate
percent 0–200 % of the programmed pattern (0 % is a zero temp basal) 201 % and above duration, percent, max basal rate and the programmed rate
duration 30–1440 minutes 29, 1441 minutes debug1 = duration, debug2 = rate, debug3 = max basal rate

The absolute limit is the max basal set with setDeliveryLimits, not a fixed 22.00 U/h: with max basal 10.00 U/h a 10.01 U/h temp is refused (debug2 = 1001, debug3 = 1000) and 10.00 U/h is accepted. A refused temp is not logged.

Behaviour measured on the bench:

  • Set: accepted from a configured pump (configurationState 0x1FFF) in a fresh session, with no in-session verifyTherapySettings (see §6). The next pumpStatus already showed the effect.
  • Replaced: a second temp-basal command while one is running — either form, even with the same parameters — is refused with NACK 0x13ED NackBadSequence (debug1 = 13). Cancel first (0x8104), then set the new one. 0x8104 is accepted even when nothing is running.
  • Cancelled: 0x8104 answered 0x8184; the next status cleared bytes 41/46-51/68-69 and the basal rate returned to the programmed pattern value (2.00 U/h in the test).
  • Expired: the temp basal ends by itself when the duration runs out; pumpStatus bytes 48-49 count down each pump minute and the pump logs the same end-of-temp-basal records as a cancel (0x00E2, 0x0057, then 0x0053/0x007C with mode 1). Measured mid-run and after expiry on 2026-11-30.
  • Zero temp basal: a 0 % or 0 U/h temp basal is still a running temp basal (bytes 46–51 set) with a basal rate of 0 — no insulin until it ends or is cancelled. Report it as a zero temp basal, not as "basal stopped": TwiistOff's readiness says "CAN DELIVER; zero temp basal running, N min left" and a warning banner says the same.

TwiistOff: the Adjust page sets either form (U/h, or % of the pattern), and POST /pump/temp-basal takes rate= or percent=. Both are checked against the limits above before anything is sent.

pumpStatus during a temp basal (verified values):

Field Absolute 0x8102 (0.50 U/h on a 2.00 U/h pattern) Percent 0x8101 (50 % on 2.00 U/h)
byte 41 netBasalRate_percent (i8) -75 -50
bytes 42–43 basalRate_UE2 50 = 0.50 U/h (actual delivered rate) 100 = 1.00 U/h
bytes 46–47 requested minutes 30 30
bytes 48–49 remaining minutes counts down 30 → 0 same
bytes 50–51 tempBasalModifier_percent 0 (absolute override) 50
bytes 68–69 netBasalRate_UE2PerHour (i16) -150 (-1.50 U/h delta) -100

Pump-log records observed for temp basal (raw types; the labels are descriptive):

Type Size Data Meaning
0x0055 4 rate_UE2PerHour u16 \| duration_minutes u16 absolute override started (the 0x8102 value)
0x0056 4 percent u16 \| duration_minutes u16 percent modify started (the 0x8101 value)
0x0057 2 0000 temp basal ended (cancel or expiry)
0x0053 18 rate u16 \| mode u16 \| programmed u16 \| … basal state change; mode is BasalState
0x007C 10 rate u16 \| mode u16 \| programmed u16 \| remaining_sec u32 basal-rate event; mode 3 = absolute override, 6 = percent modify, 1 = pattern
0x00E2 2 BasalState u16 the state value (1 pattern, 3 override, 6 modify)

For a driver, 0x8102 is the useful primitive: automated-delivery apps command an absolute U/h temporary rate, and that is exactly this opcode — no percent math layer and no need to know the programmed pattern rate. Verified: 0.50 U/h for 30 minutes on a 2.00 U/h pattern delivered 0.50 U/h and returned to 2.00 U/h after cancel.

The pump's own closed loop

With the closed loop on (setClosedLoop 0x8009 = 1) the pump doses by itself, even with no CGM attached, and can set a high basal rate from calculator BG and carbs alone. Any delivery a driver commands then lands on top of the pump's own decisions. Check the loop flag (pumpStatus byte 44, Status fields) before every delivery command, and keep the loop setting written off.

With no CGM the loop decides once per loop start, from the last calculator BG (a 0x8400/0x8401 with a BG) if it is under about 15 minutes old: a 30-minute override sized from (BG − target) ÷ ISF plus recent meal entries, less what it has delivered since its last decision. Switching the loop off ends the override about 4 s later; therapyState bits 0x4000 (loop on) and 0x0400 (override) clear by then (Status fields).

TwiistOff keeps the loop off in its stored settings and writes it with every configure. While the status says the loop is on, every delivery start TwiistOff offers is blocked — start basal, temp basal, bolus and cannula fill, in the app, in the set-up and recovery routes, and in POST /pump/temp-basal — with LOOP OFF as the one-tap fix. Turning the loop on asks for a confirmation first. The raw command routes (/pump/command, /pump/command-token) are not gated.

Bolus payload (0x8400)

17 bytes, no therapy prefix in the builder (the therapy number is prepended by the send path):

0-1   glucoseValue_mgPerdLE2
2-3   recommendedBolus_UE2
4-5   normalBolus_UE2          ← the amount actually delivered (verified)
6-7   activeInsulin_UE2
8-9   targetRangeLow_mgPerdLE2
10-11 targetRangeHigh_mgPerdLE2
12-15 bolusCalcTime_UTC (seconds since 2008-01-01)
16    targetOverrideActive

Verified amounts: 0.37, 0.50, 1.00, 1.25, 5.00 and 6.00 U all delivered as sent. Progress is visible in pumpStatus bytes 52–57 (id / requested / delivered). The response 0x8480 is consumedTherapy(2) | nextTherapy(2) | bolusId(2): take the next therapy number from bytes 2–3 — mistaking the bolus ID for the therapy number desyncs the chain.

Measured on the bench 2026-12-02:

  • Max bolus is enforced by the pump: a bolus above the configured max is refused 0x13EE, and the NACK's debug fields carry the requested amount and the limit, so a driver can say "requested > limit" from the NACK alone.
  • Rate: about 0.18 U per 5 s status push (~2.2 U/min); 6.00 U took ~4 min. A new bolus is accepted as soon as the previous one completes.
  • "Delivered" follows plunger travel, not flow. Into a sealed but compliant cap ~11 U "delivered" without an occlusion alarm; delivered == requested does not prove fluid left the line.
  • Occlusion: into a blocked, pressurised line the plunger never advanced and ~50 s after the start the pump raised occlusion + bolusStopped (recovery: §6.2). The reboot zeroes the status bolus fields; the true delivered amount of a stopped bolus is in pump-log record 0x005A (§8).
  • Status byte 76 is the bolus category (5 = manual bolus for every 0x8400, 1 = pump-button bolus).

Measured on the bench 2026-12-04:

  • Smallest bolus 0.05 U, then 0.01 U steps. 0.01, 0.02, 0.03 and 0.04 U are refused 0x13EE (the NACK carries the requested amount and the max bolus, not the minimum) and nothing is logged. 0.05 U is accepted; 0.07 U is accepted and logged as 0.07 U delivered of 0.07 U requested. TwiistOff refuses an amount under 0.05 U before sending it.
  • stopBasal stops all delivery. With a temp basal running, stopBasal alone ends the temp (log 0x0057, no alert); a later startBasal resumes the pattern, not the temp. With a bolus running, stopBasal stops the bolus too: basal state 2 (stopping) for about 4 s, then the bolus ends early (0x005A, e.g. 0.15 of 1.00 U) and the pump raises alert bit 3 bolusStopped, 409-0003 Interrupted Bolus, which needs clearPumpAlert (0x0400 + 0800). A driver that suspends should stop a running bolus first (0x8200) or expect that alert, and take the delivered amount from 0x005A.
  • A bolus and a temp basal run on through a link drop. A 1.00 U bolus with the link down for 40 s completed in full (0x005B 1.00 of 1.00 U), though it took 70 s against 39 s with the link up; a temp basal with the link down for 60 s was still running after the reconnect and stopped normally with 0x8104. The log adds only 0x003A (link dropped) and 0x0039 (session started).
  • With basal stopped the pump refuses a bolus and a temp basal (0x13ED, nothing logged): start basal first. TwiistOff's delivery gate blocks both while basal is stopped.
  • Stopped basal vs a 0.00 U/h slot: the basal rate (bytes 42–43), the net percent (41) and the net rate (68–69) all read 0 in both cases. therapyState (bytes 26–29) bit 0x04 is set while the pattern runs, in a 0.00 U/h slot too, and clear once basal is stopped. The pattern's slots follow the pump's local time (UTC plus the offset set by 0x800B): at 08:19 UTC with an offset of −6 h, the 02:00–02:30 slot ran. A new offset moves the running slot at once: with basal running at 03:03 local, 0x800B with the same UTC and an offset one hour east switched the rate to the 04:00 slot's within 4 s, and back on the restore. Each offset change raises notice bit 1 System Time Updated (no sound flag; clear with mask 0x0002).
  • stopBasal is not instant: the pump can hold a "stopping" state for up to about 10 s, with the rate still reading the pattern's; therapyState bit 0x2000 is set until the stop is done.
  • A temp basal takes 0.01 U/h steps: 0.11 U/h was accepted and reported back as 0.11 U/h. The range is unchanged (0, or 0.10 U/h up to the max basal rate).

Byte-offset trap (cost an early bench probe a false conclusion, 2026-11-30). A "0.1 U" probe sent as 00000000000A000028232823… puts 00 0A at bytes 4–5, i.e. normalBolus_UE2 = 0x0A00 = 2560 = 25.60 U, and the pump refuses it with NACK 0x13EE range check failed — not the delivery gate. The NACK's debug fields carry the values the check used: debugValue1 = the offending amount (2560) and debugValue3 = the pump's max bolus limit (600 = 6.00 U). With the amount at the right offset (0A 00 at bytes 4–5 = 10) the same command is accepted with 0x8480, and the pump log records EV_NORMAL_BOLUS_COMPLETED (0x005B) with deliveredVolume = 10. The gate (verifyTherapySettings returning 01) is a separate, real precondition for delivery; it is not what 0x13EE reports. BolverPayload/BolusPayload.kt builds the amount at the right offset — hand-built payloads are where this trap lives.

protocol/BolusPayload.kt builds this; the non-amount fields currently carry fixed defaults and do not affect the delivered volume (proven by delivering several different amounts).