nightscout / Trio

Trio - an automated insulin delivery system for iOS based on the OpenAPS algorithm with adaptations.
https://docs.diy-trio.org/en/latest/
MIT License
98 stars 526 forks source link

A "Pod Already Paired" error is always non-recoverable except by app restart #380

Open itsmojo opened 3 months ago

itsmojo commented 3 months ago

Describe the bug

See the 08/08/2024 Discord post by Dylan Sutton and subsequent follow up post by Joe Moran. There was apparently some UI glitch during pod setup that left the app where continuing from the Insert Cannula view after the cannula was successfully inserted went back to the same Inset Cannula view for some unknown reason. But after this happens and the Insert Cannula UI tries to call the pumpManager's insert cannula code again, a podAlreadyPaired error is continually returned which doesn't allow the user to get past the Insert Cannula view. The only recovery possible (without deactivating the pod) is to stop and restart the app.

This rare event happened with Trio but could potentially happen with Loop or iAPS as the code involved is virtually identical in all cases. A straightforward logic modification will prevent being forever stuck in the Insert Cannula screen with a Pod Already Paired error in the future.

Attach a Log

log.txt

Below is a summary of all the decoded pod commands from the start of the pairing through the reboot and up to the first loop.

pairing

COMMAND: 2024-08-08 19:47:16 Message(ffffffff seq:00 [AssignAddressCommand(address:ffffffff)]) RESPONSE: 2024-08-08 19:47:17 Message(ffffffff seq:01 [VersionResponse(lot:139948689, tid:1430867, address:ffffffff, firmwareVersion:4.10.0, iFirmwareVersion:1.4.0, productId:4, podProgressStatus:Reminder initialized, gain:0, rssi:0, pulseSize:NA, secondsPerBolusPulse:NA, secondsPerPrimePulse:NA, primeUnits:NA, cannulaInsertionUnits:NA, serviceDuration:NA, )]) COMMAND: 2024-08-08 19:47:17 Message(ffffffff seq:02 [SetupPodCommand(address:171aeacd, dateComponents:year: 2024 month: 8 day: 8 hour: 19 minute: 47 , lot:139948689, tid:1430867, packetTimeoutLimit:4)]) RESPONSE: 2024-08-08 19:47:17 Message(ffffffff seq:03 [VersionResponse(lot:139948689, tid:1430867, address:171aeacd, firmwareVersion:4.10.0, iFirmwareVersion:1.4.0, productId:4, podProgressStatus:Pairing completed, gain:NA, rssi:NA, pulseSize:0.05, secondsPerBolusPulse:2.0, secondsPerPrimePulse:1.0, primeUnits:2.6, cannulaInsertionUnits:0.5, serviceDuration:288000.0, )])

prime setup

COMMAND: 2024-08-08 19:47:17 Message(171aeacd seq:04 [FaultConfigCommand(nonce:494e532e, tab5Sub16:0, tab5Sub17:0)]) RESPONSE: 2024-08-08 19:47:17 Message(171aeacd seq:05 [StatusResponse(deliveryStatus:Suspended, progressStatus:Pairing completed, timeActive:2m, reservoirLevel:50+, insulinDelivered:0.00, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:4, alerts:No alerts)]) COMMAND: 2024-08-08 19:47:18 Message(171aeacd seq:06 [ConfigureAlertsCommand(nonce:494e532e, configurations:[ AlertConfiguration(slot:slot7Expired, duration:55m, trigger:triggerTime=5m, beepRepeat:every5Minutes, beepType:bipBeepBipBeepBipBeepBipBeep)])]) RESPONSE: 2024-08-08 19:47:18 Message(171aeacd seq:07 [StatusResponse(deliveryStatus:Suspended, progressStatus:Pairing completed, timeActive:2m, reservoirLevel:50+, insulinDelivered:0.00, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:6, alerts:No alerts)])

start prime bolus @ 19:47:18, finishes at 19:48:10

COMMAND: 2024-08-08 19:47:18 Message(171aeacd seq:08 [SetInsulinScheduleCommand(nonce:494e532e, bolus(units: 2.6, timeBetweenPulses: 1.0, table: OmniBLEParser.BolusDeliveryTable(entries: [InsulinTableEntry(segments:1, pulses:52, alternateSegmentPulse:false)]))), BolusExtraCommand(units:2.6, timeBetweenPulses:1.0, extendedUnits:0.0, extendedDuration:0.0, acknowledgementBeep:false, completionBeep:false, programReminderInterval:0.0)]) RESPONSE: 2024-08-08 19:47:18 Message(171aeacd seq:09 [StatusResponse(deliveryStatus:Priming, progressStatus:Priming, timeActive:2m, reservoirLevel:50+, insulinDelivered:0.00, bolusNotDelivered:2.60, lastProgrammingMessageSeqNum:8, alerts:No alerts)])

insert cannula setup, program basal & set more alerts

COMMAND: 2024-08-08 19:49:43 Message(171aeacd seq:10 [SetInsulinScheduleCommand(nonce:494e532e, basalSchedule(currentSegment: 39, secondsRemaining: 617, pulsesRemaining: 5, table: BasalDeliveryTable([InsulinTableEntry(segments:3, pulses:12, alternateSegmentPulse:false), InsulinTableEntry(segments:2, pulses:11, alternateSegmentPulse:false), InsulinTableEntry(segments:3, pulses:9, alternateSegmentPulse:true), InsulinTableEntry(segments:1, pulses:8, alternateSegmentPulse:false), InsulinTableEntry(segments:4, pulses:7, alternateSegmentPulse:true), InsulinTableEntry(segments:16, pulses:13, alternateSegmentPulse:false), InsulinTableEntry(segments:2, pulses:13, alternateSegmentPulse:false), InsulinTableEntry(segments:12, pulses:14, alternateSegmentPulse:true), InsulinTableEntry(segments:5, pulses:16, alternateSegmentPulse:false)]))), OmniBLEParser.BasalScheduleExtraCommand(blockType: OmniBLEParser.MessageBlockType.basalScheduleExtra, acknowledgementBeep: false, completionBeep: false, programReminderInterval: 0.0, currentEntryIndex: 5, remainingPulses: 48.5, delayUntilNextTenthOfPulse: 87.24138, rateEntries: [RateEntry(rate:1.2, duration:1h30m), RateEntry(rate:1.1, duration:1h), RateEntry(rate:0.95, duration:1h30m), RateEntry(rate:0.75, duration:2h30m), RateEntry(rate:1.3, duration:9h), RateEntry(rate:1.45, duration:6h), RateEntry(rate:1.6, duration:2h30m)])]) RESPONSE: 2024-08-08 19:49:43 Message(171aeacd seq:11 [StatusResponse(deliveryStatus:Scheduled basal, progressStatus:Basal initialized, timeActive:4m, reservoirLevel:50+, insulinDelivered:2.40, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:10, alerts:No alerts)]) COMMAND: 2024-08-08 19:49:43 Message(171aeacd seq:12 [ConfigureAlertsCommand(nonce:494e532e, configurations:[ AlertConfiguration(slot:slot2ShutdownImminent, trigger:triggerTime=78h56m, beepRepeat:every15Minutes, silent:true), AlertConfiguration(slot:slot3ExpirationReminder, trigger:triggerTime=69h56m, beepRepeat:every1MinuteFor3MinutesAndRepeatEvery15Minutes, silent:true), AlertConfiguration(slot:slot4LowReservoir, trigger:10U, beepRepeat:every1MinuteFor3MinutesAndRepeatEvery60Minutes, silent:true), AlertConfiguration(slot:slot7Expired, duration:7h, trigger:triggerTime=71h56m, beepRepeat:every60Minutes, silent:true)])]) RESPONSE: 2024-08-08 19:49:43 Message(171aeacd seq:13 [StatusResponse(deliveryStatus:Scheduled basal, progressStatus:Basal initialized, timeActive:4m, reservoirLevel:50+, insulinDelivered:2.40, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:12, alerts:No alerts)])

start cannula insert bolus at 19:49:44, finishes at 19:49:54

COMMAND: 2024-08-08 19:49:44 Message(171aeacd seq:14 [SetInsulinScheduleCommand(nonce:494e532e, bolus(units: 0.5, timeBetweenPulses: 1.0, table: OmniBLEParser.BolusDeliveryTable(entries: [InsulinTableEntry(segments:1, pulses:10, alternateSegmentPulse:false)]))), BolusExtraCommand(units:0.5, timeBetweenPulses:1.0, extendedUnits:0.0, extendedDuration:0.0, acknowledgementBeep:false, completionBeep:false, programReminderInterval:0.0)]) RESPONSE: 2024-08-08 19:49:44 Message(171aeacd seq:15 [StatusResponse(deliveryStatus:Bolusing, progressStatus:Inserting cannula, timeActive:4m, reservoirLevel:50+, insulinDelivered:2.40, bolusNotDelivered:0.50, lastProgrammingMessageSeqNum:14, alerts:No alerts)])

check cannula insertion get command at 19:49:54, successfully has progressStatus of Normal (ready to go)

COMMAND: 2024-08-08 19:49:54 Message(171aeacd seq:00 [GetStatusCommand(normal)]) RESPONSE: 2024-08-08 19:49:54 Message(171aeacd seq:01 [StatusResponse(deliveryStatus:Scheduled basal, progressStatus:Normal, timeActive:4m, reservoirLevel:50+, insulinDelivered:2.90, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:14, alerts:No alerts)])

Apparent app restart by user at 2024-08-08T19:50:33 with continuing startup messages through 2024-08-08T19:50:35

2024-08-08T19:50:33 [Default] FreeAPSApp.swift - init() - 56 - DEV: Trio Started: v0.2.0(23) [buildDate: Optional(2024-08-07 06:48:56 +0000)] [buildExpires: Optional(2024-11-05 05:48:56 +0000)]

Initial getStatusCommand performed on app start up

COMMAND: 2024-08-08 19:50:36 Message(171aeacd seq:02 [GetStatusCommand(normal)]) RESPONSE: 2024-08-08 19:50:37 Message(171aeacd seq:03 [StatusResponse(deliveryStatus:Scheduled basal, progressStatus:Normal, timeActive:5m, reservoirLevel:50+, insulinDelivered:2.90, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:14, alerts:No alerts)])

Lots of OpenAPS logging from 2024-08-08T19:50:39 to 2024-08-08T19:50:45

Set TB & do 0.2U auto bolus

COMMAND: 2024-08-08 19:50:45 Message(171aeacd seq:04 [SetInsulinScheduleCommand(nonce:494e532e, tempBasal(secondsRemaining: 1800, firstSegmentPulses: 0, table: BasalDeliveryTable([InsulinTableEntry(segments:2, pulses:0, alternateSegmentPulse:false)]))), TempBasalExtraCommand(completionBeep:false, programReminderInterval:0s, remainingPulses:0.2, delayUntilFirstPulse:5h, rateEntries:[RateEntry(rate:0.01, duration:1h)])]) RESPONSE: 2024-08-08 19:50:45 Message(171aeacd seq:05 [StatusResponse(deliveryStatus:Temp basal running, progressStatus:Normal, timeActive:5m, reservoirLevel:50+, insulinDelivered:2.90, bolusNotDelivered:0.00, lastProgrammingMessageSeqNum:4, alerts:No alerts)]) COMMAND: 2024-08-08 19:50:45 Message(171aeacd seq:06 [SetInsulinScheduleCommand(nonce:494e532e, bolus(units: 0.2, timeBetweenPulses: 2.0, table: OmniBLEParser.BolusDeliveryTable(entries: [InsulinTableEntry(segments:1, pulses:4, alternateSegmentPulse:false)]))), BolusExtraCommand(units:0.2, timeBetweenPulses:2.0, extendedUnits:0.0, extendedDuration:0.0, acknowledgementBeep:false, completionBeep:false, programReminderInterval:63.0)]) RESPONSE: 2024-08-08 19:50:46 Message(171aeacd seq:07 [StatusResponse(deliveryStatus:Bolusing with temp basal, progressStatus:Normal, timeActive:5m, reservoirLevel:50+, insulinDelivered:2.90, bolusNotDelivered:0.20, lastProgrammingMessageSeqNum:6, alerts:No alerts)])

N.B. No comms issues observed and commands, responses and their timing all looks as expected.

To Reproduce

Unknown how to reproduce the Insert Cannula view continuing back to the same view.

Getting stuck in the Insert Cannula screen can be reproduced by having the pumpManager returning a .podAlreadyPaired error or by having the InsertCannulaView_Previews code return a .podAlreadyPaired error instead of a success mockDelay.

Expected behavior

If the Insert Cannula view ever gets a podAlreadyPaired return, it should treat it as success and allow the user to continue on instead of being stuck forever displaying a Pod Already Paired error when the pod is already to go.

Screenshots

Pod-Already-Paired-Error

Setup Information (please complete the following information):

Smartphone:

Pump:

CGM:

Trio Version:

Technical Details

If applicable, provide any technical details that might help in diagnosing the problem. This could include logs, error messages, or relevant configuration details. See above details and the highlighted Discord posts.

Additional context

The podAlreadyPaired error is only returned in one place in the Omni{BLE,Kit}PumpManager code -- when the pumpManager.insertCannula() is called for a pod which setupProgress indicates that the pod's setupProgress variable indicates that the pod setup is complete. But if this special podAlreadyPaired "error" is ever returned and treated like any other error, the app will be stuck as nothing will change on subsequent Retries. The only recovery possible is restarting the app [or deactivating the already completely setup up pod].