Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
b1b4052
Add Omnipod 5 pump support. New pump:omnipod:omnipod5 module (Omnipod…
premnirmal Aug 18, 2026
9e0ac2b
Update alert reminder config for O5
premnirmal Aug 26, 2026
09f35ef
do not proactively connect to pod on overview open, do it when refres…
premnirmal Aug 26, 2026
0a07331
Bolus completion fix, pairing IDs and activation timeout
premnirmal Sep 4, 2026
11161b0
Merge remote-tracking branch 'origin/dev' into copilot/rebase-dev-int…
Copilot Sep 11, 2026
2652403
Resolve merged build dependency
Copilot Sep 11, 2026
d8fec1f
Fix merged Omnipod dependency
Copilot Sep 11, 2026
df9c6f8
Exclude removed Omnipod 5 module
Copilot Sep 11, 2026
a688b78
Fix Omnipod response imports
Copilot Sep 11, 2026
fbe0bca
omnipod5 module include in setting.gradle
premnirmal Sep 11, 2026
d4e5776
Fix Omnipod 5 module integration
premnirmal Sep 11, 2026
c71991e
Resolve dev merge conflict
Copilot Sep 22, 2026
ce136cf
Fix old pod address reuse issue
premnirmal Sep 22, 2026
f22b137
Log basal tracking, fix basal expectation update order, and add basal…
premnirmal Sep 23, 2026
56ef718
Extract dash+o5 logic into shared common layer
premnirmal Sep 23, 2026
4bc0302
Add O5History and O5History viewer screen/viewmodel
premnirmal Sep 23, 2026
40e0157
Show pod history entrypoint in 2 places
premnirmal Sep 23, 2026
d59041b
Add ability to read cert from assets
premnirmal Sep 23, 2026
14399fc
Show basal drift compensation bolus as compensation in pod history
premnirmal Sep 23, 2026
7d7253b
content weight
premnirmal Sep 23, 2026
eecc58b
Launch webview for O5 credential when none installed
Copilot Sep 23, 2026
7bd90b3
Fix o5 insulin pump time expiration display
premnirmal Sep 24, 2026
d43d06c
Merge branch 'o5' into o5-testing
premnirmal Sep 24, 2026
6971a20
Show O5 credential import full screen
Copilot Sep 24, 2026
6512214
Use resources for O5 import messages
Copilot Sep 24, 2026
32d337e
Use shared spacing for credential screen
Copilot Sep 24, 2026
93850aa
Clear canceled O5 activation state
Copilot Sep 24, 2026
eceb3b7
Apply remaining changes
Copilot Sep 24, 2026
b2a62b2
Dash pump expiration time
premnirmal Sep 24, 2026
6ae4232
Merge branch 'copilot/override-pump-expiration-time' into o5
premnirmal Sep 24, 2026
a65ef72
Revert "Fix o5 insulin pump time expiration display"
premnirmal Sep 24, 2026
b403640
build fix
premnirmal Sep 24, 2026
b93aa89
Merge dev into o5 branch
Copilot Sep 24, 2026
7ac9576
UI tweaks
premnirmal Sep 24, 2026
271fc81
rename/comment edit
premnirmal Sep 24, 2026
3468686
Merge remote-tracking branch 'origin/o5' into copilot/o5-merge-dev-an…
Copilot Sep 24, 2026
9cad1b7
Fix merged o5 and dev conflicts
Copilot Sep 24, 2026
afab3a4
clean up certificate store screen
premnirmal Sep 24, 2026
1cd2aef
Fix some tests, and do not allow remove cert unless no pump is active
premnirmal Sep 25, 2026
417d603
Fix failing unit tests (#16)
Copilot Sep 25, 2026
114a8fa
Show a progress state in the webview to avoid first load delay confusion
premnirmal Sep 26, 2026
6f7d218
linear progress
premnirmal Sep 26, 2026
a56cf8c
Merge branch 'dev' into o5
premnirmal Sep 28, 2026
cc94f9b
Reservoir units > 1023 for O5
premnirmal Sep 28, 2026
4dae7f2
Fix no zero-rate TBR when the pod stops delivering, match periodic po…
premnirmal Sep 30, 2026
34d8723
O5 now shows the pod time aligned with Dash, time on pod now uses the…
premnirmal Sep 30, 2026
0166383
Add exception message strings
premnirmal Sep 30, 2026
af9b4be
Inside a coroutine so we can use await() rather than blockingAwait(),…
premnirmal Sep 30, 2026
70bddd2
Merge branch 'dev' into o5
premnirmal Sep 30, 2026
07059e8
Restore toolchain vendor to JETBRAINS
premnirmal Oct 1, 2026
7782472
Fix O5 suspend alert flag after profile changes - mark suspend alerts…
premnirmal Oct 5, 2026
3c4f287
Merge dev into o5
premnirmal Oct 6, 2026
b52b514
For O5 - make basal compensation on by default, and fix plugin test
premnirmal Oct 8, 2026
ec1a776
Merged dev, resolved conflicts
premnirmal Oct 8, 2026
006d951
Merge branch 'dev' into o5
premnirmal Oct 9, 2026
168770b
Merge branch 'dev' into o5
premnirmal Oct 11, 2026
acf7c30
Fix potential pairing failure - during pairing the queue did not see …
premnirmal Oct 11, 2026
c5707cb
Remove suspend action from pump actions for O5
premnirmal Oct 12, 2026
b78d4f8
Merge branch 'dev' into o5
premnirmal Oct 12, 2026
c919c34
Re-add showCredentialImport to back handler
premnirmal Oct 12, 2026
ca173d6
Merge branch 'dev' into o5
premnirmal Oct 12, 2026
5ad8359
Use shared history models and bolus type from omnipod:common
premnirmal Oct 12, 2026
2cf834e
Add pod hard end date to o5
premnirmal Oct 12, 2026
5a8a456
Merge branch 'dev' into o5
premnirmal Oct 13, 2026
6973460
Merge branch 'dev' into o5
premnirmal Oct 14, 2026
87cd20a
O5 wizard: pass rh and rxBus to the base view model after dev b7f5f96
premnirmal Oct 14, 2026
83b56a2
Only show O5 manual certificate import with engineering mode
premnirmal Oct 14, 2026
6c0bfd2
Only show certificate store when eng mode is enabled
premnirmal Oct 14, 2026
20770c3
For O5 the drift check now runs only after the new temp basal is set …
premnirmal Oct 14, 2026
698ecb6
use pluginScope for commands
premnirmal Oct 15, 2026
5f92bf5
Fixed O5 lost-response recovery to restore basal records, preserve de…
premnirmal Oct 15, 2026
1919e6a
Add concurrency tests and deadlock tests for the mutex in the plugin
premnirmal Oct 15, 2026
dd26910
Merged dev, resolved conflicts
premnirmal Oct 15, 2026
1c3e0d2
Use common pod history UI
premnirmal Oct 15, 2026
6e028aa
merge fix and unused imports
premnirmal Oct 15, 2026
76d1323
Merge branch 'dev' into o5
premnirmal Oct 16, 2026
87cd454
Port pod pulse fix from #5314 to O5
premnirmal Oct 16, 2026
6bad085
O5 now accounts for delivered bolus pulses during each status update,…
premnirmal Oct 16, 2026
8c5c15b
Merge branch 'dev' into o5
premnirmal Oct 16, 2026
ff90900
Add pdm ref codes for O5 and map them to error types shown in the pum…
premnirmal Oct 19, 2026
f4bd04d
Merge branch 'dev' into o5
premnirmal Oct 20, 2026
7409daa
Show overlay progress when fetching certificate to make loading clear…
premnirmal Oct 20, 2026
270c085
Add a loading text to the progress indicator
premnirmal Oct 20, 2026
a82ff3c
Merge branch 'dev' into o5
premnirmal Oct 21, 2026
96e3ca4
Aligned O5 with Dash to save fault codes and available PDM Ref codes …
premnirmal Oct 21, 2026
0fb12f6
Merge branch 'dev' into o5
premnirmal Oct 22, 2026
bb550f7
Undo search and unrelated file changes
premnirmal Oct 22, 2026
01d231b
Add network connection error messaging on cert retrieval
premnirmal Oct 22, 2026
dd408eb
Undo some verbose changes
premnirmal Oct 22, 2026
0fac39a
Allowed origins change for Webview
premnirmal Oct 22, 2026
31fa8ec
Merge pull request #5366 from premnirmal/o5
MilosKozak Oct 22, 2026
85f2535
Untangled pod erros for Dash and O5
Oct 22, 2026
b30290e
Merge pull request #5370 from nl-ruud/dash-o5-pdm-fault-text-per-pump
MilosKozak Oct 22, 2026
9a5fb94
Omnipod: only the pod hard end turns red, and it shows the time left …
MilosKozak Oct 22, 2026
9af2c54
Omnipod 5: pod expiry and hard end rows use the shared Omnipod colour…
MilosKozak Oct 22, 2026
bd6f9cd
Omnipod 5: remove omnipod_5_history from the preference snapshot, the…
MilosKozak Oct 23, 2026
5e091ef
Omnipod 5 tests: record the two pluginScope launches, and wait for th…
MilosKozak Oct 23, 2026
dcce560
Move PDM reference code display rules into pump code
Oct 24, 2026
183cb28
Careportal now saves the pod alarm description and reference code, in…
premnirmal Oct 24, 2026
d5acb40
Fix missing Omnipod Dash fault alarms and add regression tests
Oct 24, 2026
75f51cd
Fix BasalProgram losing saved segments after a Gson field rename
Oct 24, 2026
89e9dae
Allow "mutableSegmentsOrNull" as alternate for "segments"
Oct 24, 2026
f70af62
Merge pull request #5390 from nl-ruud/fix/dash-basal-program-gson
MilosKozak Oct 25, 2026
52deb76
Merge pull request #5386 from nl-ruud/o5-pdm-refcode-in-code
MilosKozak Oct 25, 2026
533545b
Merge branch 'dev' into o5
MilosKozak Oct 25, 2026
8310c2c
Merge pull request #5387 from premnirmal/fix/o5-pod-fault-reporting
MilosKozak Oct 25, 2026
f46bfec
Merge pull request #5388 from nl-ruud/fix/dash-alarm-response
MilosKozak Oct 25, 2026
cca740f
O5 bolus progress timing fix
premnirmal Oct 29, 2026
2d0f0de
O5 now exposes its confirmed rounded basal rates through deliveredBas…
premnirmal Oct 29, 2026
3609a40
Merge pull request #5432 from premnirmal/fix-o5-bolus-progress-timing
MilosKozak Oct 29, 2026
c20c229
Merge remote-tracking branch 'origin/dev' into o5
MilosKozak Oct 29, 2026
3dfa267
Merge branch 'dev' into o5
MilosKozak Oct 30, 2026
7643aed
Fix memory leak with web message listener keeping the webview and act…
premnirmal Nov 3, 2026
b381603
Merge pull request #5471 from premnirmal/o5
MilosKozak Nov 3, 2026
b0568cc
build fix
premnirmal Nov 3, 2026
3159eec
Merge branch 'dev' into o5
MilosKozak Nov 3, 2026
dcd7c82
Merge pull request #5472 from premnirmal/o5
MilosKozak Nov 3, 2026
7ab90a3
Initial DST Change support for Omnipod Dash and O5
Nov 5, 2026
33875af
Track reported suspend basal in Omnipod drivers
Nov 6, 2026
7e80f7c
Merge pull request #5506 from nl-ruud/dst
MilosKozak Nov 10, 2026
2f89bf2
Merge branch 'dev' into o5
MilosKozak Nov 12, 2026
4fe0425
Merge branch 'dev' into o5
MilosKozak Nov 16, 2026
41d94eb
Merge branch 'dev' into o5
MilosKozak Nov 16, 2026
f321197
Omnipod 5: pairing works on Android 12, no BigInteger.TWO
MilosKozak Nov 16, 2026
e08cab0
Merge branch 'dev' into o5
MilosKozak Nov 16, 2026
8f180bb
Merge branch 'dev' into o5
MilosKozak Nov 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class PluginLifetimeWorkScanTest {
"SignatureVerifierPlugin#onStart" to "onStop removes the callbacks, quits the looper and nulls the handler",
"OmnipodDashPumpPlugin#scope" to "onStop cancels the scope and tears the handler down",
"OmnipodDashPumpPlugin#onStart" to "onStop cancels the scope and tears the handler down",
"O5PumpPlugin#scope" to "the statusChecker that the init block re-posts is removed in onStop, which also nulls the handler",
"O5PumpPlugin#armStatusChecker" to "onStop removes the statusChecker callbacks and nulls the handler",
"O5PumpPlugin#onStart" to "onStop removes the statusChecker callbacks, nulls the handler and cancels the scope",
"LoopPlugin#scheduleBuildAndStoreDeviceStatus" to "the job is held in deviceStatusJob and onStop cancels it",
"LoopPlugin#scheduleSmbFallback" to "the deferred SMB re-run is held in smbFallbackJob and onStop cancels it",
"XdripPlugin#onStart" to "onStop removes the callbacks first, then quits the looper",
Expand Down Expand Up @@ -279,6 +282,11 @@ class PluginLifetimeWorkScanTest {
"readStatus(unconfirmed_command). A read. SAFE to abandon - but see handleCommandConfirmation " +
"below, which is the reason unconfirmed commands are being chased in the first place."
),
"O5PumpPlugin.kt#refreshStatusOnUnacknowledgedCommands" to Site(
1,
"readStatus(omnipod_5_unconfirmed_command). A copy of OmnipodDashPumpPlugin#refreshStatusOnUnacknowledgedCommands. " +
"A read. SAFE to abandon."
),
"OmnipodErosPumpPlugin.kt#queueAcknowledgeAlertsCommand" to Site(
1,
"customCommand(CommandSilenceAlerts), result only logged. Silencing an alert is a pod write, but " +
Expand All @@ -302,6 +310,13 @@ class PluginLifetimeWorkScanTest {
"actual harm here, because it is the only record that the correction worked. Cancelling would " +
"not stop the delivery anyway; the command is already in the queue by then. This is the site " +
"that rules out a per-enable pluginScope for this driver."
),
"O5PumpPlugin.kt#queueBasalCorrectionIfNeeded" to Site(
1,
"customCommand(CommandDeliverBasalCorrection). DELIVERS INSULIN. The O5 copy of the correction in " +
"OmnipodDashPumpPlugin#handleCommandConfirmation, and the same decision: it must NOT be cancelled, " +
"and cancelling would not stop it anyway, because the command is already in the queue. The queued " +
"command checks the drift again before it sends anything. Rules out a per-enable pluginScope for O5 too."
)
)

Expand Down
3 changes: 3 additions & 0 deletions app/src/testFull/resources/prefs-schema.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ AAPS.Omnipod.suspend_delivery_button_enabled|ErosBooleanPreferenceKey|true
AAPS.Omnipod.tbr_beeps_enabled|OmnipodBooleanPreferenceKey|true
AAPS.Omnipod.tbrs_set|ErosLongNonPreferenceKey|true
AAPS.Omnipod.time_change_enabled|ErosBooleanPreferenceKey|true
AAPS.Omnipod5.pod_state|O5StringNonPreferenceKey|true
AAPS.Omnipod5.registration_data_encrypted|O5StringNonPreferenceKey|false
AAPS.OmnipodDash.pod_state|DashStringNonPreferenceKey|true
AAPS.RileyLink.LastGoodDeviceFrequency|RileyLinkDoubleKey|true
AAPS.RileyLink.lastGoodDeviceCommunicationTime|RileyLinkLongKey|true
Expand Down Expand Up @@ -365,6 +367,7 @@ nsclientinternal_api_secret|StringKey|true
nsclientinternal_url|StringKey|true
oh_charging_only|BooleanKey|true
oh_wifi_only|BooleanKey|true
omnipod_5_certificate_store|O5IntentKey|false
openaps_smb_min_5m_carbimpact|DoubleKey|true
openapsama_autosens_period|IntKey|true
openapsama_current_basal_safety_multiplier|DoubleKey|true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,26 @@ enum class PumpType(
hasCustomUnreachableAlertCheck = false,
supportBatteryLevel = false
),
OMNIPOD_5(
description = "Omnipod 5",
manufacturer = ManufacturerType.Insulet,
model = "5",
bolusSize = 0.05,
specialBolusSize = null,
extendedBolusSettings = DoseSettings(0.05, 30, 8 * 60, 0.05),
pumpTempBasalType = PumpTempBasalType.Absolute,
tbrSettings = DoseSettings(0.05, 30, 12 * 60, 0.0, 30.0),
specialBasalDurations = arrayOf(Capability.BasalRate_Duration30minAllowed),
baseBasalMinValue = 0.05,
baseBasalMaxValue = null,
baseBasalStep = 0.05,
baseBasalSpecialSteps = null,
isPatchPump = true,
maxReservoirReading = 50,
pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = false,
supportBatteryLevel = false
),
MEDTRONIC_512_712(
description = "Medtronic 512/712",
manufacturer = ManufacturerType.Medtronic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum class Sources {
Omnipod, //No entry currently
OmnipodEros,
OmnipodDash, //No entry currently
Omnipod5,
EOPatch2,
Equil,
Medtrum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ data class UserEntry(
Omnipod, //No entry currently
OmnipodEros,
OmnipodDash, //No entry currently
Omnipod5,
EOPatch2,
Equil,
Medtrum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data class InterfaceIDs @Ignore constructor(
DANA_RS_KOREAN,
OMNIPOD_EROS,
OMNIPOD_DASH,
OMNIPOD_5,
MEDTRONIC_512_517,
MEDTRONIC_515_715,
MEDTRONIC_522_722,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fun InterfaceIDs.PumpType.fromDb(): PumpType =
InterfaceIDs.PumpType.DANA_I2 -> PumpType.DANA_I2
InterfaceIDs.PumpType.OMNIPOD_EROS -> PumpType.OMNIPOD_EROS
InterfaceIDs.PumpType.OMNIPOD_DASH -> PumpType.OMNIPOD_DASH
InterfaceIDs.PumpType.OMNIPOD_5 -> PumpType.OMNIPOD_5
InterfaceIDs.PumpType.MEDTRONIC_512_517 -> PumpType.MEDTRONIC_512_712
InterfaceIDs.PumpType.MEDTRONIC_515_715 -> PumpType.MEDTRONIC_515_715
InterfaceIDs.PumpType.MEDTRONIC_522_722 -> PumpType.MEDTRONIC_522_722
Expand Down Expand Up @@ -66,6 +67,7 @@ fun PumpType.toDb(): InterfaceIDs.PumpType =
PumpType.DANA_I2 -> InterfaceIDs.PumpType.DANA_I2
PumpType.OMNIPOD_EROS -> InterfaceIDs.PumpType.OMNIPOD_EROS
PumpType.OMNIPOD_DASH -> InterfaceIDs.PumpType.OMNIPOD_DASH
PumpType.OMNIPOD_5 -> InterfaceIDs.PumpType.OMNIPOD_5
PumpType.MEDTRONIC_512_712 -> InterfaceIDs.PumpType.MEDTRONIC_512_517
PumpType.MEDTRONIC_515_715 -> InterfaceIDs.PumpType.MEDTRONIC_515_715
PumpType.MEDTRONIC_522_722 -> InterfaceIDs.PumpType.MEDTRONIC_522_722
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun UserEntry.Sources.fromDb(): Sources =
UserEntry.Sources.Omnipod -> Sources.Omnipod
UserEntry.Sources.OmnipodEros -> Sources.OmnipodEros
UserEntry.Sources.OmnipodDash -> Sources.OmnipodDash
UserEntry.Sources.Omnipod5 -> Sources.Omnipod5
UserEntry.Sources.EOPatch2 -> Sources.EOPatch2
UserEntry.Sources.Equil -> Sources.Equil
UserEntry.Sources.Medtrum -> Sources.Medtrum
Expand Down Expand Up @@ -158,6 +159,7 @@ fun Sources.toDb(): UserEntry.Sources =
Sources.Omnipod -> UserEntry.Sources.Omnipod
Sources.OmnipodEros -> UserEntry.Sources.OmnipodEros
Sources.OmnipodDash -> UserEntry.Sources.OmnipodDash
Sources.Omnipod5 -> UserEntry.Sources.Omnipod5
Sources.EOPatch2 -> UserEntry.Sources.EOPatch2
Sources.Equil -> UserEntry.Sources.Equil
Sources.Medtrum -> UserEntry.Sources.Medtrum
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ androidx-legacy-support = { group = "androidx.legacy", name = "legacy-support-v1
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleRuntimeKtx" }
androidx-documentfile = { group = "androidx.documentfile", name = "documentfile", version = "1.1.0" }
androidx-preference = { group = "androidx.preference", name = "preference-ktx", version = "1.2.1" }
androidx-webkit = { group = "androidx.webkit", name = "webkit", version = "1.12.1" }
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
androidx-room-rxjava3 = { group = "androidx.room", name = "room-rxjava3", version.ref = "room" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class UserEntryPresentationHelperImpl(
Sources.Omnipod -> IcPatchPump
Sources.OmnipodDash -> IcPatchPump
Sources.OmnipodEros -> IcPatchPump
Sources.Omnipod5 -> IcPatchPump
Sources.Ottai -> IcPluginSyai
Sources.Overview -> Icons.Default.Home
Sources.PocTech -> IcPluginPocTec
Expand Down Expand Up @@ -250,6 +251,7 @@ class UserEntryPresentationHelperImpl(
Sources.Omnipod -> ElementType.PUMP.color()
Sources.OmnipodDash -> ElementType.PUMP.color()
Sources.OmnipodEros -> ElementType.PUMP.color()
Sources.Omnipod5 -> ElementType.PUMP.color()
Sources.Ottai -> ElementType.CGM_DEX.color()
Sources.Overview -> ElementType.AAPS.color()
Sources.PocTech -> ElementType.CGM_DEX.color()
Expand Down
1 change: 1 addition & 0 deletions pump/omnipod/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {

implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
implementation(libs.kotlinx.coroutines.rx3)

testImplementation(project(":shared:tests"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ package app.aaps.pump.omnipod.common.bledriver.comm
import app.aaps.pump.omnipod.common.bledriver.comm.interfaces.scan.PodScanner
import app.aaps.pump.omnipod.common.bledriver.pod.state.OmnipodDashPodStateManager

class Ids(podState: OmnipodDashPodStateManager) {
/**
* The controller/pod identity pair used throughout pairing and session establishment.
*
* The primary constructor (from [OmnipodDashPodStateManager]) is unchanged from before -
* every existing Dash call site behaves identically. [forController] is an additive
* factory for pod types (e.g. Omnipod 5) that don't have a Dash-style pod state manager
* to derive their controller/pod ids from - O5 derives its controller id from
* [app.aaps.pump.omnipod.common.bledriver.comm.pair.O5CertificateStore.controllerId]
* instead.
*/
class Ids private constructor(val myId: Id, val podId: Id) {

val myId = Id.fromInt(OmnipodDashBleManagerImpl.CONTROLLER_ID)
private val uniqueId = podState.uniqueId
val podId = uniqueId?.let(Id::fromLong)
?: myId.increment() // pod not activated
constructor(podState: OmnipodDashPodStateManager) : this(
myId = Id.fromInt(OmnipodDashBleManagerImpl.CONTROLLER_ID),
podId = podState.uniqueId?.let(Id::fromLong)
?: Id.fromInt(OmnipodDashBleManagerImpl.CONTROLLER_ID).increment()
)

companion object {

Expand All @@ -17,5 +28,8 @@ class Ids(podState: OmnipodDashPodStateManager) {
PodScanner.POD_ID_NOT_ACTIVATED
)
}

/** For pod types without a Dash-style pod state manager to derive ids from. */
fun forController(myId: Id, podId: Id): Ids = Ids(myId, podId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ abstract class SharedBleManager(
* Exceptions are handled by the enclosing operation: the connection is disconnected and the
* observable emits the error.
*/
protected open fun onCommandWriteCompleted() = Unit
protected open fun onCommandWriteCompleted() {
onCommandSent()
}

protected open fun onCommandSent() = Unit

/**
* Called on the subscription thread before [PodEvent.ResponseReceived] is emitted.
Expand Down Expand Up @@ -109,6 +113,7 @@ abstract class SharedBleManager(
}

is CommandReceiveError -> {
readResult.result?.let(::onResponse)
emitter.tryOnError(MessageIOException("Could not read response: $readResult"))
return@create
}
Expand Down Expand Up @@ -155,6 +160,7 @@ abstract class SharedBleManager(
emitter.onNext(PodEvent.Connected)
complete(emitter::onComplete) { busyReleasedBeforeCompletion = true }
} catch (ex: Exception) {
aapsLogger.error(LTag.PUMPBTCOMM, "$connectionName connection failed", ex)
disconnect(false)
emitter.tryOnError(ex)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ object BleCommandSuccess : BleCommand(BleCommandType.SUCCESS)

object BleCommandFail : BleCommand(BleCommandType.FAIL)

object BleCommandPairStatus : BleCommand(BleCommandType.PAIR_STATUS)

data class BleCommandNack(val idx: Byte) : BleCommand(BleCommandType.NACK, byteArrayOf(idx)) {
companion object {

Expand Down Expand Up @@ -93,6 +95,9 @@ sealed class BleCommand(val data: ByteArray) {
BleCommandType.FAIL ->
BleCommandFail

BleCommandType.PAIR_STATUS ->
BleCommandPairStatus

BleCommandType.HELLO ->
BleCommandIncorrect("Incorrect hello command received", payload)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ enum class BleCommandType(val value: Byte) {
SUCCESS(0x04.toByte()),
FAIL(0x05.toByte()),
HELLO(0x06.toByte()),

/** O5-only: an intermediate "still working" status the pod can send on the CMD
* characteristic while preparing a response, before the real expected command
* (e.g. SUCCESS). Matches OmnipodKit's PodCommand.PAIR_STATUS - see
* PeripheralManager.waitForCommand(), which loops past it instead of failing. */
PAIR_STATUS(0x08.toByte()),
INCORRECT(0x09.toByte());

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ import java.math.BigInteger
import java.util.UUID

enum class CharacteristicType(val value: String) {
CMD("1a7e2441-e3ed-4464-8b7e-751e03d0dc5f"), DATA("1a7e2442-e3ed-4464-8b7e-751e03d0dc5f");
CMD("1a7e2441-e3ed-4464-8b7e-751e03d0dc5f"),
DATA("1a7e2442-e3ed-4464-8b7e-751e03d0dc5f"),

/**
* Omnipod 5's data characteristic. O5 shares Dash's CMD characteristic (and GATT
* service) but uses a different DATA characteristic - see
* [app.aaps.pump.omnipod.common.bledriver.pod.util.BluetoothServiceUuids] for the
* canonical source of these UUIDs (this enum predates that file and is left as the
* existing GATT-wiring mechanism rather than migrated wholesale, to avoid touching
* more of the working Dash connection path than necessary).
*/
DATA_O5("1a7e2443-e3ed-4464-8b7e-751e03d0dc5f");

val uuid: UUID
get() = UUID(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app.aaps.core.utils.toHex
import app.aaps.pump.omnipod.common.bledriver.comm.interfaces.io.CharacteristicType.Companion.byValue
import app.aaps.pump.omnipod.common.bledriver.comm.legacy.io.IncomingPackets
import app.aaps.pump.omnipod.common.bledriver.comm.session.DisconnectHandler
import app.aaps.pump.omnipod.common.bledriver.pod.util.BluetoothServiceUuids
import java.util.UUID
import java.util.concurrent.BlockingQueue
import java.util.concurrent.CountDownLatch
Expand All @@ -32,8 +33,16 @@ class BleCommCallbacks(
private var connected: CountDownLatch = CountDownLatch(1)
@Synchronized get
@Synchronized set
private var mtuNegotiationComplete: CountDownLatch = CountDownLatch(1)
@Synchronized get
@Synchronized set
private val writeQueue: BlockingQueue<WriteConfirmation> = LinkedBlockingQueue()

/** The ATT MTU last confirmed via [onMtuChanged]; the BLE-spec default until negotiated. */
@Volatile
var negotiatedMtu: Int = DEFAULT_ATT_MTU
private set

override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
aapsLogger.debug(LTag.PUMPBTCOMM, "OnConnectionStateChange with status/state: $status/$newState")
super.onConnectionStateChange(gatt, status, newState)
Expand Down Expand Up @@ -120,7 +129,14 @@ class BleCommCallbacks(
super.onCharacteristicChanged(gatt, characteristic)

val payload = characteristic.value
val characteristicType = byValue(characteristic.uuid.toString())
val uuid = characteristic.uuid.toString()

if (uuid.equals(BluetoothServiceUuids.O5_HEARTBEAT_CHARACTERISTIC_UUID, ignoreCase = true)) {
aapsLogger.debug(LTag.PUMPBTCOMM, "Received O5 heartbeat: ${payload.toHex()}")
return
}

val characteristicType = byValue(uuid)

aapsLogger.debug(
LTag.PUMPBTCOMM,
Expand Down Expand Up @@ -153,6 +169,24 @@ class BleCommCallbacks(
LTag.PUMPBTCOMM,
"onMtuChanged with MTU/status: $mtu/$status "
)
if (status == BluetoothGatt.GATT_SUCCESS) {
negotiatedMtu = mtu
}
mtuNegotiationComplete.countDown()
}

/**
* @return true once [onMtuChanged] has fired (successfully or not); false on timeout.
* Callers should check [negotiatedMtu] afterwards to see what was actually granted.
*/
fun waitForMtuChange(timeoutMs: Long): Boolean {
val latch = mtuNegotiationComplete
try {
latch.await(timeoutMs, TimeUnit.MILLISECONDS)
} catch (e: InterruptedException) {
aapsLogger.warn(LTag.PUMPBTCOMM, "Interrupted while waiting for MTU negotiation")
}
return latch.count == 0L
}

override fun onReadRemoteRssi(gatt: BluetoothGatt?, rssi: Int, status: Int) {
Expand Down Expand Up @@ -210,13 +244,19 @@ class BleCommCallbacks(
aapsLogger.debug(LTag.PUMPBTCOMM, "Reset connection")
connected.countDown()
serviceDiscoveryComplete.countDown()
mtuNegotiationComplete.countDown()
connected = CountDownLatch(1)
serviceDiscoveryComplete = CountDownLatch(1)
mtuNegotiationComplete = CountDownLatch(1)
negotiatedMtu = DEFAULT_ATT_MTU
flushConfirmationQueue()
}

companion object {
// the confirmation queue should be empty anyway
private const val WRITE_CONFIRM_TIMEOUT_MS = 10

/** BLE-spec default ATT MTU (23 bytes total, 20 usable payload) before any negotiation. */
const val DEFAULT_ATT_MTU = 23
}
}
Loading
Loading