Skip to content

AndroidAPS driver

Bench hardware only. Not ready to loop. Use it only with pump hardware that is not connected to any living subject. The driver fails closed: when it cannot confirm the pump's state, it sends nothing.

State

In progress; insulin delivery is locked. The code is not public yet. The current working version speaks the real twiist protocol, but it has not yet run against a pump: everything below the Android Bluetooth link is tested on the JVM against a wire-level simulated pump. It is built to run for bench debugging once you supply your own pump's key (LTSS), the same way TwiistOff takes it. What is missing for everyone else is a way to get a pump's LTSS (provisioning), not the driver itself; see Real looping drivers.

What works

  • Connect and arm. Connects straight to the Bluetooth address of a pump already bonded to the phone (no scan, no button press, also after a link drop), arms the session with the key you enter in the twiist settings, and proves the command path with a read-only history read before anything else.
  • Status. Reservoir, battery, the running basal rate, temp basal, bolus progress, alarms and alerts, from the pump's own status pushes. A stopped basal is told apart from a 0.00 U/h slot by the pump's history.
  • Alarms and alerts. Raised as AndroidAPS notifications with their display id and title: an alarm as an urgent notification ("108 Line Blocked" and the alarm text), an alert as a warning ("409-0003 Interrupted Bolus"); each is dismissed when the pump clears it.
  • History. Boluses (the delivered amount as the pump logged it, a stopped bolus included) and temp basals (start, cancel, expiry) go into AndroidAPS's treatment history, keyed by the pump's log event id so nothing is recorded twice. A stopped basal is recorded as a pump suspend and ends when basal runs again.
  • Stop basal. Stopping basal on the pump ends a running temp basal and stops a running bolus (alert 409-0003 Interrupted Bolus). The driver follows both: the bolus result is the amount the pump logged, and the stopped bolus is not mistaken for one still running.
  • Command discipline. One command at a time; a therapy command is sent once and never resent, and its own reply is matched; a refusal moves the therapy number on and the driver uses the new one; a lost answer is settled from the pump's status and log; after a pump restart the driver re-arms once and proves the path with a read before any therapy; therapy is refused while the pump's own closed loop is on.
  • Delivery paths, built and locked. Bolus from 0.05 U in 0.01 U steps (rounded down), bolus stop, temp basal in U/h (0.01 U/h steps, rounded down; under 0.10 U/h sent as 0) or percent, 30 minutes to 24 hours (a running one is cancelled first), cancel and clock setting are implemented and tested against the simulated pump. A bolus or temp basal is refused with the reason while basal is stopped, since the pump refuses them then. While delivery is locked, every one of them is refused before anything is sent, a temp-basal cancel included; only a bolus stop goes through.

What is stubbed

Each of these refuses and sends nothing:

  • Extended bolus: the pump starts one only through its meal-bolus command, which the driver does not use yet.
  • Basal profile write: needs the pump's full therapy-settings record, which the driver cannot yet rebuild for a pump it did not configure. AndroidAPS is told the profile is set, so it does not retry.
  • Daily totals (TDD): not read yet. The pump has them: 0x8500 / 0x8501 count the current local day, and the history log's midnight records hold each finished day's totals.
  • Daylight saving: the driver still reports it cannot handle a DST change itself. The pump's basal schedule follows its zone offset, and a new offset moves the running slot at once, so a driver can set the new offset with 0x800B when the phone's zone changes.
  • Start basal: the driver does not start a stopped basal (it needs the same therapy-settings record); start it from the app that set the pump up.
  • Pairing: the driver does not pair; bond the pump to the phone first.

Open before delivery can be unlocked: the first run on a bench pump, reconnecting after a link lost by range (after a clean disconnect a bonded phone reconnects with no scan or button press), and whether a second controller can be bonded at the same time. The pump limits the driver follows are on Delivery.