pn532 (adafruit) read ndef-record

i am trying to read a nfc tag with using a arduino-uno-wifi and adafriut-pn532. i have installed the don/ndef library from github and its not quite working. it might mbe as simple as pointer/reference mistakes as i’m a bginner in embeded systems. here is the output of the tag (external):

Found an ISO14443A card
  UID Length: 7 bytes
  UID Value: 0x04 0x8D 0x71 0x9A 0x27 0x49 0x80

Seems to be an NTAG2xx tag (7 byte UID)
PAGE 00: 04 8D 71 70  .�qp
PAGE 01: 9A 27 49 80  �'I�
PAGE 02: 74 48 00 00  tH..
PAGE 03: E1 10 10 00  �...
PAGE 04: 01 03 A0 10  ..�.
PAGE 05: 44 03 4C 94  D.L�
PAGE 06: 1C 05 63 68  ..ch
PAGE 07: 2E 6F 77 69  .owi
PAGE 08: 74 65 63 2E  tec.
PAGE 09: 74 69 6D 65  time
PAGE 10: 74 72 61 63  trac
PAGE 11: 6B 69 6E 67  king
PAGE 12: 3A 73 74 61  :sta
PAGE 13: 6D 70 39 38  mp98
PAGE 14: 37 36 34 54  764T
PAGE 15: 0F 16 61 6E  ..an
PAGE 16: 64 72 6F 69  droi
PAGE 17: 64 2E 63 6F  d.co
PAGE 18: 6D 3A 70 6B  m:pk
PAGE 19: 67 63 68 2E  gch.
PAGE 20: 6F 77 69 74  owit
PAGE 21: 65 63 2E 74  ec.t
PAGE 22: 69 6D 65 74  imet
PAGE 23: 72 61 63 6B  rack
PAGE 24: 69 6E 67 FE  ing�
PAGE 25: 00 00 00 00  ....
PAGE 26: 00 00 00 00  ....
PAGE 27: 00 00 00 00  ....
PAGE 28: 00 00 00 00  ....
PAGE 29: 00 00 00 00  ....
PAGE 30: 00 00 00 00  ....
PAGE 31: 00 00 00 00  ....
PAGE 32: 00 00 00 00  ....
PAGE 33: 00 00 00 00  ....
PAGE 34: 00 00 00 00  ....
PAGE 35: 00 00 00 00  ....
PAGE 36: 00 00 00 BD  ...�
PAGE 37: 00 00 00 FF  ...�
PAGE 38: 00 05 00 00  ....
PAGE 39: 00 00 00 00  ....
PAGE 40: 00 00 00 00  ....

which i output like this

success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
  
  // It seems we found a valid ISO14443A Tag!
  if (success) 
  {
    // 2.) Display some basic information about the card
    Serial.println("Found an ISO14443A card");
    Serial.print("  UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
    Serial.print("  UID Value: ");
    nfc.PrintHex(uid, uidLength);
    Serial.println("");
   
    if (uidLength != 7)
    {
      Serial.println("This doesn't seem to be an NTAG203 tag (UUID length != 7 bytes)!");
    }
    else
    {
      uint8_t data[64];
      uint8_t tmp[64];
      
      // We probably have an NTAG2xx card (though it could be Ultralight as well)
      Serial.println("Seems to be an NTAG2xx tag (7 byte UID)");    
      Serial.flush();    


//debug
      for (uint8_t i = 0; i < 41; i++) 
      {
        success = nfc.ntag2xx_ReadPage(i, tmp);

        if(i == 3)
          memcpy(data, tmp, 32);
        
        // Display the current page number
        Serial.print("PAGE ");
        if (i < 10)
        {
          Serial.print("0");
          Serial.print(i);
        }
        else
        {
          Serial.print(i);
        }
        Serial.print(": ");

        // Display the results, depending on 'success'
        if (success) 
        {
          // Dump the page data
          nfc.PrintHexChar(tmp, 4);
        }
        else
        {
          Serial.println("Unable to read the requested page!");
        }
      }

i would like to read the ndef-record with the following:

success = nfc.ntag2xx_ReadPage(3, data);
      if (! success)
      {
        Serial.println("Unable to read the Capability Container (page 3)");
        return;
      }
      else
      {
        // If the tag has already been formatted as NDEF, byte 0 should be:
        // Byte 0 = Magic Number (0xE1)
        // Byte 1 = NDEF Version (Should be 0x10)
        // Byte 2 = Data Area Size (value * 8 bytes)
        // Byte 3 = Read/Write Access (0x00 for full read and write)
        if (!((data[0] == 0xE1) && (data[1] == 0x10)))
        {
          Serial.println("This doesn't seem to be an NDEF formatted tag.");
          Serial.println("Page 3 should start with 0xE1 0x10.");
        }
        else
        {
          // 4.) Determine and display the data area size
          dataLength = data[2]*8;
          Serial.print("Tag is NDEF formatted. Data area size = ");
          Serial.print(dataLength);
          Serial.println(" bytes");

//          NfcTag t1 = NfcTag(uid, uidLength, "sP", *data, &dataLength);
          NfcTag t1 = NfcTag(uid, uidLength, "sP", data, &dataLength);
          Serial.println("output tag");
          t1.print();
          
          NdefMessage m1 = t1.getNdefMessage();
          Serial.println("got message");
          
          NdefRecord r = m1.getRecord(0);
          byte l = r.getPayloadLength();
          byte payload[l];
          r.getPayload(payload);
  
          // Print the Hex and Printable Characters
          Serial.print("  Payload (HEX): ");
          PrintHexChar(payload, l);
  
          // Force the data into a String (might work depending on the content)
          // Real code should use smarter processing
          String payloadAsString = "";
          for (int c = 0; c < l; c++) {
            payloadAsString += (char)payload[c];
          }
          Serial.print("  Payload (as String): ");
          Serial.println(payloadAsString);

this always shows me empty payloads. why can’t i seam to get the payload?

Found an ISO14443A card
  UID Length: 7 bytes
  UID Value: 0x04 0x8D 0x71 0x9A 0x27 0x49 0x80

Seems to be an NTAG2xx tag (7 byte UID)
Tag is NDEF formatted. Data area size = 128 bytes
output tag
NFC Tag - sP
UID 04 8D 71 9A 27 49 80

NDEF Message 1 record, 19 bytes
  NDEF Record
    TNF 0x1 Well Known
    Type Length 0x10 16
    Payload Length 0x0 0
    Type 00 00 00 00 87 00 00 00 00 00 01 03 00 00 69 00  ....�.........i.
    Payload   
    Record is 19 bytes
got message
  Payload (HEX):   
  Payload (as String):

The payload length is 0 so of course all your code to try to print it isn’t going to have a chance of working because r.getPayloadLength() returns 0. As to why the payload length is 0 I don’t have a clue, maybe someone else can help.

i know the payload is zero but it shouldn’t be. my money is on pointers/references that are wrong

i think i have figured it partially out. i am only passing page3 to NfcTag(). This probably happens because i dont use NfcAdapter which would read the complete tag. I think I have to read all pages and then pass it to NfcTag(). But how do i get all data?

maybe something like this?

uint8_t data[512];
uint8_t tmp[8];

for (uint8_t i = 0; i < 41; i++) 
{
        nfc.mifareultralight_ReadPage(i, tmp);
        strcat(data, tmp);
}

NfcTag t1 = NfcTag(uid, uidLength, "sP", data, 512);

this code crashes when i try to create the nfctag-object and restarts arduino sketch