【问题标题】:Android NFC: Exception "transceive failed" when using transceive()Android NFC:使用 transceive() 时出现异常“transceive failed”
【发布时间】:2015-10-15 13:20:31
【问题描述】:

我正在尝试在三星 Galaxy S3 和支持NfcAIsoDep (Mifare DESFire EV1) 的智能卡之间进行通信。为此,我启用了前台调度并在发现标签时启动了一项任务。任务中的代码如下所示:

IsoDep isoDep = IsoDep.get(tag);

byte[] selectCommand = {
        (byte)0x00, // CLA
        (byte)0xA4, // INS
        (byte)0x04, // P1
        (byte)0x00, // P2
        (byte)0x0A, // LC
        (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0xFF, // AID
        (byte)0x7F  // LE
};

try {
    isoDep.connect();
    byte[] response = isoDep.transceive(selectCommand);
    String result = bytesToString(response);
    isoDep.close();
    return result;
} catch (Exception e) {
    e.printStackTrace();
}

transceive 方法抛出这个异常:

java.io.IOException: Transceive failed

IsoDep(如getTimeout())的所有其他方法都可以正常执行。增加超时不会改变行为。选择命令中带有 AID 的小程序出现在卡上。我也尝试使用NfcA 类。但后来我得到了异常“标签丢失”。

Galaxy S3 会不会是问题所在?

【问题讨论】:

  • 您是否尝试设置 Le=0x00
  • 00 A4 04 00 07 D2 76 00 00 85 01 01 00 命令 APDU 工作吗?
  • 这两个建议的例外情况相同。
  • 还有905A00000300000000?
  • 我在 S3 上以 ISO 模式使用 DESFire EV1 没有问题。你能用this app检查你的卡吗?

标签: android nfc smartcard mifare contactless-smartcard


【解决方案1】:

我刚刚在另一部手机上尝试了相同的应用程序,它运行时没有任何问题。 Galaxy S3 确实是问题所在。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-05
    • 2020-01-11
    相关资源
    最近更新 更多