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 531 forks source link

Fix G7 plist File State Management #376

Closed dnzxy closed 3 months ago

dnzxy commented 3 months ago

Addresses #354 and handles glucose source changes so that the binary file is properly updated, solving an issue where Trio reverts back to old G7 transmitter IDs.

Additionally, this PR also holds a small fix by @bjorkert to be able to build Trio when the code base sits at a tag or a detached head.

marionbarker commented 3 months ago

Status

Successful tests

Configuration

I did this testing using dnzxy/fix/trio-g7-statemanagement, commit 2c1b921d, which is the same commit used for this PR.

G7 Sensor Identifiers

I am wearing two G7 sensors identified as:

Method to swap sensors without losing them

Thanks to @bjorkert for this method.

  1. go in to bluetooth, select the G7 sensor DXCMxx value, forget this item.
  2. turn off bluetooth.
  3. In the G7 app, select stop sensor
    • it will not be stopped for real since phone has no contact with it.
  4. Swipe up and kill the G7 app (without restarting the app, it gets a bit confused).
  5. Enable bluetooth.
  6. Start Dexcom G7 app and scan the applicator for the new sensor.

Behavior after swap sensor

Once Dexcom G7 app pairs with the designated sensor, monitor Trio while Loop reports its glucose reading in the dynamic island.

CGMManagetState.plist file with 2 different G7 sensors

plist-g7-sensors

Binary versions of the 2 plist files are in this zip file: CMG-plist.zip

marionbarker commented 3 months ago

The other thing I noted while testing this code was that once it connected to the G7 sensor, the CGMManagerState.plist updates the timestamp every time a CGM reading comes in. So it always has the most up-to-date information from the app.

Sjoerd-Bo3 commented 3 months ago

@dnzxy Is it not wise to put the detached state into it own PR? Thats cleaner to search if ever needed to. At least put it in the title if we leave it in here

bjornoleh commented 3 months ago

@dnzxy Is it not wise to put the detached state into it own PR? Thats cleaner to search if ever needed to. At least put it in the title if we leave it in here

It is also not required for testing of this PR, as it is on a branch. So it can safely be removed from here.

dnzxy commented 3 months ago

As per request (@Sjoerd-Bo3, @bjornoleh) removed the capture build fix and opened a distinct PR (#378) for it.

@marionbarker and @avouspierre, please re-approve the PR due to the changes.

marionbarker commented 3 months ago

Status

Successful test

Steps Taken

  1. Confirmed the last commit only remove the change to scripts/capture-build-details.sh
  2. Update to commit 37f2e7ca of dnzxy/fix/trio-g7-statemanagement
  3. Build to iPhone 15 pro, iOS 17.6 running Loop, Trio and Dexcom G7

Repeat the test from https://github.com/nightscout/Trio/pull/376#issuecomment-2278890551

This time, transition from Sensor 2 (DXCM3g) to Sensor 1 (DXCMJd).

marionbarker commented 3 months ago

Status

Success

More Testing

Build dev:

Sensor Swap with dev:

The CGMManagerState.plist file does not include the DXCMJd as was seen with the code from this PR.

This screenshot is dated 07:39, while dev build was on phone.

plist-file-dev

Build fix/trio-g7-statemanagement

plist-file-fix-g7

aug0211 commented 3 months ago

Went through a standard G7 switch from old sensor to new sensor.

Successful with no manual interventions.

Started new sensor on Dexcom G7 app, and Trio saw the new sensor on its own.

t1dude commented 3 months ago

Tested successfully in vivo.

Sjoerd-Bo3 commented 3 months ago

Transition to new sensor in vivo success. Id in plist file found.