1
0
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
d38b534bbe RFID: Track ID changes
We keep track of the detected tag UUIDs and their figurine ID, but
we don't update it when a programming request succeeds.
Search through the tracked tags for the programmed UUID and update
the stored ID when the change suceeds.
2024-03-05 23:56:00 +00:00
c92c8ce11f 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.
2024-03-05 23:54:24 +00:00

View file

@ -100,6 +100,15 @@ bool RFID::programTag(Com::TagInfoRecord *tagToProgram) {
Serial.println("Failed to program tag.");
return false;
}
// Programming succeeded, update the tracked ID of the tag.
for (uidNode* node = activeTags; node; node = node->next) {
// The protocol does not support UIDs other than 4 bytes, so assume it
// is the case here directly.
if ( *(uint32_t*)(node->uid.uidByte) == tagToProgram->uid)
node->tag_ID = tagToProgram->figId;
}
return true;
}
@ -161,7 +170,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;