forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapple_watch_discoverer.dart
More file actions
42 lines (37 loc) · 1.33 KB
/
Copy pathapple_watch_discoverer.dart
File metadata and controls
42 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import 'package:omi/backend/schema/bt_device/bt_device.dart';
import 'package:omi/gen/pigeon_communicator.g.dart';
import 'package:omi/services/devices/discovery/device_discoverer.dart';
import 'package:omi/services/devices/discovery/device_locator.dart';
import 'package:omi/utils/logger.dart';
class AppleWatchDiscoverer extends DeviceDiscoverer {
@override
String get name => 'Apple Watch';
@override
bool get isSupported => true; // runtime check inside discover
@override
Future<DeviceDiscoveryResult> discover({int timeout = 5}) async {
try {
final host = WatchRecorderHostAPI();
final supported = await host.isWatchSessionSupported();
final paired = await host.isWatchPaired();
final reachable = await host.isWatchReachable();
if (supported && paired) {
final device = BtDevice(
name: 'Apple Watch',
id: 'apple-watch',
type: DeviceType.appleWatch,
rssi: reachable ? 0 : -100,
locator: DeviceLocator.watchConnectivity(),
);
return DeviceDiscoveryResult(devices: [device]);
}
} catch (e) {
Logger.debug('Apple Watch discovery error: $e');
}
return const DeviceDiscoveryResult(devices: []);
}
@override
Future<void> stop() async {
// Apple Watch discovery is stateless, no cleanup needed
}
}