From d38b534bbe78453198bc9716706118782bda31c6 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Tue, 5 Mar 2024 23:56:00 +0000 Subject: [PATCH] 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. --- src/RFID.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/RFID.cpp b/src/RFID.cpp index 1c4eb2a..2b15851 100644 --- a/src/RFID.cpp +++ b/src/RFID.cpp @@ -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; }