Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor Improvements #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 1 addition & 4 deletions lib/src/ledger/ledger_ble_connection_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ class LedgerBleConnectionManager extends BleConnectionManager {
StreamSubscription? subscription;
await disconnect(device);

subscription = _bleManager
.connectToAdvertisingDevice(
subscription = _bleManager.connectToDevice(
id: device.id,
withServices: [Uuid.parse(serviceId)],
prescanDuration: options?.prescanDuration ?? _options.prescanDuration,
connectionTimeout:
options?.connectionTimeout ?? _options.connectionTimeout,
)
Expand Down
15 changes: 1 addition & 14 deletions lib/src/ledger/ledger_gatt_reader.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:typed_data';

import 'package:ledger_flutter/src/exceptions/ledger_exception.dart';
import 'package:ledger_flutter/src/utils/buffer.dart';

class LedgerGattReader {
Expand All @@ -16,8 +15,6 @@ class LedgerGattReader {
/// the protocol being used
static const versionCla = 0x00;

static const errorDataSize = 2;

var currentSequence = 0;
var remainingBytes = 0;
var payload = <int>[];
Expand Down Expand Up @@ -60,7 +57,6 @@ class LedgerGattReader {
_handleData(
Uint8List.fromList(payload),
onData: onData,
onError: onError,
);
} else if (remainingBytes > 0) {
// wait for next message
Expand All @@ -78,18 +74,9 @@ class LedgerGattReader {
void _handleData(
Uint8List data, {
void Function(Uint8List event)? onData,
Function? onError,
}) {
reset();

if (data.length > errorDataSize) {
onData?.call(data);
} else if (data.length == errorDataSize) {
final errorCode = ByteData.sublistView(data).getInt16(0);
onError?.call(LedgerException(errorCode: errorCode));
} else {
onError?.call(LedgerException());
}
onData?.call(data);
}

/// Reset the reader
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ledger_flutter
description: A Flutter plugin to scan, connect & sign transactions using your Ledger Nano devices
version: 1.0.1
version: 1.0.2
homepage: https://developers.ledger.com/
repository: https://github.com/RootSoft/ledger-flutter
issue_tracker: https://github.com/RootSoft/ledger-flutter/issues
Expand Down