BluetoothService: cleanup

This commit is contained in:
Ly-sec
2025-11-23 11:34:32 +01:00
parent cfffcdcd24
commit 5187c8075b
+5 -21
View File
@@ -10,9 +10,7 @@ import qs.Services.UI
Singleton { Singleton {
id: root id: root
// ============================================================================
// Properties // Properties
// ============================================================================
readonly property BluetoothAdapter adapter: Bluetooth.defaultAdapter readonly property BluetoothAdapter adapter: Bluetooth.defaultAdapter
readonly property int state: adapter?.state ?? 0 readonly property int state: adapter?.state ?? 0
@@ -32,9 +30,7 @@ Singleton {
property var devicesBeingPaired: ({}) property var devicesBeingPaired: ({})
property var connectionAttempts: ({}) property var connectionAttempts: ({})
// ============================================================================ // Init
// Initialization
// ============================================================================
function init() { function init() {
Logger.i("Bluetooth", "Service started"); Logger.i("Bluetooth", "Service started");
@@ -43,9 +39,7 @@ Singleton {
onAdapterChanged: _configureAdapter() onAdapterChanged: _configureAdapter()
// ============================================================================ // Device Actions
// Public API - Device Actions
// ============================================================================
function connectDeviceWithTrust(device) { function connectDeviceWithTrust(device) {
if (!device) if (!device)
@@ -116,9 +110,7 @@ Singleton {
adapter.enabled = state; adapter.enabled = state;
} }
// ============================================================================ // Device Info Helpers
// Public API - Device Info Helpers
// ============================================================================
function sortDevices(devices) { function sortDevices(devices) {
return devices.sort((a, b) => { return devices.sort((a, b) => {
@@ -213,9 +205,7 @@ Singleton {
return `Battery: ${Math.round(device.battery * 100)}%`; return `Battery: ${Math.round(device.battery * 100)}%`;
} }
// ============================================================================
// Device Monitoring // Device Monitoring
// ============================================================================
Repeater { Repeater {
model: root.devices model: root.devices
@@ -249,9 +239,7 @@ Singleton {
} }
} }
// ============================================================================
// Adapter State Monitoring // Adapter State Monitoring
// ============================================================================
Connections { Connections {
target: adapter target: adapter
@@ -276,9 +264,7 @@ Singleton {
} }
} }
// ============================================================================ // Private
// Private Helper Functions
// ============================================================================
function _filterDevices(filterFn) { function _filterDevices(filterFn) {
if (!adapter?.devices) if (!adapter?.devices)
@@ -374,9 +360,7 @@ Singleton {
delete connectionAttempts[address]; delete connectionAttempts[address];
} }
// ============================================================================ // Internal
// Internal Components
// ============================================================================
Timer { Timer {
id: discoveryTimer id: discoveryTimer