ensure timer is reset after rapid reader use
This commit is contained in:
parent
bde9a0ad0f
commit
50cde43e7c
1 changed files with 9 additions and 2 deletions
11
src/main.cpp
11
src/main.cpp
|
@ -6,7 +6,7 @@ unsigned long lastDataTime = 0;
|
|||
const unsigned long displayDelay = 1000; // Delay in milliseconds after which the data is displayed
|
||||
const unsigned long wifiRebootTimeout = 20000; // Delay before reboot after disconnect
|
||||
unsigned int bitCount = 0; // Variable to keep track of the bit count
|
||||
unsigned int maxBitCount = 34; // Variable to make sure reader does not exceed maxiumum bits
|
||||
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
|
||||
|
||||
|
||||
#ifdef WIFI
|
||||
|
@ -398,7 +398,8 @@ void loop() {
|
|||
lastDataTime = millis(); // Reset the time of last received data
|
||||
}
|
||||
|
||||
if (millis() - lastDataTime >= displayDelay && cardData != 0 && bitCount == maxBitCount) {
|
||||
if (millis() - lastDataTime >= displayDelay && cardData != 0) {
|
||||
|
||||
|
||||
uint64_t facilityID = (cardData >> 17) & 0xFFFF;
|
||||
uint64_t cardID = (cardData >> 1) & 0xFFFF;
|
||||
|
@ -478,4 +479,10 @@ void loop() {
|
|||
#endif
|
||||
|
||||
}
|
||||
else if (millis() - lastDataTime >= maxReaderWaitTime) {
|
||||
cardData = 0; // Reset the card data
|
||||
lastDataTime = millis(); // Reset the time of last received data
|
||||
bitCount = 0; // Reset the bit count
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue