ApexKit is a standalone iOS framework that integrates the APEX TruCare III insulin pump with LoopKit-based automated insulin delivery (AID) apps such as Trio.
It was extracted from Trio's in-app Apex pump driver so the same pump support can be reused in other LoopKit apps without copying app-specific code.
- A
PumpManagerUIimplementation (ApexPumpManager) that can be registered as a pump plugin in any LoopKit-based app. - Direct Bluetooth connection to the pump by serial number. The target device
name is
APEX+ serial number, matching the pump's BLE advertisement. - Read-only status updates (firmware/protocol version, battery, reservoir) on a heartbeat.
- Real treatment commands: temporary basal rate, cancel temp basal, suspend,
resume, bolus (0.025 U steps) and cancel bolus. Each treatment uses its own
BLE connection and performs the minimum initialization writes
(
SyncDateTime,NotifyAboutConnection) before the treatment command. - Onboarding UI (serial number entry) and a settings page with pump status.
The packet construction, CRC16-Modbus validation and response parsing follow the documented TruCare III protocol (protocol version 4.12). Command vectors are covered by unit tests.
| Path | Purpose |
|---|---|
Sources/ApexKit/ApexPumpProtocol.swift |
BLE session config, command builder, packet parser |
Sources/ApexKit/ApexPumpReadOnlyTransport.swift |
Bluetooth read-only status transport |
Sources/ApexKit/ApexPumpTreatmentTransport.swift |
Bluetooth treatment transport |
Sources/ApexKit/ApexPumpManager.swift |
PumpManagerUI implementation |
Sources/ApexKit/ApexPumpSetupViewController.swift |
Onboarding + settings UI |
Sources/ApexKit/ApexPumpTreatmentCommandTestViewController.swift |
Debug treatment page |
Sources/ApexKit/ApexBolusProgressEstimator.swift |
Bolus progress reporting |
Sources/ApexKit/ApexPumpDoseEntryExtensions.swift |
Dose/event constructors |
Sources/ApexKit/ApexLog.swift |
Lightweight OSLog logging |
Tests/ApexKitTests/ApexPumpIntegrationTests.swift |
Behavior + packet vector tests |
project.yml |
XcodeGen project spec |
Requirements: Xcode with an iOS 17+ simulator, XcodeGen,
and a LoopKit checkout next to this folder (../LoopKit/LoopKit.xcodeproj).
xcodegen generate
xcodebuild build-for-testing \
-project ApexKit.xcodeproj \
-scheme ApexKit \
-destination 'platform=iOS Simulator,name=iPhone 17,OS=26.5'
xcodebuild test-without-building \
-project ApexKit.xcodeproj \
-scheme ApexKit \
-destination 'platform=iOS Simulator,name=iPhone 17,OS=26.5'The test suite covers packet vectors, response parsing, dose construction, manager behavior (accepted/rejected/busy/suspended/not-validated/zero/over-max), bolus cancel and progress, and the settings UI.
-
Add
ApexKit/ApexKit.xcodeprojto your Xcode workspace. -
Link and embed
ApexKit.frameworkin your app target (embed withCodeSignOnCopy), and add a target dependency on theApexKittarget. -
import ApexKitwhere needed. -
Register the plugin:
let pumpManagers: [PumpManager.Type] = [ ApexPumpManager.self, // ... ] let pluginMap: [String: PumpManager.Type] = [ ApexPumpManager.pluginIdentifier: ApexPumpManager.self, // ... ]
-
The app already embeds
LoopKit.frameworkandLoopKitUI.framework(ApexKit links against both).
The integration steps above follow the same pattern used by Trio, where the
workspace references ApexKit/ApexKit.xcodeproj and the app target links and
embeds ApexKit.framework.
- Connection mode is fixed direct Bluetooth; there is no broadcast mode or connection-method selector.
- Treatment commands are sent only after a read-only validation has succeeded (firmware/protocol version received).
- A bolus accepted by the pump is recorded as fully delivered so history and IOB count the dose.
- Logs contain command summaries and status only; device identity, serial numbers, keys and communication payloads are not written to shareable logs.
- Real-pump validation still requires an actual APEX pump; unit tests cover the protocol and manager logic but not hardware behavior.