added timeout to nfc so that webserver works again

This commit is contained in:
2025-02-07 08:50:21 +01:00
parent 41d7972301
commit 88fdc1d132

View File

@@ -137,7 +137,7 @@ void setup() {
void loop() {
//check every time if wifi is active
if(!WiFi.isConnected()) {
/*if(!WiFi.isConnected()) {
WiFi.disconnect();
WiFi.begin(ssid, password);
@@ -148,7 +148,7 @@ void loop() {
}
Serial.println("\n\n");
}
}*/
//calculates time to run webpage pull function
time_t now = time(NULL);
@@ -165,7 +165,7 @@ void loop() {
// Look for an NFC card
Serial.println("Waiting for an NFC card...");
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 500);
if (success) {
Serial.println("NFC Card detected!");
@@ -179,22 +179,12 @@ void loop() {
// Check if the detected card matches the known UID
if (uidLength == sizeof(knownUID) && memcmp(uid, knownUID, uidLength) == 0) {
Serial.println("Known NFC card detected! Sending HTTP request...");
/*httpClient.begin(wakeUrl);
int httpResponseCode = httpClient.GET();
if (httpResponseCode > 0) {
Serial.printf("HTTP Response Code: %d\n", httpResponseCode);
} else {
Serial.printf("Error sending HTTP request: %s\n", httpClient.errorToString(httpResponseCode).c_str());
}
httpClient.end();*/
wakePc();
} else {
Serial.println("Unknown NFC card.");
}
delay(2000); // Debounce delay
//delay(2000); // Debounce delay
}
//nfc end