Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions open_wearable/lib/models/mock_wearable.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import 'dart:async';

import 'package:open_earable_flutter/open_earable_flutter.dart';
import 'package:sensors_plus/sensors_plus.dart';

class MockWearable extends Wearable
implements SensorManager, SensorConfigurationManager {
@override
final List<Sensor> sensors = [];

@override
final List<SensorConfiguration> sensorConfigurations = [];

@override
Stream<Map<SensorConfiguration, SensorConfigurationValue>>
get sensorConfigurationStream => const Stream.empty();

MockWearable({required super.disconnectNotifier})
: super(name: "Mock Device") {
sensors.add(MockGyroSensor());
sensors.add(MockAccelerometer());
}

@override
String get deviceId => "MOCK-001";

@override
Future<void> disconnect() async {
// nothing to do
return Future.value();
}

@override
String? getWearableIconPath({bool darkmode = false}) {
return null;
}
}

class MockGyroSensor extends Sensor<SensorDoubleValue> {
MockGyroSensor()
: super(
sensorName: "Gyroscope",
chartTitle: "Gyroscope",
shortChartTitle: "Gyro",
relatedConfigurations: [],
);

@override
List<String> get axisNames => ['X', 'Y', 'Z'];

@override
List<String> get axisUnits => ['rad/s', 'rad/s', 'rad/s'];

@override
Stream<SensorDoubleValue> get sensorStream {
return gyroscopeEventStream().map((event) {
return SensorDoubleValue(
values: [event.x, event.y, event.z],
timestamp: DateTime.now().millisecondsSinceEpoch,
);
});
}
}

class MockAccelerometer extends Sensor<SensorDoubleValue> {
MockAccelerometer()
: super(
sensorName: "Accelerometer",
chartTitle: "Accelerometer",
shortChartTitle: "Accel",
relatedConfigurations: [
MockConfigurableSensorConfiguration(
name: "Sensor Rate",
availableOptions: {
StreamSensorConfigOption(),
},
values: [
MockConfigurableSensorConfigurationValue(
key: "30Hz",
options: {
StreamSensorConfigOption(),
},),
],),
],
);

@override
List<String> get axisNames => ['X', 'Y', 'Z'];

@override
List<String> get axisUnits => ['m/s²', 'm/s²', 'm/s²'];

@override
Stream<SensorDoubleValue> get sensorStream {
return accelerometerEventStream().map((event) {
return SensorDoubleValue(
values: [event.x, event.y, event.z],
timestamp: DateTime.now().millisecondsSinceEpoch,
);
});
}
}

class MockConfigurableSensorConfiguration
extends ConfigurableSensorConfiguration<
MockConfigurableSensorConfigurationValue> {
MockConfigurableSensorConfiguration({
required super.name,
required super.values,
super.availableOptions,
});

@override
void setConfiguration(
MockConfigurableSensorConfigurationValue configuration,) {
// no-op
}
}

class MockConfigurableSensorConfigurationValue
extends ConfigurableSensorConfigurationValue {
MockConfigurableSensorConfigurationValue({
required super.key,
super.options,
});

@override
MockConfigurableSensorConfigurationValue withoutOptions() {
return MockConfigurableSensorConfigurationValue(key: key);
}
}
17 changes: 17 additions & 0 deletions open_wearable/lib/widgets/devices/connect_devices_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:open_earable_flutter/open_earable_flutter.dart' hide logger;
import 'package:open_wearable/models/mock_wearable.dart';
import 'package:open_wearable/view_models/sensor_recorder_provider.dart';
import 'package:open_wearable/view_models/wearables_provider.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -86,6 +88,21 @@ class _ConnectDevicesPageState extends State<ConnectDevicesPage> {
onPressed: _startScanning,
child: PlatformText('Scan'),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: PlatformElevatedButton(
onPressed: () {
final mockWearable = MockWearable(
disconnectNotifier: WearableDisconnectNotifier(),
);
context.read<WearablesProvider>().addWearable(mockWearable);
context
.read<SensorRecorderProvider>()
.addWearable(mockWearable);
},
child: PlatformText('Simulate Device'),
),
),
],
),
),
Expand Down
2 changes: 2 additions & 0 deletions open_wearable/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import file_picker
import file_selector_macos
import flutter_archive
import open_file_mac
import path_provider_foundation
import share_plus
import shared_preferences_foundation
import universal_ble
Expand All @@ -19,6 +20,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FlutterArchivePlugin.register(with: registry.registrar(forPlugin: "FlutterArchivePlugin"))
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UniversalBlePlugin.register(with: registry.registrar(forPlugin: "UniversalBlePlugin"))
Expand Down
4 changes: 2 additions & 2 deletions open_wearable/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODS:
- FlutterMacOS
- ZIPFoundation (= 0.9.19)
- FlutterMacOS (1.0.0)
- open_file_mac (0.0.1):
- open_file_mac (1.0.3):
- FlutterMacOS
- path_provider_foundation (0.0.1):
- Flutter
Expand Down Expand Up @@ -67,7 +67,7 @@ SPEC CHECKSUMS:
file_selector_macos: 9e9e068e90ebee155097d00e89ae91edb2374db7
flutter_archive: 07888d9aeb79da005e0ad8b9d347d17cdea07f68
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
open_file_mac: 01874b6d6a2c1485ac9b126d7105b99102dea2cf
open_file_mac: 76f06c8597551249bdb5e8fd8827a98eae0f4585
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
share_plus: 510bf0af1a42cd602274b4629920c9649c52f4cc
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
Expand Down
88 changes: 28 additions & 60 deletions open_wearable/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.4.1"
version: "1.4.0"
clock:
dependency: transitive
description:
Expand All @@ -57,14 +57,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.2"
code_assets:
dependency: transitive
description:
name: code_assets
sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -336,14 +328,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de
url: "https://pub.dev"
source: hosted
version: "2.1.3"
go_router:
dependency: "direct main"
description:
Expand All @@ -352,14 +336,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.8.1"
hooks:
dependency: transitive
description:
name: hooks
sha256: "7a08a0d684cb3b8fb604b78455d5d352f502b68079f7b80b831c62220ab0a4f6"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
http:
dependency: "direct main"
description:
Expand Down Expand Up @@ -444,18 +420,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
version: "0.12.18"
version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.13.0"
version: "0.11.1"
mcumgr_flutter:
dependency: "direct main"
description:
Expand All @@ -480,14 +456,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
native_toolchain_c:
dependency: transitive
description:
name: native_toolchain_c
sha256: "89e83885ba09da5fdf2cdacc8002a712ca238c28b7f717910b34bcd27b0d03ac"
url: "https://pub.dev"
source: hosted
version: "0.17.4"
nested:
dependency: transitive
description:
Expand All @@ -496,14 +464,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
objective_c:
dependency: transitive
description:
name: objective_c
sha256: "983c7fa1501f6dcc0cb7af4e42072e9993cb28d73604d25ebf4dab08165d997e"
url: "https://pub.dev"
source: hosted
version: "9.2.5"
open_earable_flutter:
dependency: "direct main"
description:
Expand Down Expand Up @@ -612,10 +572,10 @@ packages:
dependency: transitive
description:
name: path_provider_foundation
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4"
url: "https://pub.dev"
source: hosted
version: "2.6.0"
version: "2.5.1"
path_provider_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -744,6 +704,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.28.0"
sensors_plus:
dependency: "direct main"
description:
name: sensors_plus
sha256: "56e8cd4260d9ed8e00ecd8da5d9fdc8a1b2ec12345a750dfa51ff83fcf12e3fa"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
sensors_plus_platform_interface:
dependency: transitive
description:
name: sensors_plus_platform_interface
sha256: "58815d2f5e46c0c41c40fb39375d3f127306f7742efe3b891c0b1c87e2b5cd5d"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
share_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -865,10 +841,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "19a78f63e83d3a61f00826d09bc2f60e191bf3504183c001262be6ac75589fb8"
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.8"
version: "0.7.7"
tuple:
dependency: transitive
description:
Expand Down Expand Up @@ -1037,14 +1013,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.6.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
url: "https://pub.dev"
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.10.3 <4.0.0"
flutter: ">=3.38.4"
dart: ">=3.10.0 <4.0.0"
flutter: ">=3.38.0"
1 change: 1 addition & 0 deletions open_wearable/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies:
url_launcher: ^6.3.2
go_router: ^14.6.2
http: ^1.6.0
sensors_plus: ^7.0.0

dev_dependencies:
flutter_test:
Expand Down