Android - 写入 ISO15693 标签

Android - Writing to ISO15693 Tags

我目前正在尝试将几个字节写入特定块。我的读取命令运行良好,我可以使用以下代码读取标签的任何块:

command = new byte[]{
            (byte) 0x02, // Flags
            (byte) 0x23, // Command: Read multiple blocks
            (byte) 0x09, // First block (offset)
            (byte) 0x03  // Number of blocks // MAX READ SIZE: 32 blocks:1F
    };
byte[] data = nfcvTag.transceive(command);

当我尝试使用下面的代码编写时,我的应用程序崩溃了。

Write = new byte[]{
                (byte) 0x02, // Flags
                (byte) 0x21, // Command: Write 1 blocks
                (byte) 0x5A, // First block (offset)
                (byte) 0x41  // Data
        };
    nfcvTag.transceive(Write);

我在 AsyncTask 中执行此操作并得到 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 异常。

有什么建议吗?标签是 STMicroelectronics M24LR04E-R

想通了。我只写了 8 位数据,而标签每个块有 32 位。添加了3个0x00,写入成功。

Write = new byte[]{
            (byte) 0x02, // Flags
            (byte) 0x21, // Command: Write 1 blocks
            (byte) 0x5A, // First block (offset)
            (byte) 0x41,
            (byte) 0x00,
            (byte) 0x00,
            (byte) 0x00  
    };
nfcvTag.transceive(Write);