From 67a4537882282112be347377dd3bd7e01c982d35 Mon Sep 17 00:00:00 2001
From: TheJoKlLa <thejoklla@gmail.com>
Date: Mon, 31 Oct 2022 20:36:08 +0100
Subject: [PATCH] Added: Reader Timeoute

---
 src/FabReader_v2/src/main.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/FabReader_v2/src/main.cpp b/src/FabReader_v2/src/main.cpp
index cb66063..84fe2c3 100644
--- a/src/FabReader_v2/src/main.cpp
+++ b/src/FabReader_v2/src/main.cpp
@@ -23,6 +23,9 @@ PubSubClient* mqtt;
 NFC* nfc;
 OTAProxy* ota;
 
+unsigned long otatimeout = 3000;
+unsigned long lastotatime;
+
 void setup_wifi() 
 {
     delay(10);
@@ -125,8 +128,16 @@ void loop()
             if(nfc->connecttoCard())
             {
                 Serial.println("Card connected");
+                lastotatime = millis();
                 ota->startOTA();
             }
         }
     }
+    if(ota->hasActiveOTA())
+    {
+        if(millis() - lastotatime > otatimeout)
+        {
+            ota->cancelOTA();
+        }
+    }
 }
\ No newline at end of file