Skip to content

Commit fa511e0

Browse files
feat(wearable_manager): add getSystemDevices method for retrieving known Bluetooth devices
1 parent 88ab14a commit fa511e0

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

lib/open_earable_flutter.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ class WearableManager {
141141
return await BleManager.checkPermissions();
142142
}
143143

144+
/// Retrieves Bluetooth devices already known to the operating system.
145+
///
146+
/// When [checkAndRequestPermissions] is `true`, the manager first requests
147+
/// any missing runtime permissions required for system-device discovery.
148+
Future<List<DiscoveredDevice>> getSystemDevices({
149+
bool checkAndRequestPermissions = true,
150+
}) {
151+
return _bleManager.getSystemDevices(
152+
checkAndRequestPermissions: checkAndRequestPermissions,
153+
);
154+
}
155+
144156
/// Adds a wearable factory to the manager.
145157
/// Wearable factories are used to create wearable instances based on the connected devices.
146158
/// This allows the manager to support multiple types of wearables.
@@ -169,7 +181,8 @@ class WearableManager {
169181
}
170182

171183
/// Returns an unmodifiable list of the currently registered wearable factories.
172-
List<WearableFactory> get wearableFactories => List.unmodifiable(_wearableFactories);
184+
List<WearableFactory> get wearableFactories =>
185+
List.unmodifiable(_wearableFactories);
173186

174187
/// Starts scanning for BLE devices.
175188
/// If `checkAndRequestPermissions` is true, it will check and request the necessary
@@ -292,10 +305,10 @@ class WearableManager {
292305
ConnectionFailedException _ =>
293306
'Failed to connect to device "$normalizedDeviceName". Please try again.',
294307
_ => _normalizeDeviceNameInMessage(
295-
message: e.toString(),
296-
rawDeviceName: deviceName,
297-
normalizedDeviceName: normalizedDeviceName,
298-
),
308+
message: e.toString(),
309+
rawDeviceName: deviceName,
310+
normalizedDeviceName: normalizedDeviceName,
311+
),
299312
};
300313
}
301314

0 commit comments

Comments
 (0)