readReg method

Future<Uint8List?> readReg(
  1. NfcTag tag,
  2. int address
)

Implementation

Future<Uint8List?> readReg(NfcTag tag, int address) async {
  Uint8List? receive;
  String flag;

  try {
    receive = await sendCommand(tag, Uint8List.fromList([0xB5, address]));
    flag = await Sic431XFlag().checkFlag(receive!);
  } catch (e) {
    if (kDebugMode) {
      print(e.toString());
    }
    return Uint8List(0);
  }

  if (flag.isNotEmpty) {
    return receive;
  } else {
    if (Platform.isIOS) {
      NfcManager.instance
          .stopSession(errorMessage: 'Read Register error !!!');
    }
    return Uint8List(0);
  }
}