Skip to content

Commit 1f2377c

Browse files
Implementing full support for OpenRing (#113)
* renamed tau ring to OpenRing * renamed folder * added missing file * renamed value parser * Add OpenRing PPG sensor parsing and configuration * small changes * Add OpenRing payload-based config and PPG streaming command * updates * Fix OpenRing IMU frame parsing and add PPG packet decoding * Swap OpenRing PPG start/stop control byte * Harden OpenRing IMU stream handling for mixed packets * Make OpenRing parser tolerant to partial/mixed packets * Decode OpenRing PPG packet type 0x02 frames * Fix OpenRing IMU payload offset and flexible waveform logs * Fix OpenRing sample timestamps to be strictly monotonic * Trace OpenRing parsed/emitted values and decouple timestamps by cmd * Estimate IMU sample rate from packet timing for timestamp spacing * Use fixed IMU sample spacing for timestamps * Align IMU accel parsing with SDK sub-opcode behavior * Ignore OpenRing accel-only IMU packets and parse accel+gyro only * fully implemented imu * added PPG support * all sensors working * implemented wall clock time sync for OpenRing * implemented regular battery polling * ensure timing logic while battery and time sync * implemented openring * added off state and default states for openring * added openring image * more gracefully handle sensor states and data targets for openring * more gracefully handle sensor states and data targets for openring * streamlined the system devices and bluetooth devices (ring-only split) * made the openring implementation more stable * made the openring implementation more stable * improved the state handling * rely on the 0x32 characharteristic only * simplified the logic to pure software disable because everything else turns out to be unstable * fixed a little bug in the battery logic * fixed a little bug in the battery logic * lib/src/models/devices/open_ring_factory.dart: changed units of sensors to match actual data --------- Co-authored-by: TobiasRoeddiger <roeddiger@teco.edu>
1 parent f1135da commit 1f2377c

17 files changed

Lines changed: 2364 additions & 498 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.3.3
2+
3+
* renamed TauRing to OpenRing
4+
* added support for OpenRing temperature sensors (`temp0`, `temp1`, `temp2`) as one 3-channel `Temperature` sensor (`°C`) with software-only on/off control
5+
16
## 2.3.2
27

38
* fixed some bugs with Esense devices
@@ -73,4 +78,4 @@ Connecting to earable now retries after first failure.
7378

7479
## 0.0.1
7580

76-
* TODO: Describe initial release.
81+
* TODO: Describe initial release.
1.59 MB
Loading

example/lib/widgets/sensor_configuration_view.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class _SensorConfigurationViewState extends State<SensorConfigurationView> {
3333
@override
3434
void initState() {
3535
super.initState();
36-
_selectedValue = widget.configuration.values.first;
36+
_selectedValue =
37+
widget.configuration.offValue ?? widget.configuration.values.first;
3738
}
3839

3940
@override

lib/open_earable_flutter.dart

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import 'src/managers/wearable_disconnect_notifier.dart';
2121
import 'src/models/capabilities/stereo_device.dart';
2222
import 'src/models/capabilities/system_device.dart';
2323
import 'src/models/devices/discovered_device.dart';
24-
import 'src/models/devices/tau_ring_factory.dart';
24+
import 'src/models/devices/open_ring_factory.dart';
2525
import 'src/models/devices/wearable.dart';
2626

2727
export 'src/models/devices/discovered_device.dart';
@@ -111,7 +111,7 @@ class WearableManager {
111111
CosinussOneFactory(),
112112
PolarFactory(),
113113
DevKitFactory(),
114-
TauRingFactory(),
114+
OpenRingFactory(),
115115
EsenseFactory(),
116116
];
117117

@@ -262,16 +262,53 @@ class WearableManager {
262262
}
263263

264264
String deviceErrorMessage(dynamic e, String deviceName) {
265+
final normalizedDeviceName = _formatDisplayDeviceName(deviceName);
265266
return switch (e) {
266-
UnsupportedDeviceException _ => 'Device "$deviceName" is not supported.',
267+
UnsupportedDeviceException _ =>
268+
'Device "$normalizedDeviceName" is not supported.',
267269
AlreadyConnectedException _ =>
268-
'Device "$deviceName" is already connected.',
270+
'Device "$normalizedDeviceName" is already connected.',
269271
ConnectionFailedException _ =>
270-
'Failed to connect to device "$deviceName". Please try again.',
271-
_ => e.toString(),
272+
'Failed to connect to device "$normalizedDeviceName". Please try again.',
273+
_ => _normalizeDeviceNameInMessage(
274+
message: e.toString(),
275+
rawDeviceName: deviceName,
276+
normalizedDeviceName: normalizedDeviceName,
277+
),
272278
};
273279
}
274280

281+
String _formatDisplayDeviceName(String rawName) {
282+
final trimmed = rawName.trim();
283+
if (trimmed.isEmpty) {
284+
return trimmed;
285+
}
286+
287+
final replaced = trimmed.replaceFirst(
288+
RegExp(r'^bcl[-_\s]*', caseSensitive: false),
289+
'OpenRing-',
290+
);
291+
292+
if (replaced == 'OpenRing-') {
293+
return 'OpenRing';
294+
}
295+
296+
return replaced;
297+
}
298+
299+
String _normalizeDeviceNameInMessage({
300+
required String message,
301+
required String rawDeviceName,
302+
required String normalizedDeviceName,
303+
}) {
304+
if (rawDeviceName.isEmpty ||
305+
rawDeviceName == normalizedDeviceName ||
306+
message.isEmpty) {
307+
return message;
308+
}
309+
return message.replaceAll(rawDeviceName, normalizedDeviceName);
310+
}
311+
275312
void addPairingRule(PairingRule rule) {
276313
_pairingManager.addRule(rule);
277314
}

0 commit comments

Comments
 (0)