From c92c8ce11f7b2cc07ed8385e46d543127846968c Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Tue, 5 Mar 2024 23:54:24 +0000 Subject: [PATCH] RFID: Fix buffer size for writes The RFID library expects a 16 bytes buffer for writing blocks. However, we re-use the 18 bytes buffer needed for reading blocks. Properly remove those two extra bytes when writing blocks. --- src/RFID.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/RFID.cpp b/src/RFID.cpp index 03b40d5..1c4eb2a 100644 --- a/src/RFID.cpp +++ b/src/RFID.cpp @@ -161,7 +161,8 @@ bool RFID::writeBlock(MFRC522Constants::Uid &uidToRead, byte blockAddr, uint8_t return false; } - byte size = sizeof(comData); + // Take into account the two bytes used only for the read commands. + byte size = sizeof(comData) - 2; for (byte& bufferByte: comData) bufferByte = 0;