美文网首页
Android NFC(三)CPU卡操作

Android NFC(三)CPU卡操作

作者: ccDown | 来源:发表于2019-05-06 11:25 被阅读0次

需要使用IsoDep命令进行卡片的控制,操作流程:
1.NFC权限判断
2.卡类型判断
3.卡连接
4.通过isoDep.transceive(byte[] commond)控制卡片(传输的byte[]为 APDU命令,该命令返回值后两个字节为报文处理结果,前边的内容为报文返回内容)

前三步跟M1卡流程类似,M1卡调用MifareClassic类的方法,CPU调用IsoDep类的方法。

下面为读取CPU卡信息的方法

/**
 * CPU卡信息读取
 * @param tag
 * @return
 * @throws IOException
 */
public static String readIsoCard(Tag tag) throws IOException {
    IsoDep isoDep = IsoDep.get(tag);
    if (!isoDep.isConnected()){
        isoDep.connect();
    }

    String result = StringUtil.bytesToHexString(isoDep.transceive(StringUtil.hex2Bytes("00A404000B485A2E4A4D2E4144463031")));
    Log.e("readIsoCard",result);
    result = StringUtil.bytesToHexString(isoDep.transceive(StringUtil.hex2Bytes("00B0950030")));
    Log.e("readIsoCard",result);
    isoDep.close();
    return result;
}

相关文章

网友评论

      本文标题:Android NFC(三)CPU卡操作

      本文链接:https://www.haomeiwen.com/subject/mphroqtx.html