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

Trio remote control #328

Merged
merged 38 commits into from
Dec 6, 2024
Merged

Trio remote control #328

merged 38 commits into from
Dec 6, 2024

Conversation

bjorkert
Copy link
Contributor

@bjorkert bjorkert commented Sep 29, 2024

Remote Control for Trio 1.0

In LoopFollow, a new option is introduced in Remote Settings: Trio Remote Control.
This new Remote Control features Apple Push Notifications in order to deliver remote commands to Trio.

You will need to enter a shared secret (Available in Trio), your APNS Key ID and APNS Key.

There are also guardrails available for bolus, carbs, protein and fat.

In the remote tab, you can use Meal for sending remote carbs/fat/protein. Bolus for remote bolusing. Temp Target for setting a temp target (or set up preset temp targets that are locally in your LoopFollow) or use Overrides (defined in Trio).

When sending a command, you will get a message indicating if the sending is a success or not. This does not mean that Trio has acted on the command. Depending on many factors, it can take from seconds (if the app is open, good network coverage) or many minutes (if the phone is used for playing games that takes lots of resources). Trio will accept a message that is up to 10 minutes old, after that it will be rejected. Trio will also reject a bolus or carbs command if there was other boluses or carbs entries created after the command was created, in order to avoid overdosing. If Trio rejects a command, it will be logged as a Note-entry, visible in LoopFollow and Nightscout.

@bjorkert bjorkert marked this pull request as draft October 12, 2024 18:09
@marionbarker
Copy link
Collaborator

Status

Success

Comments

This comment only covers the Trio 0.2.2 portions of this interface between LoopFollow and Trio.

LoopFollow interacts with TempTargets for Trio 0.2.2 using the new Remote icon on the main screen toolbar.

No other remote features using LoopFollow as entry mechanism are available using this branch with Trio 0.2.2.

Requests

I think the LoopFollow, Settings, Remote Settings screen needs some information included on screen.

Remote Type shows as None, Nightscout or Trio Remote Control

Possible words to add:

  • Nightscout is the only option available for released version of Trio
  • Trio Remote Control requires a special version of Trio, which is under development in a private repository until sufficient testing is completed.

Test Summary Results

Changes update quickly to plots for LoopFollow (LF), Nightscout (NS) and Trio phone except for the LF Info Table which is fed from the OpenAPS pill. The OpenAPS pill updates with the next cycle, and then the LF Info Table updates. I believe this is expected behavior but needs to be explained in the LoopFollow remote documentation.

Remote Settings Choices

  • Remote Settings = None and tap on Remote in toolbar, told to go to settings
  • Remote Settings = Nightscout (see test results below)
  • Remote Settings = Trio Remote Control (shows a bunch of fields to fill out that require the private testing version)
    • The 4 icons that work with the private version of Trio show up
    • If a user attempts to use one, they are told there are missing fields.

Tests with Nightscout Option

All these test were successful and behaved as expected:

  1. set a TT on Trio phone and see it appear on NS and LF plots; update in OpenAPS pill and LF Info Table at next cycle
  2. cancel that same TT on LoopFollow phone and see it cancel on NS and Trio plots; update in OpenAPS pill and LF Info Table at next cycle
  3. set a TT on LF phone and see it appear on NS and Trio plots; update in OpenAPS pill and LF Info Table at next cycle
  4. cancel the TT on Trio phone and see it cancel on NS and LF plots; update in OpenAPS pill and LF Info Table at next cycle
  5. create two named TT in LF and then choose one; see it appear on NS and Trio plots; update in OpenAPS pill and LF Info Table at next cycle
  6. enable named TT in LF, wait for it to appear in NS, Trio and OpenAPS pill; and then cancel the TT using NS Careportal with entered by set to remote - behaves as expected

Copy link
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

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

See my comments. IMO, this can be merged to dev (for Trio 0.2.2 use) without modification although I think the added information on the Remote Settings page would be helpful.

@bjorkert
Copy link
Contributor Author

@marionbarker, just pushed "Instructions for Remote Type options".
I think it would be good to merge to dev now, I have some other non-trio features I would like to add.
Simulator 2024-11-10 13 01 36

@bjorkert bjorkert marked this pull request as ready for review November 10, 2024 12:04
@marionbarker
Copy link
Collaborator

Status

Successful test for Trio 0.2.2 on "looper's" phone

Configuration

  • looper's phone is an iPhone SE running 18.1 with an rPi pump and NS as a CGM
    • Trio 0.2.2 (main branch, commit d97ee5e8)
  • LoopFollow phone is an iPhone 7+ running 15.8.3
    • trio_remote_control branch, commit 42f8558

Tests for Trio 0.2.0

Message on LoopFollow Settings Remote Control

  • added message is good when selecting the 3 options

From LoopFollow send temp target commands to Trio phone

  • success: message that it was sent to NS is seen but nothing happens on Trio phone when remote control is disabled on the trio phone
  • success: temporary target (value and duration), seen on LF, NS and Trio main screen (upper bar)
    • cancel it early from LoopFollow phone and it is cancelled from NS, Trio and LF phones
    • go to Temp Target screen on Trio phone (it doesn't show up except on main screen), tap cancel and it is cancelled on Trio phone and NS; after refresh, it goes away on LoopFollow phone
  • success: save as preset and send the named preset (shows up with target value, top of Trio main display); let it run planned duration
    • Named presets names created on LoopFollow phone, visible only on LoopFollow side

From Trio phone, apply temp target and override

  • create a named preset and apply, it appears in NS and on LoopFollow phone
    • Named presets names created on Trio phone, visible only on Trio side
    • cancel temp target on LoopFollow phone, it is canceled in NS and on Trio phone

@marionbarker
Copy link
Collaborator

Status:

Success when credentials are correct, remote commands from LoopFollow to Trio work
Cancel running overrides and TT on Trio appear to work, but might need more testing.

  • I did not layer TT and Overrides.

The testing of credentials will be done in another comment.

Configuration

LF phone is iPhone 8 running iOS 16
Configure Remote Settings to use Trio Remote Control

  • include Shared Secret, APNS Key ID and APNS Key
  • configure max Bolus of 1.0
  • configure max carbs, protein and fat of 30 g
  • start with these disabled: Meal with Bolus, Meal with Fat/Protein

Trio phone is iPhone SE running iOS 18.1

  • commit is fbdc3a2ad from private Trio-dev repository

Tests

Remote commands to Trio from LoopFollow

Define success as command is seen on Trio phone and Nightscout display and echoed back appropriately to LF phone (target changes are not seen in the Information Table untl the next cycle, but show up promptly after a refresh on the plot)
Define guardrail as command was rejected on LF phone as exceeding a guardrail

Set 1:

  • carbs
    • 4 g: success
    • 45 g: guardrail success (slight UI issue reported via PM)
    • 30 g: success
    • 15 g, later: success
    • WARNING: NS only allows one carb entry per timestamp.
      • sent carb value for specific time, e.g., 09:55, only the most recent one shows up
      • sent 1, then 4, then 1 all for for future time of 09:55; check each treatments - only the most recent is there in NS
      • all of them are present in Trio
      • solution in Loop was to use the seconds for the entry so that 09:55 shows up as different time stamps in NS
  • bolus
    • 2 U: guardrail success
    • 0.5 U: success
  • Temp Target
    • The temp target names are created on the LF phone
    • Create and save named TT: success
    • Enact named TT: success (shows up on Trio promptly; need to refresh or wait for it to show up on LF phone)
    • Cancel active TT on LF phone
  • Overrides
    • The named overrides are shared from the Trio phone
    • Enact named Override: success (shows up on Trio promptly; need to refresh or wait for it to show up on LF phone)
    • Cancel active Override on LF phone

Set 2

  • enabled: Meal with Bolus
  • enter carbs and bolus: success
    • hint should be updated for Schedule for Later to indicate the carbs are later, the bolus is now
  • enable: Meal with Fat/Protein
  • enter carbs, protein, fat and bolus: success

@marionbarker
Copy link
Collaborator

Status

The Browser Build for Trio does not seem to work.

Test build source for Trio

Determine if the remote control works from the same LoopFollow phone using different build methods.

  1. The previous comment used a build for the Trio phone created with Xcode 16.1 using manually signed targets.
    • NS profile items: "teamID":"myvalue", "isAPNSProduction":false, "deviceToken":"427a5b etc"
    • all remote commands work
  2. Install a GitHub Browser Build version for Trio phone
    • NS profile items: "teamID":"myvalue", "isAPNSProduction": true, "deviceToken":"b2981b etc"
    • remote control does not work from LoopFollow phone
    • start an override from Trio phone, observe it on NS and LF - cancel the override from LF phone, command is accepted but it does not cancel anything
  3. Fresh build for the Trio phone created with Xcode 16.1 using automatically signed targets.
    • NS profile items: "teamID":"myvalue", "isAPNSProduction":false, "deviceToken":"427a5b etc"
    • all remote commands work

@marionbarker
Copy link
Collaborator

Status

My credential tests were successful. Warning - another user reports he is still having trouble with his credentials.

Update since last test

The Browser Build method for Trio-dev (private repo) was updated. It now has the correct value for isAPNSProduction and for teamID.

The Mac-Xcode build method for Trio-dev (private repo) was updated. It now has correct value for teamID regardless of the signing method.

Build using this new version and see what it takes to update or remove valid credentials from the LoopFollow-Trio phone pair.

Configuration

  • iPhone 8: LoopFollow: cb55221
  • iPhone SE: Trio-dev:fbdc3a2ad (browser build version)
  • Nightscout Site: created using Google Cloud method, version 15.0.2

Testing

The initial state was that all remotes were all working.

Credential Test 1

Install an old version of the browser build that should fail becauseisAPNSProduction andteamID are incorrect.

  • Intially remotes continue to work, so clearly there is some memory that allows this to keep working
    • In previous tests, when I tested the next day, the status (working or not working) changed to match the state of the credentials (valid or invalid)
  1. Select Nightscout in LoopFollow, Settings, Remote Settings
    • Test sending a TempTarget (all that is available with Nightscout selection) - this works
  2. Select Trio Remote Control in LoopFollow, Settings, Remote Settings
    • Test sending a Override - LoopFollow reports a Credential error and doesn't try to send remote

Credential Test 2

Build with Xcode (same fbdc3a2ad commit) using manual signing and removing the override config file.

  1. Attempt to send a remote command and get the same Credential error on LoopFollow phone (even though it should now be correct.)
  2. Select None in LoopFollow, Settings, Remote Settings
    • Get the nice message: Please select a Remote Type in Settings.
  3. Select Trio Remote Control in LoopFollow, Settings, Remote Settings
    • Test sending a Override from LoopFollow - it is accepted and seen in Nightscout, Trio and LoopFollow phones
    • Repeat a hand full of other remotes, they all work as expected

@marionbarker
Copy link
Collaborator

Status Summary

These are items that I noted need to be fixed before this can be merged to dev branch of LoopFollow.

Credential Issues

  • At this point in time, there is still one tester who is having trouble with credentials.

LoopFollow Issues

  • The behavior when carbs exceed maxCarb is not the same as when the bolus exceeds maxBolus
    • Tap Send Meal directly, the carb count is decreased without warning and user is asked to Confirm
    • Tap keyboard icon, the expected Validation Error is displayed
  • The timestamp for uploading carb entries to Nightscout (especially when selecting carbs in the future) needs to include at least the current seconds and not just hh:mm:00.
  • The Meal with Bolus option for Meal entry sends a bolus command without requesting authorization, this should be updated to require authorization.
  • The Meal with Bolus option for Meal should have an extra note, e.g., "Carbs are entered in the future, while bolus is enacted now."

@marionbarker
Copy link
Collaborator

Status:

The earlier tests were all done with the Trio phone unlocked.
It is important to test with the phone locked to see how this works with Trio in the background.
All remote commands were successful even with Trio phone locked.

Configuration

  • Both phones are on the same WiFi network (no cell service)
  • Trio phone, private repo commit fbdc3a2ad
    • using Nightscout (glucose near 110 mg/dL) as CGM
    • using MDT 515 pump with rileylink
  • LoopFollow phone, commit cb55221

Test 1 - phone recently locked

Performed 2024-11-19:
Do a few sample remote commands from LoopFollow phone, observe on Nightscout display and pump

  • 06:18 remote 10 g carb; see it on NS
  • 06:22 remote 1 U bolus; observe MDT pump see it about 6:24 and then in NS too
  • 06:26 remote 15 g carb; 06:27 see it in NS
    • 06:34 NS shows a TB of 0 followed by TB of 0.85 U/hr (scheduled is 0.6 U/hr)
  • 06:35 issue higher temp target (150 mg/dL for 10 min) - should respond with decreased basal
    • shows up on NS and LF phone
    • 06:39 observe return to scheduled basal on NS

Test 2 - phone locked more than one hour

Performed 2024-11-19:
Do a few sample remote commands from LoopFollow phone, observe on Nightscout display and pump

  • 07:45 remote 11 g carb; see it on NS at 07:46
  • 07:47 remote 0.5 U bolus; observe MDT pump see it about 07:48 and then in NS too
  • 07:50 remote 30 g carb; 07:50 see it in NS within a few seconds
    • NS shows a TB of 0 at time carb enter was sent, but glucose is flat so don't expect to see much action
    • next OpenAPS update on NS: remains a 0 TB.
  • 08:06 issue higher target override (180 mg/dL for 15 min)
    • shows up on NS and LF phone

Evaluate on Trio:

open Trio phone

  • confirm all remotes show up in history
  • the carbs are there
  • the manual boluses are there
  • the target changes are plotted
  • the active override is displayed in main screen

@marionbarker marionbarker merged commit 0d79ca9 into dev Dec 6, 2024
@bjorkert bjorkert deleted the trio_remote_control branch December 6, 2024 19:09
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.

2 participants