disconnectDevice method

  1. @mustCallSuper
Future<void> disconnectDevice()
inherited

Disconnect the reader, cancels all pending commands with a DeviceDisconnectedException

Implementation

@mustCallSuper

/// Disconnect the reader, cancels all pending commands
/// with a [DeviceDisconnectedException]
Future<void> disconnectDevice() async {
  _remainingBytes = -1;
  _buffer.clear();
  _cmdQueue
    ..forEach((key, value) {
      if (value.completer.isCompleted) {
        return;
      }
      value.completer.completeError(
        DeviceDisconnectedException(),
      );
    })
    ..clear();
  onDisconnectCallback?.call();
  setStatus(ConnectionStatus.idle);
}