Reading a NXP ICODE SLI-L tag with Android

不打扰是莪最后的温柔 提交于 2019-12-04 20:31:41

ISO 15693 defines different read commands and manufacturers also may define proprietary read commands. All ICODE tags support the ISO 15693 Single Block Read command. You can send it as follows:

public static void processNfcIntent(Intent intent){
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    if(tag != null){
      // set up read command buffer
      byte blockNo = 0; // block address
      byte[] readCmd = new byte[3 + id.length];
      readCmd[0] = 0x20; // set "address" flag (only send command to this tag)
      readCmd[1] = 0x20; // ISO 15693 Single Block Read command byte
      byte[] id = tag.getId();
      System.arraycopy(id, 0, readCmd, 2, id.length); // copy ID
      readCmd[2 + id.length] = blockNo; // 1 byte payload: block address

      NfcV tech = NfcV.get(tag);
      if (tech != null) {
        // send read command
        try {
          tech.connect();
          byte[] data = tech.transceive(readCmd); 
        } catch (IOException e) {
          e.printStackTrace();
        } finally {
          try {
            tech.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!