From b7ec6df8ec43b913e4b81a9876eb46c597a9a4b8 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Wed, 20 Nov 2019 22:31:20 +0100 Subject: [PATCH] Fix HTTP polling to presence-button.glitch.me, randomly crashing after some time --- main.ino | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/main.ino b/main.ino index d67cab7..9ee7907 100644 --- a/main.ino +++ b/main.ino @@ -14,7 +14,7 @@ Ticker ticker; const byte RELAY_PIN = 12; -const byte LED_PIN = 2; // 13 for Sonoff S20, 2 for NodeMCU/ESP12 internal LED +const byte LED_PIN = 13; // 13 for Sonoff S20, 2 for NodeMCU/ESP12 internal LED const byte BUTTON_PIN = 0; bool fuzIsOpen = false; @@ -320,12 +320,14 @@ void morseSOSLED() { // ... ___ ... delay(500); } +HTTPClient http2; +// http2.setReuse(true); void notifyFuzIsOpen() { - HTTPClient http; - http.begin("http://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen)); - http.setAuthorization(matrixUsername.c_str(), matrixPassword.c_str()); - http.GET(); - Serial.println("GET status body: " + http.getString()); + http2.begin("http://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen)); + http2.setAuthorization(matrixUsername.c_str(), matrixPassword.c_str()); + int httpCode = http2.GET(); + Serial.println("GET status return code: " + String(httpCode)); + http2.end(); } bool loggedInMatrix = false;