3

请参阅NFC 阅读器“选择(通过 AID)”APDU在调试和最终结果中未路由到 Android 设备。TL; DR 读者可能已经不复存在了。


我将 ACR122U 阅读器连接到我的 Android 设备。我的最终目标是在 HCE 模式下使用另一台 Android 设备来启用设备之间的数据通信。

目前我在与 ACR122U 阅读器集成时遇到问题。我使用供应商提供的 lib acssmc-1.1.1.jar 提供程序。这是我目前拥有的代码(省略打开阅读器的示例代码)。

mReader.power(slotNum, Reader.CARD_WARM_RESET);
mReader.setProtocol(slotNum, Reader.PROTOCOL_T0 | Reader.PROTOCOL_T1);

//FF 00 00 00 04 D4 4A 01 00 00 - Polling for the ISO14443-4 A ??
byte[] w = new byte[255];
int len = mReader.transmit(0, new byte[] { (byte)0xFF, 0x00, 0x00, 0x00, 0x04,(byte)0xD4, 0x4A, 0x01, 0x00}, 9, w, w.length);
Log.e("Response", "r: " + NfcUtils.convertBinToASCII(w, 0, len));

//00 A4 04 00 07 F0 01 02 03 04 05 07 00 - Select AID APDU
w = new byte[255];
mReader.transmit(0, new byte[] {0x00, (byte) 0xA4, 0x04, 0x00, 7,
    (byte)0xF0, 0x01, 0x02, 0x03, 0x04, (byte) 0x05, 0x07, 0}, 13, w, w.length);
Log.e("Response", "r: " + Arrays.toString (recvBuffer));

如果我在 NFC 阅读器上点击标签,这就是我得到的输出

r: D54B0101440004048853606A9000
r: lots of zeroes

当我点击 Android 设备时,这是响应:

r: D54B6300
r: lots of zeroes

基本上它在轮询阶段失败(?)。在 Android 设备上,我有一个基本的HostAdpuService实现:

public class MyHostApduService extends HostApduService {

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("APDU", "APDU service was created.");
    }

    @Override
    public byte[] processCommandApdu(byte[] apdu, Bundle extras) {
       Log.e("APDU", "command apdu: " + Arrays.toString(apdu));
       return new byte[2];
    }
    @Override
    public void onDeactivated(int reason) {
       Log.e("APDU", "ON DEACTIVATED.");
    }
}

processCommandApdu从来没有被叫过。查看 Android 设备的日志时,当我点击该设备时,我找不到任何相关内容。

我在网上浏览了几个示例,但也无法使其在其他(非 Android)平台(Windows、OSX)上运行。

4

0 回答 0