transferIn method
Implementation
@override
Future<Uint8List?> transferIn(int packetSize, int timeout) async {
try {
final activeDevice = _activeDevice;
if (activeDevice == null) {
throw Exception('No active device; use open() first');
}
final device = activeDevice.device;
final endpointNumber = activeDevice.inEndpointNumber;
if (!device.opened) {
await device.open();
}
final result = await device.transferIn(endpointNumber, packetSize);
return result.data;
} catch (e) {
debugPrint('Error in transferIn: $e');
if (e.toString().contains('InvalidStateError')) {
await _reopenDevice();
return transferIn(packetSize, timeout);
}
return null;
}
}