Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 3, 2026

Implements offline session transfer via Bluetooth to complement Parse-based online transfers. Enables metadata-only song transfers between paired devices within Bluetooth range (WinUI ↔ Android, WinUI ↔ WinUI, Android ↔ Android).

Architecture

Core Services:

  • IBluetoothSessionManagerService - High-level session orchestration, device discovery, pairing validation
  • BluetoothSessionManagerService - Transfer coordination, incoming request handling, device cache management
  • Platform implementations:
    • WindowsBluetoothService - UWP RFCOMM APIs
    • AndroidBluetoothService - Android Bluetooth APIs (enhanced with length-prefixed protocol)

Protocol:

  • Length-prefixed framing (4-byte int32 + JSON payload)
  • 10MB message size limit
  • Standard SPP UUID (00001101-0000-1000-8000-00805F9B34FB)
  • Transfers DimmerSharedSong metadata only (title, artist, album, position, song ID)

Integration

SessionManagementViewModel extended to support dual-mode transfers:

// Bluetooth mode
[RelayCommand]
public async Task TransferToBluetoothDevice(BluetoothDeviceInfo targetDevice)
{
    // Pairing check with system settings prompt
    if (!await _bluetoothSessionManager.IsDevicePairedAsync(targetDevice.DeviceName))
    {
        await _bluetoothSessionManager.PromptPairingAsync();
        return;
    }
    
    await _bluetoothSessionManager.InitiateSessionTransferAsync(targetDevice, currentSongView);
}

// Incoming transfer handling
_bluetoothSessionManager.IncomingTransferRequests
    .ObserveOn(RxSchedulers.UI)
    .Subscribe(HandleIncomingBluetoothTransferRequest);

Platform-specific service registration in respective DI containers (WinUI MauiProgram.cs, Android Bootstrapper.cs).

Key Implementation Details

Thread Safety:

  • CancellationTokenSource lifecycle managed to prevent race conditions
  • Fire-and-forget async operations wrapped in Task.Run with exception handling
  • Event handlers avoid async void pattern

Resource Management:

  • All services implement IDisposable
  • Bluetooth connections properly torn down on disposal
  • Event handlers unsubscribed to prevent leaks

Security:

  • OS-level Bluetooth pairing required
  • Message size validation enforced
  • No audio file transfer (metadata only)
  • Platform-specific settings access via IBluetoothService.OpenBluetoothSettingsAsync()

User Experience:

  • Observable device lists via IObservable<IChangeSet<BluetoothDeviceInfo, string>>
  • Real-time connection status updates
  • User prompt for transfer acceptance
  • Graceful handling when song not found locally

Receiving device automatically starts Bluetooth server on app launch. Sender connects on-demand when initiating transfer. Song lookup on receiver uses song ID fallback to title/artist matching.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • crl.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/EB23B7D1B15B85081672081E55C17E18/missingpackages_workingdir --packages /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force mmer�� (dns block)
  • ocsp.godaddy.com
    • Triggering command: /usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/EB23B7D1B15B85081672081E55C17E18/missingpackages_workingdir --packages /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /home/REDACTED/work/Dimmer-MAUI/.codeql-scratch/dbs/csharp/working/nugetconfig/nuget.config --force mmer�� (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Offline session transfer via Bluetooth </issue_title>
<issue_description>As I have online transfer via Parse, I gotta have one for offline using Bluetooth.

Likely by having the sender being a Bluetooth server and receiving joins and we complete a handshake for transfer to occur.

I could be winui to droid or winui to winui, droid to droid - all should work same.

No need to transfer the song, but we do transfer the rest like that of Parse does.

If both devices aren't paired, we'd need to prompt user to open settings and pair, else, we just do the transfer after user chose the destination device which isn't self.

</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 3, 2026 23:19
…tions

Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
…latform-specific code separation

Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
…onnection

Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
Co-authored-by: YBTopaz8 <41630728+YBTopaz8@users.noreply.github.com>
Copilot AI changed the title [WIP] Add offline session transfer via Bluetooth Add Bluetooth offline session transfer Jan 3, 2026
Copilot AI requested a review from YBTopaz8 January 3, 2026 23:33
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.

Offline session transfer via Bluetooth

2 participants