added timeout to nfc so that webserver works again
This commit is contained in:
@@ -137,7 +137,7 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
//check every time if wifi is active
|
//check every time if wifi is active
|
||||||
if(!WiFi.isConnected()) {
|
/*if(!WiFi.isConnected()) {
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("\n\n");
|
Serial.println("\n\n");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//calculates time to run webpage pull function
|
//calculates time to run webpage pull function
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
@@ -165,7 +165,7 @@ void loop() {
|
|||||||
|
|
||||||
// Look for an NFC card
|
// Look for an NFC card
|
||||||
Serial.println("Waiting 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) {
|
if (success) {
|
||||||
Serial.println("NFC Card detected!");
|
Serial.println("NFC Card detected!");
|
||||||
@@ -179,22 +179,12 @@ void loop() {
|
|||||||
// Check if the detected card matches the known UID
|
// Check if the detected card matches the known UID
|
||||||
if (uidLength == sizeof(knownUID) && memcmp(uid, knownUID, uidLength) == 0) {
|
if (uidLength == sizeof(knownUID) && memcmp(uid, knownUID, uidLength) == 0) {
|
||||||
Serial.println("Known NFC card detected! Sending HTTP request...");
|
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();
|
wakePc();
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Unknown NFC card.");
|
Serial.println("Unknown NFC card.");
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(2000); // Debounce delay
|
//delay(2000); // Debounce delay
|
||||||
}
|
}
|
||||||
//nfc end
|
//nfc end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user