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

Upload SAGE to NS for Dexcom #355

Merged
merged 1 commit into from
Jul 21, 2024
Merged

Upload SAGE to NS for Dexcom #355

merged 1 commit into from
Jul 21, 2024

Conversation

MikePlante1
Copy link
Contributor

Address Issue #269 when using Dexcom G5, G6 (ONE), or G7 (ONE+) as a CGM source. Note this does not address using xDrip4iOS as a cgm source.

It expands on (and slightly refactors) the LibreTransmitter fix in #112 . Please reference the comments on that PR about adding the LibreTransmitter library (this PR adds the CGMBLEKit and G7SensorKit libraries).

The only testing I've done for this PR is with my in-vivo phone.

  • iPhone 15 ProMax
  • iOS 17.5.1
  • Dexcom G6 via official G6 app
  • Nightscout hosted on GoogleCloud
  • Medtronic 722 + OrangeLink
- Testing still needs to be done using G7

Before building this PR, my phone was at the tip of dev: 9672da2

  • I checked Files > Trio > Monitor and there was no file cgm-state.json
  • On my NS, I generated a 6-month report for Treatments and checked ☑️ Event Type: CGM Sensor Start
  • The most recent entries for CGM Sensor Start are 2024-04-01 and 2024-03-22 but those were from when I used xDrip4iOS and directly uploaded glucose to NS from xDrip4iOS instead of Trio/iAPS.
    prePR NS record xD
  • I did have an entry on 2024-03-07 marked as from iAPS, but if I remember correctly, it was from this repo before it was rebranded as Trio and before the change to submodules here 47fa017
    prePR NS record

After receiving my first reading from G6 after building this PR to my phone:

  • SAGE on Nightscout was updated correctly.
    postPR NS
  • CGM Sensor Start showed up in Treatment report on the correct day
    postPR NS record
  • FIle cgm-state.json now exists in Files > Trio > Monitor
    IMG_5114

@marionbarker
Copy link
Contributor

Status

Everything I could test seemed fine.
I will add an approval knowing that someone else will be checking this.

Code review

Code review looks good - although I wonder if an enum plus case statements is more in keeping with the style of the app.

  • Others need to answer that

Test

  • started with latest dev (no other patches applied), commit 8303f0a
  • applied patch from this PR
  • Built to test phone with no issues
  • Built to real phone on which I use Trio for LiveActivities triggering off my G7 (I run Loop as my OS-AID)
    • Trio missed the most recent glucose - probably because I was building, so wait a few more cycles
    • Trio captured the next few CGM readings - no more misses, showing up in dynamic island and lock screen widget

@marionbarker marionbarker self-requested a review July 21, 2024 00:17
@MikePlante1
Copy link
Contributor Author

Code review looks good - although I wonder if an enum plus case statements is more in keeping with the style of the app.

It looks like the enum for which cgm is being used was just changed to .plugin for all of these, so I just copied the code for Libre. If there's a better way I'm definitely open to hearing it.

Test

  • started with latest dev (no other patches applied), commit 8303f0a

  • applied patch from this PR

  • Built to test phone with no issues

  • Built to real phone on which I use Trio for LiveActivities triggering off my G7 (I run Loop as my OS-AID)

    • Trio missed the most recent glucose - probably because I was building, so wait a few more cycles
    • Trio captured the next few CGM readings - no more misses, showing up in dynamic island and lock screen widget

Is your Trio app connected to a Nightscout account to see if it updates SAGE properly for your G7? One whose SAGE was either out of date or non-existent? I can give you credentials for a spare NS if you need.

@aug0211
Copy link
Contributor

aug0211 commented Jul 21, 2024

Is starting a new CGM required in order to test this, can we test this with an existing/already started CGM?

I suppose we may be able to just forget/remove the existing G7 and re-add in Trio after applying this commit?

@MikePlante1
Copy link
Contributor Author

MikePlante1 commented Jul 21, 2024

Is starting a new CGM required in order to test this, can we test this with an existing/already started CGM?

I suppose we may be able to just forget/remove the existing G7 and re-add in Trio after applying this commit?

(Edit: existing G7 is fine)

Is SAGE currently out-of-date in your NS? If yes, apply this PR and after receiving 1 or 2 readings from G7, check NS to see if SAGE is now updated properly.

@avouspierre
Copy link
Contributor

Even the code introduced specific lib in main code, currently no other simple solution to collect sage information. Probably could be a very good solution to have a generic API / method in loop submodules to retrieve this info and avoid specific code.

@aug0211
Copy link
Contributor

aug0211 commented Jul 21, 2024

Is starting a new CGM required in order to test this, can we test this with an existing/already started CGM?
I suppose we may be able to just forget/remove the existing G7 and re-add in Trio after applying this commit?

(Edit: existing G7 is fine)

Is SAGE currently out-of-date in your NS? If yes, apply this PR and after receiving 1 or 2 readings from G7, check NS to see if SAGE is now updated properly.

Not currently out of date because I use a shortcut to set it.

It sounds like this can be tested with an exciting sensor though, just by clearing the previous sensor date from the backend in NS.

Thanks, will take a look!

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 with G7 in vivo
  • Success
  • Deleted previous sensor change date from Nightscout
  • Confirmed latest sensor age from Nightscout was gone
  • Deployed this code over my live instance of Trio
  • After 1 loop, nothing updated
  • After 2nd loop, the SAGE updated correctly
  • I now also see the sensor insertion date in Nightscout history, noting the sensor bluetooth ID which is nice

Old manual sensor start entry:
01 - Previous Manual Entry

Delete the old entry:
02 - Delete

Confirm the old entry is gone:
03 - Gone

Viola, the new G7 start entry automatically appears:
04 - Back Successfully

@dnzxy
Copy link
Contributor

dnzxy commented Jul 21, 2024

Merging with 3 approvals. Thank you @MikePlante1

@dnzxy dnzxy merged commit f5a8d97 into nightscout:dev Jul 21, 2024
mountrcg pushed a commit to mountrcg/Trio that referenced this pull request Jul 26, 2024
@MikePlante1 MikePlante1 mentioned this pull request Jul 27, 2024
@MikePlante1 MikePlante1 deleted the sage branch August 14, 2024 19:14
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.

5 participants