Skip to content

Conversation

@codebymini
Copy link
Collaborator

@codebymini codebymini commented Aug 12, 2025

Share settings (nightscout url and remote settings) with QR code

Overview

This commit implements a comprehensive QR code sharing system for remote command settings, allowing users to easily import and export their remote configuration between LoopFollow apps.

New Features

  • QR Code Import/Export: Users can now scan QR codes to import remote settings or generate QR codes to share their own settings
  • Smart Device Detection: Automatically detects and sets device type (Loop/Trio) based on imported remote type
  • URL/Token Validation: Handles conflicts between existing and imported Nightscout URLs/tokens with user confirmation
  • Import Settings Menu: Added "Import Settings" option in settings menu when no Nightscout URL is configured

New Components

  • QRCodeGenerator.swift - Core QR code generation with customizable colors and sizes
  • QRCodeDisplayView.swift - SwiftUI view for displaying generated QR codes
  • RemoteCommandSettings.swift - Data structure for encoding/decoding remote settings
  • URLTokenValidationView.swift - Interface for resolving URL/token conflicts during import

Enhanced Functionality

  • RemoteSettingsView: Added QR code import/export buttons and validation flows
  • RemoteSettingsViewModel: Extended with QR code handling and device type management
  • SettingsMenuView: Added conditional "Import Settings" option for users without Nightscout URL
  • LogManager: Added new "Remote" logging category for tracking import/export operations

Technical Improvements

  • Automatic device type detection based on remote type (Loop APNS → Loop, TRC → Trio)
  • Comprehensive validation of imported settings before application
  • Graceful handling of URL/token conflicts with user choice
  • Proper error handling and user feedback throughout the import process

Benefits

  • Easy Setup: Users can quickly configure remote settings by scanning a QR code
  • Device Compatibility: Automatically configures the correct device type for imported settings
  • Conflict Resolution: Smart handling of Nightscout configuration conflicts
  • User Experience: Seamless import/export workflow with clear feedback and validation
    This feature significantly improves the user experience for setting up remote commands, especially for users who need to configure multiple devices or share settings with others.

@bjorkert bjorkert marked this pull request as draft August 13, 2025 18:57
@codebymini codebymini changed the title Add sharing settings with QR code Share settings (nightscout url and remote settings) with QR code Aug 13, 2025
@bjorkert bjorkert marked this pull request as ready for review August 27, 2025 06:42
codebymini added a commit to CodeByMiniOrg/LoopFollow that referenced this pull request Sep 30, 2025
@marionbarker
Copy link
Collaborator

Test

Summary

  • Using SE phones with iOS 18.7 and iOS 26.0, this worked well
  • The transfer is not successful with the iOS 16 phone

Test Details

Delete settings and restore

  • Delete the remote settings from one phone
  • configure remote settings to None
  • import from QR screen on other phone - success
  • able to issue remote carbs, bolus and override.

Test first with Trio then Loop

Delete app and start fresh

  • Delete the app from one phone
  • Cannot import in this situation because Remote Settings - None is not available
  • enter URL but no token
  • can now select remote settings none and import

trio vs loop

  • When importing information from one phone configured for Trio/Loop remote control to a different phone previously set up for Loop/Trio, the URL and token are reported as different, but if you choose to accept, then the information is transferred. You may need to wait for the next cycle for the debug information to be filled out before you can use the new phone for remotes.

iOS 26

I'm noticing some iOS 26 issue, but I'll write those up separately. Not related to this PR.

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.

Minimal testing done but seems to work really well.

  • It is not available for an IOS 16 phone with this implementation, but this is an enhancement which adds a very nice capability

@marionbarker marionbarker merged commit a8d78f2 into loopandlearn:dev Oct 1, 2025
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