Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix G7 plist File State Management #376

Merged
merged 9 commits into from
Aug 11, 2024

Conversation

dnzxy
Copy link
Contributor

@dnzxy dnzxy commented Aug 9, 2024

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
Copy link
Contributor

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.

  • I used my Loop iPhone 15, iOS 17.6
  • Build Trio configured just to use G7 as a CGM with nothing else enabled

G7 Sensor Identifiers

I am wearing two G7 sensors identified as:

  • Sensor 1: DXCMJd (on left arm) Pairing code 9280
  • Sensor 2: DXCM3g (on right arm) Pairing code 5764

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.

  • Trio and Loop update at the same time
  • I did multiple swaps (from 1 to 2, 2 to 1 and then finally 1 to 2)
  • In each case, both Trio and Loop picked up the correct DXCM at the next CGM reading after the Dexcom G7 app paired with the sensor.

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
marionbarker previously approved these changes Aug 9, 2024
@marionbarker
Copy link
Contributor

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.

avouspierre
avouspierre previously approved these changes Aug 10, 2024
Copy link
Contributor

@avouspierre avouspierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked the code and confirm no regressive bug for others CGM

@Sjoerd-Bo3
Copy link
Contributor

@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
Copy link
Contributor

@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 dnzxy dismissed stale reviews from avouspierre and marionbarker via 4d4c6b4 August 10, 2024 14:38
@dnzxy
Copy link
Contributor Author

dnzxy commented Aug 10, 2024

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.

@dnzxy dnzxy force-pushed the fix/trio-g7-statemanagement branch from 4d4c6b4 to 37f2e7c Compare August 10, 2024 14:47
@marionbarker
Copy link
Contributor

marionbarker commented Aug 10, 2024

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 #376 (comment)

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

  • Dexcom App pairs.
  • Loop shows "Searching for Sensor", Trio shows stale reading.
  • Wait for next CGM reading
  • Both Loop and Trio pick up the new sensor
  • CGMManagerState.list timestamp is current and shows DXCMJd

Copy link
Contributor

@avouspierre avouspierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a recheck and deployment with G6 successfully.

@marionbarker
Copy link
Contributor

Status

Success

More Testing

  • Return to dev to observe differences with G7 behavior.

Build dev:

  • Sensor 1 is currently the one being read by Dexcom G7 app
  • Configuration: branch dev, commit c8385cc
    • build onto Loop/Trio phone
    • timestamp for plist: 06:54 PDT = same as build time
  • wait 20 minutes, observe each CGM reading comes in as expected
    • plist timestamp remains 06:54 PDT
  • Notice at 7:20, the HUD value does not update, but the Loop and Trio G7 screen both have newer reading
    • At 7:23 - same thing, HUD is out of date and with red loop

Sensor Swap with dev:

  • perform the sensor swap using the Bluetooth trick
    • this time see if I can add back the same sensor or if it has to be a different one.
    • trick worked fine, Dexcom G7 paired back with Sensor 1
  • Loop shows Searching for Sensor
  • Put Trio in foreground, wait for HUD CGM value to update
  • Loop picked up sensor 1 and so did Trio, green loop
    • plist timestamp updated to 07:34

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

  • Configuration: branch fix/trio-g7-statemanagement, commit 37f2e7c
    • plist timestamp initially build time of 07:42 and also does not include the DXCMJd for Sensor 1
  • wait for next CGM reading, which comes in at 07:43
    • plist timestamp updates to 07:43 and contains the DXCMJd indicator for Sensor 1

plist-file-fix-g7

Copy link
Contributor

@Sjoerd-Bo3 Sjoerd-Bo3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the trick also worked for me, will make definive reciew once normal change is coming up.

@Sjoerd-Bo3 Sjoerd-Bo3 merged commit 3955e96 into nightscout:dev Aug 11, 2024
1 check passed
@aug0211
Copy link
Contributor

aug0211 commented Aug 12, 2024

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.

@aug0211 aug0211 self-assigned this Aug 12, 2024
Copy link
Contributor

@aug0211 aug0211 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in vivo successfully.

@t1dude
Copy link
Contributor

t1dude commented Aug 12, 2024

Tested successfully in vivo.

@Sjoerd-Bo3
Copy link
Contributor

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

@MikePlante1 MikePlante1 mentioned this pull request Aug 17, 2024
mountrcg pushed a commit to mountrcg/Trio that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants