Using RAM instead of EEPROM for NDEF messages?
ChristianTrummer99 opened this issue · 1 comments
I am trying to dynamically generate a token (within an NDEF message) that is returned upon tag-read. Since the token is generated as-needed, I assume I won't need persistent memory. As an initial test I'm just trying to return a static NDEF message that is stored in RAM. This is my edit to lines 510-511 of the 'full' variant applet (in NdefApplet.java).
// send directly
byte[] arr = JCSystem.makeTransientByteArray((short)14, JCSystem.CLEAR_ON_RESET);
arr[0] = (byte)0x00;
arr[1] = (byte)0x0C;
arr[2] = (byte)0xD1;
arr[3] = (byte)0x01;
arr[4] = (byte)0x07;
arr[5] = (byte)0x54;
arr[6] = (byte)0x02;
arr[7] = (byte)0x65;
arr[8] = (byte)0x6E;
arr[9] = (byte)0x54;
arr[10] = (byte)0x65;
arr[11] = (byte)0x73;
arr[12] = (byte)0x74;
arr[13] = (byte)0x81;
apdu.setOutgoingLength((short)14);
apdu.sendBytesLong(arr, (short)0, (short)14);
Interestingly, when using this app, available on the app store, I am able to send custom APDU's to the applet and read the expected responses, but when using the generic NFC reader (of any NFC app - "NFC app", "NXP TagInfo", etc) the tag is not recognized at all. Specifically: I can send a sequence of custom APDU's to "read" from the tag resulting in the response 000CD101075402656E54657374819000
, but when using the regular "NFC Reader" function (of any of the common NFC read/write apps) the tag is not detected.
My Question: In order to be detected as an NDEF tag, must the NDEF message be written to EEPROM?
I can provide A LOT more details with respect to my testing of this, but I am very curious if there is something obvious that I'm missing.
The following solved my issue:
// send directly
byte[] arr = JCSystem.makeTransientByteArray((short)14, JCSystem.CLEAR_ON_RESET);
arr[0] = (byte)0x00;
arr[1] = (byte)0x0C;
arr[2] = (byte)0xD1;
arr[3] = (byte)0x01;
arr[4] = (byte)0x07;
arr[5] = (byte)0x54;
arr[6] = (byte)0x02;
arr[7] = (byte)0x65;
arr[8] = (byte)0x6E;
arr[9] = (byte)0x54;
arr[10] = (byte)0x65;
arr[11] = (byte)0x73;
arr[12] = (byte)0x74;
arr[13] = (byte)0x81;
apdu.setOutgoingLength(le);
apdu.sendBytesLong(arr, (short)0, le);
as you can see the outgoing length must be le
. Byte arrays stored in RAM can certainly be returned as valid NDEF messages.
Apologies for the clutter. Hopefully someone finds this useful.