I have a little project to write data to Ntag 213, 215, and 216.
I success write the data using the MifareUltraLight method. The problem is when I scan using NfcTools, the data format is different than I expected.
Here's the format that I expected.
Here's the format that I got.
I want that when the Ntag scan, it will open the browser if the apps not installed.
I'm using Mifare method because the Ntag will be protected by password. I tried two different way to write the data.
I handle the write function manually using the command for Ntag. You can see the code below
fun writePages(msg: String, mifare: MifareUltralight) { val uriString = Uri.parse(msg).normalizeScheme().toString() val subsUri = Uri.parse(msg).host.toString() val encodedPayload2 = uriString.toByteArray() val encodedData = byteArrayOf(0xD1.toByte(), 0x01.toByte(), (subsUri.length).toByte(), 0x55.toByte()) + encodedPayload2 val tlvEncodedData = byteArrayOf(0x03.toByte(), encodedData.size.toByte()) + encodedData + byteArrayOf(0xFE.toByte()) var currentPage = 4 for (i in tlvEncodedData.indices step 4) { var currentBlock = i + 4 if (currentBlock > tlvEncodedData.size) { currentBlock = tlvEncodedData.size } val data = tlvEncodedData.sliceArray(i until currentBlock) var command = byteArrayOf(0xA2.toByte(), currentPage.toByte()) + data if (command.size < 6) { for (w in command.size until 6) { command += 0.toByte() } } mifare.transceive(command) currentPage += 1 } }I tried to write the data using this simple project. But the result is the same.
My question is, did I use the wrong method to write the data or something that I miss?

