From ddf9a31ebce6a14327fce1a48def16dd5749ac6c Mon Sep 17 00:00:00 2001 From: Ben Howes Date: Tue, 2 Feb 2021 14:15:12 +0000 Subject: [PATCH] Fix for partially read ultralight tag --- MifareUltralight.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MifareUltralight.cpp b/MifareUltralight.cpp index c139b7d..c1a4cca 100644 --- a/MifareUltralight.cpp +++ b/MifareUltralight.cpp @@ -74,9 +74,11 @@ NfcTag MifareUltralight::read(byte * uid, unsigned int uidLength) index += ULTRALIGHT_PAGE_SIZE; } - NdefMessage ndefMessage = NdefMessage(&buffer[ndefStartIndex], messageLength); - return NfcTag(uid, uidLength, NFC_FORUM_TAG_TYPE_2, ndefMessage); - + if(messageLength > 0){ + NdefMessage ndefMessage = NdefMessage(&buffer[ndefStartIndex], messageLength); + return NfcTag(uid, uidLength, NFC_FORUM_TAG_TYPE_2, ndefMessage); + } + return NfcTag(uid, uidLength, NFC_FORUM_TAG_TYPE_2); } boolean MifareUltralight::isUnformatted()