From dd86fbf687bbcaed92e96c9774d0838994c1363b Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Sat, 8 Nov 2025 12:17:49 +0100 Subject: [PATCH] displaySuccess after reading card --- the-cup.ino | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/the-cup.ino b/the-cup.ino index 33018ba..11a08d3 100644 --- a/the-cup.ino +++ b/the-cup.ino @@ -41,8 +41,27 @@ void setup() { Serial.begin(115200); pinMode(LED_PIN, OUTPUT); - displaySuccess(); + reader.PCD_Init(); // Init each MFRC522 card. +} + +void loop() { + if (reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) { + char reader_uid[32] = ""; + read_card(reader_uid); + send_uid(reader_uid); + } +} + +void read_card(char reader_uid[]) { + reader.PICC_HaltA(); + reader.PCD_StopCrypto1(); + byte_to_string(reader.uid.uidByte, 4, reader_uid); + Serial.println(reader_uid); + displaySuccess(); +} + +void send_uid(char reader_uid[]) { WiFiManager wm; bool res; res = wm.autoConnect("KLUK"); // password protected ap @@ -57,27 +76,6 @@ void setup() { Serial.println("connected...yeey :)"); displaySuccess(); } - - reader.PCD_Init(); // Init each MFRC522 card. -} - -void loop() { - - if (reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) { - char reader_uid[32] = ""; - read_card(reader_uid); - send_uid(reader_uid); - } -} - -void read_card(char reader_uid[]) { - reader.PICC_HaltA(); - reader.PCD_StopCrypto1(); - byte_to_string(reader.uid.uidByte, 4, reader_uid); - Serial.println(reader_uid); -} - -void send_uid(char reader_uid[]) { auto client = std::make_unique(); client->setInsecure(); @@ -104,7 +102,6 @@ void send_uid(char reader_uid[]) { https.end(); Serial.print("[HTTPS] ended...\n"); - } void byte_to_string(byte array[], unsigned int len, char buffer[]) {