Skip to content

Commit

Permalink
flush and close http connection after each send
Browse files Browse the repository at this point in the history
  • Loading branch information
gojimmypi committed Jun 16, 2020
1 parent 9c97cc8 commit 8364165
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions RFID_Logger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,24 @@ int SaveUID(String thisUID, String thisMessage) {
if (thisUID) {
if (!WiFiConnected()) {
wifiConnect(50);
WebServerConnect();
}

WebServerConnect();

if (!client.connected()) {
Serial.println("SaveUID when wifi client.connected is false; check firewall on receiver");
Serial.print("IP address=");
Serial.println(WiFi.localIP());
return 2;
}
Serial.println("Saving UID");
String url = "/RFID/default.aspx?UID=" + thisUID + "&MAC=" + wifiMacAddress() + "&MSG=" + thisMessage; // reminder that IIS will return a 302 (moved) for default.aspx that points to default :/
String url = String(SECRET_APP_PATH) + "?UID=" + thisUID + "&MAC=" + wifiMacAddress() + "&MSG=" + thisMessage; // reminder that IIS will return a 302 (moved) for default.aspx that points to default :/
String thisRequest = HTML_RequestText(url);
String thisMovedRequestURL = "";
HTML_SendRequestFollowMove(&client, thisRequest, thisMovedRequestURL);

client.flush();
delay(100);
client.stop();
return 0;
}
else {
Expand Down Expand Up @@ -174,8 +177,6 @@ void setup() {
//wifiConnect(50);


SaveUID("00000000", "Startup"); // save a marker at startup time

// testSSL();

SPI.begin(); // Init SPI bus
Expand All @@ -189,6 +190,25 @@ void setup() {
Serial.print(F("Using the following key:"));
printHex(key.keyByte, MFRC522::MF_KEY_SIZE);

SaveUID("00000000", "Startup"); // save a marker at startup time

// some reconnection tests...
//delay(1000);
//SaveUID("00000001", "Startup"); // save a marker at startup time
//delay(5000);
//SaveUID("00000005", "Startup"); // save a marker at startup time
//delay(20000);
//SaveUID("00000020", "Startup"); // save a marker at startup time
//delay(60000);
//SaveUID("00000060", "Startup"); // save a marker at startup time
//delay(120000);
//SaveUID("00000120", "Startup"); // save a marker at startup time
//delay(240000);
//SaveUID("00000240", "Startup"); // save a marker at startup time
//delay(1000000);
//SaveUID("00001000", "Startup"); // save a marker at startup time

Serial.println("Setup complete: awaiting card...");
}

bool IsCardReady() {
Expand Down

0 comments on commit 8364165

Please sign in to comment.