How chaitanyabiswas/bluetoothautoconnect works
Bluetooth Auto Connect is a Windows desktop app and optional CLI that discovers nearby or paired devices, applies trusted-device rules, and connects or pairs matches. In the desktop flow, the UI adapter observes discovery through the agent watcher; the policy engine checks whitelist and retry rules, and connection requests can use the privileged service over a local named pipe or user-session Bluetooth APIs. Persistence stores whitelist rules and device history in SQLite. The README documents tray operation, notifications, manual connection, and CLI scanning and management; some subsystem links rely on documentation because those source files were not excerpted.
Main entry points: BluetoothAgentViewModelAdapter.cs Bluetooth UI adapter · BluetoothAgentWatcher.cs Bluetooth discovery agent · BluetoothDbContext.cs Shared SQLite database · WhitelistRepository.cs Whitelist repository
Components 19
Desktop experience
- WinUI interface
BlueToothAutoConnect.UserAgent/MainPage.xaml.cs - Main view model
BlueToothAutoConnect.UserAgent/ViewModels/MainViewModel.cs - Bluetooth UI adapter
BlueToothAutoConnect.UserAgent/Services/BluetoothAgentViewModelAdapter.cs - Tray and notifications
BlueToothAutoConnect.UserAgent/Services/SystemTrayIcon.cs - Diagnostic logging
BlueToothAutoConnect.UserAgent/Services/DiagnosticLog.cs
Discovery and policy
- Bluetooth discovery agent
BlueToothAutoConnect.AgentCore/BluetoothAgentWatcher.cs - Connection policy
BlueToothAutoConnect.PolicyEngine/Policy/BluetoothPolicyEngine.cs - User-session pairing
BlueToothAutoConnect.AgentCore/UserSessionBluetoothService.cs - Named-pipe client
BlueToothAutoConnect.AgentCore/AgentIpcClient.cs
Privileged Bluetooth
- Service IPC server
BlueToothAutoConnect.PrivilegedHost/IPC/IpcServer.cs - Windows Bluetooth service
BlueToothAutoConnect.PrivilegedHost/Bluetooth/BluetoothService.cs
Persistence
- Whitelist repository
BlueToothAutoConnect.Persistence/Repositories/WhitelistRepository.cs - Device history repository
BlueToothAutoConnect.Persistence/Repositories/DeviceHistoryRepository.cs - Shared SQLite database
BlueToothAutoConnect.Persistence/Data/BluetoothDbContext.cs - Trusted-device rules
BlueToothAutoConnect.Persistence/Entities/WhitelistEntry.cs - Device history records
BlueToothAutoConnect.Persistence/Entities/DeviceHistory.cs
Command-line client
- CLI commands
BlueToothAutoConnect.UserAgent.Cli/Program.cs - CLI discovery agent
BlueToothAutoConnect.UserAgent.Cli/Services/CliBluetoothAgent.cs
Other components
- Desktop user
Connections 23
- Desktop user → WinUI interface: manages devices
README.md - WinUI interface → Main view model: invokes actions
BlueToothAutoConnect.UserAgent/MainPage.xaml.cs - Main view model → Bluetooth UI adapter: uses adapter
BlueToothAutoConnect.UserAgent/ViewModels/MainViewModel.cs - Bluetooth UI adapter → Bluetooth discovery agent: observes discovery
BlueToothAutoConnect.UserAgent/Services/BluetoothAgentViewModelAdapter.cs - Bluetooth UI adapter → Whitelist repository: checks matches
BlueToothAutoConnect.UserAgent/Services/BluetoothAgentViewModelAdapter.cs - Bluetooth UI adapter → Diagnostic logging: logs activity
BlueToothAutoConnect.UserAgent/Services/BluetoothAgentViewModelAdapter.cs - Bluetooth discovery agent → Connection policy: evaluates devices
BlueToothAutoConnect.AgentCore/BluetoothAgentWatcher.cs - Bluetooth discovery agent → Named-pipe client: requests service actions
BlueToothAutoConnect.AgentCore/BluetoothAgentWatcher.cs - Bluetooth discovery agent → User-session pairing: uses user APIs
BlueToothAutoConnect.AgentCore/BluetoothAgentWatcher.cs - Named-pipe client → Service IPC server: sends pipe requests
BlueToothAutoConnect.AgentCore/AgentIpcClient.cs - Service IPC server → Windows Bluetooth service: dispatches requests
BlueToothAutoConnect.PrivilegedHost/IPC/IpcServer.cs - Connection policy → Whitelist repository: matches rules
BlueToothAutoConnect.PolicyEngine/Policy/BluetoothPolicyEngine.cs - Connection policy → Device history repository: checks replacements
BlueToothAutoConnect.PolicyEngine/Policy/BluetoothPolicyEngine.cs - Whitelist repository → Shared SQLite database: reads and writes
BlueToothAutoConnect.Persistence/Repositories/WhitelistRepository.cs - Device history repository → Shared SQLite database: reads and writes
BlueToothAutoConnect.Persistence/Repositories/DeviceHistoryRepository.cs - Shared SQLite database → Trusted-device rules: stores
BlueToothAutoConnect.Persistence/Data/BluetoothDbContext.cs - Shared SQLite database → Device history records: stores
BlueToothAutoConnect.Persistence/Data/BluetoothDbContext.cs - Desktop user → CLI commands: runs commands
README.md - CLI commands → CLI discovery agent: starts discovery
BlueToothAutoConnect.UserAgent.Cli/Program.cs - CLI discovery agent → Bluetooth discovery agent: runs discovery
BlueToothAutoConnect.UserAgent.Cli/Services/CliBluetoothAgent.cs - CLI commands → Whitelist repository: manages rules
BlueToothAutoConnect.UserAgent.Cli/Program.cs - Tray and notifications → Diagnostic logging: logs tray activity
BlueToothAutoConnect.UserAgent/Services/SystemTrayIcon.cs - Bluetooth UI adapter → Tray and notifications: signals connection events