Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NdefMessage addTextRecord maxing out. #53

Open
tgikal opened this issue Jun 24, 2019 · 3 comments
Open

NdefMessage addTextRecord maxing out. #53

tgikal opened this issue Jun 24, 2019 · 3 comments

Comments

@tgikal
Copy link

tgikal commented Jun 24, 2019

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?

@tgikal
Copy link
Author

tgikal commented Jun 25, 2019

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.

@tgikal tgikal closed this as completed Jun 25, 2019
@tgikal
Copy link
Author

tgikal commented Jun 26, 2019

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 tgikal reopened this Jun 26, 2019
@rrakso
Copy link

rrakso commented Oct 29, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants