Android NFC(三)CPU卡操作

2019-05-06  本文已影响0人  ccDown

需要使用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;
}
上一篇 下一篇

猜你喜欢

热点阅读