Repository navigation
Switch Loop profiles from the Loop remote screen - #790
Conversation
Adds a Profiles button that lists the profiles Loop uploads to Nightscout, previews one the way Loop does and sends an OTP-protected profile switch with a fingerprint of the previewed values. Loop's return push is matched by profile name. The button is greyed out with an explanation when Loop does not list profile-switch in remoteCommands.
…ofile-switch # Conflicts: # LoopFollow/Remote/LoopAPNS/LoopAPNSService.swift
There was a problem hiding this comment.
❌ An authorization on the LoopFollow phone must be required before allowing remote change of profile.
Loop phone is main branch (v3.14.11) plus the one customization profiles using the remote_profile branch.
LoopFollow phone is feature/loop-remote-profile-switch 985338e
Test✅ When the Loop on the other side of the NS URL that LoopFollow is following does not have the customization, the icon for Profiles is not blue and when you tap on it the message is clear.
❌ This is on the customization side, I think
|
TestThe customization was updated. Built new code on the Loop phone with the customization updated to loopandlearn/customization@2a2013a ✅ On Loop phone, load a saved profile, return to profile row and note that the current profile is indicated and does not report that it needs to be updated |
marionbarker
left a comment
There was a problem hiding this comment.
Approve by code review and test.
When the customization is not applied or not available, the Profile feature shows as not available. So this can be merged independently.
TestAfter the customization was updated, test main and next-dev independently Test with customization on Loop phoneCustomization is applied on Loop phone. |
Adds a Profiles button to the Loop remote screen for switching Loop to one of the profiles saved with the profiles customization. It needs Loop built with the profiles customization that includes remote switching (loopandlearn/customization#107).
The button is blue when Loop lists profile-switch in loop.testingDetails.remoteCommands, and grey otherwise; tapping the grey button explains that the profiles customization is needed. The list shows the saved profiles from Loop's latest profile upload with the active one marked. Selecting one shows its correction range, carb ratios, basal rates with the daily total and insulin sensitivities, like Loop's own preview. Activate asks for confirmation and sends an OTP-protected command with a fingerprint of the shown values, so Loop only activates what was previewed. LoopFollow waits up to three minutes for Loop's return push and shows the outcome, including Loop's reason on failure. Replies are matched by profile name, so a late reply for one profile does not resolve a switch to another. A missing reply is shown as unknown, not as a failure, because the switch may still complete. The profile list refreshes after a successful switch.
Like carb edit and delete, the command requires LoopFollow's own APNS credentials so Loop can reply. The shared message for that case now says "This command" instead of naming carb entries.
Tested in the simulator against a local Nightscout and APNs stand-in with a next-dev Loop build carrying the profiles customization: switch, pump failure, profile changed after upload and the greyed-out button. Unit tests cover the payload, the fingerprint (same vector as the Loop side), the profile list and reply matching.
Remote screen, saved profiles, preview and confirmation:
Waiting for Loop, success, and the list after Loop uploaded the switched profile:
Pump communication failure, profile changed in Loop after upload, and a Loop build without the customization: