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
2 changes: 1 addition & 1 deletion lib/src/control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class Gen5HelloInfo {
final batteryRaw = u32(body, 1) ~/ 10;
return Gen5HelloInfo(
helloRevision: body[0],
batteryPct: (batteryRaw >= 0 && batteryRaw <= 100) ? batteryRaw : null,
batteryPct: batteryRaw <= 100 ? batteryRaw : null,
charging: (body[5] & 0x01) != 0,
tsSeconds: u32(body, 6),
tsSubseconds: u32(body, 10),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/garmin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ GarminMlrPacket? garminDecodeMlr(List<int> data) {
if (data.isEmpty) return null;
if ((data[0] & _kMlrFlag) != 0) {
final handle = (data[0] & _kMlrHandleMask) >> _kMlrHandleShift;
return GarminMlrData(handle, Uint8List.fromList(data));
return GarminMlrData(handle, Uint8List.fromList(data.sublist(1)));
}
if (data[0] != 0) return null;
if (data.length < 2) return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ultrahuman.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const int kUltrahumanMeasureNotOnFinger = 100;
/// `offset + 32 > bytes.length` — a truncated record, never guessed at.
UltrahumanRecord? parseUltrahumanRecord(List<int> bytes, int offset) {
if (offset < 0 || offset + kUltrahumanRecordLen > bytes.length) return null;
final b = Uint8List.fromList(bytes);
final b = bytes is Uint8List ? bytes : Uint8List.fromList(bytes);
final d = b.buffer.asByteData(b.offsetInBytes + offset);
return UltrahumanRecord(
tsA: d.getUint32(0, Endian.little),
Expand Down
1 change: 1 addition & 0 deletions test/garmin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void main() {
final decoded = garminDecodeMlr([0x80 | (2 << 4), 1, 2, 3]);
expect(decoded, isA<GarminMlrData>());
expect((decoded as GarminMlrData).handle, 2);
expect(decoded.payload, [1, 2, 3], reason: 'routing byte 0 must be stripped');
});

test('a non-flagged, non-zero first byte is rejected, not a data frame',
Expand Down
Loading