transceive static method
Transceive data with polled WebUSB device according to our protocol.
Implementation
static Future<String> transceive(String capdu) async {
log.config('CAPDU: $capdu');
if (!_deviceAvailable()) {
throw PlatformException(
code: "406", message: "No tag polled or device already disconnected");
}
try {
var rawCAPDU = Uint8List.fromList(hex.decode(capdu));
var rawRAPDU = await _doTransceive(rawCAPDU);
String rapdu = hex.encode(rawRAPDU);
log.config('RAPDU: $rapdu');
return rapdu;
} on TimeoutException catch (_) {
log.severe("Transceive timeout");
throw PlatformException(code: "408", message: "Transceive timeout");
} on PlatformException catch (e) {
log.severe("Transceive error", e);
rethrow;
} on Exception catch (e) {
log.severe("Transceive error", e);
throw PlatformException(
code: "500", message: "WebUSB API error", details: e);
}
}