don/NDEF

NdefMessage addTextRecord maxing out.

Opened this issue · 3 comments

I'm trying to write to a NTAG215, which has around 504 bytes of usable memory, yet I can only seem to use 227 (255 with headers ect.) bytes with the message.addTextRecord(input) function.

Basically I have something that looks like this:

#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>   // The following files are included in the libraries Installed
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);  // Indicates the Shield you are using
String input;

void setup(void) {
  while (!Serial); // for Leonardo/Micro/Zero
  Serial.begin(9600);
  Serial.println("READY"); // Header used when using the serial monitor
  nfc.begin();
}
void loop(void) {
  while(Serial.available() > 1) {
    input = Serial.readString(); } // read the incoming data as string

  if (input.indexOf("write") >= 0) {
    if (nfc.tagPresent()) {
      NdefMessage message = NdefMessage();
      input.remove(0,6);
      message.addTextRecord(input); // Text Message you want to Record
      boolean success = nfc.write(message);
      if (success) {
          Serial.println("COMPLETE"); // if it works you will see this message 
      } else {
          Serial.println("FAILED"); } // If the the rewrite failed you will see this message
    }
  } // End of write
  while (nfc.tagPresent()); // Wait for tag removal
  input = "";
}

Which works fine, until I exceed 227 characters.

Any ideas?

I found it in the MifareUltralight.cpp, #define ULTRALIGHT_MAX_PAGE 63 was limiting the tag to 63 pages (~252 bytes), I changed it to #define ULTRALIGHT_MAX_PAGE 135 and it seems to be working.

That actually only bumped it up to 260 characters before something else is maxing out, basically it crashes the arduino if you go higher.

@tgikal hmm, this issue (#60) seem to be alittle bit similar. I will try to figure something out.