From 5618f52a0e444866ac6617b06333fe0a8b72fae3 Mon Sep 17 00:00:00 2001 From: Teo-CD Date: Sat, 6 Jan 2024 00:40:27 +0000 Subject: [PATCH] main: Add message handling We want to check for new messages at the end of the loop, when all other events should have happenned. Handle the two supported messages there : tag info request and tag programming command. The timing might need some testing, hopefully it is short enough. --- src/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 3b5902f..b281973 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,6 +77,16 @@ __attribute__((noreturn)) int main() { } } + Com::ReceivedMessage message = Com::receiveMessage(); + if (message == Com::TAG_INFO_REQUEST) { + uint8_t tagCount = rfid.gatherTagInfo(Com::getTagRecords()); + Com::sendTagInfo(tagCount); + } else if (message == Com::TAG_PROGRAMMING) { + if (!rfid.programTag(Com::getTagRecords())) { + Com::sendComment("Tag programming failed."); + } + } + /* TODO: Drop delay, WFE+timer interrupt(s) ? */ delay(25); }