From 6d459c131f4ff5aebf048bffb67ed1da15dcd786 Mon Sep 17 00:00:00 2001 From: ilyacodes <33097525+ilyacodes@users.noreply.github.com> Date: Fri, 27 Dec 2024 14:12:04 -0700 Subject: [PATCH] Increase `PN532_PACKBUFFSIZ` to 128 bytes This change is in response to a bug in this library found when working with NFC YubiKeys, which contain an NDEF record that is returned as 71 bytes (6 bytes of header, 63 bytes of payload, 2 bytes of status words). It was found that when read using `inDataExchange()`, the last 15 bytes (13 bytes of payload and 2 bytes of status words) are being read as `00` rather than their actual value: ``` 00 43 D1 01 3F 55 04 6D 79 2E 79 75 62 69 63 6F 2E 63 6F 6D 2F 79 6B 2F 23 76 76 63 63 63 62 69 63 75 6C 75 63 6A 6A 6E 67 6B 75 69 62 75 62 6E 74 6A 65 63 68 76 6A 66 00 00 00 00 00 00 00 00 00 00 00 00 00 ``` However the reading function still returns true as though it succeeded. This has been documented [here](https://github.com/esphome/feature-requests/issues/2207#issuecomment-2332950416), and a suggested solution is to increase the size of `PN532_PACKBUFFSIZ`. Although I'm not sure what the optimal size is, upping it to 128 solved my problem but is not wildly larger (given this is obviously meant for am embedded system). --- Adafruit_PN532.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_PN532.cpp b/Adafruit_PN532.cpp index 494bfb7..f5041c4 100644 --- a/Adafruit_PN532.cpp +++ b/Adafruit_PN532.cpp @@ -75,7 +75,7 @@ byte pn532response_firmwarevers[] = { #define PN532DEBUGPRINT Serial ///< Fixed name for debug Serial instance //#define PN532DEBUGPRINT SerialUSB ///< Fixed name for debug Serial instance -#define PN532_PACKBUFFSIZ 64 ///< Packet buffer size in bytes +#define PN532_PACKBUFFSIZ 128 ///< Packet buffer size in bytes byte pn532_packetbuffer[PN532_PACKBUFFSIZ]; ///< Packet buffer used in various ///< transactions