9
0
mirror of https://github.com/Lomanic/presence-button synced 2024-10-31 19:17:29 +00:00

Fix HTTP polling to presence-button.glitch.me, randomly crashing after some time

This commit is contained in:
Lomanic 2019-11-20 22:31:20 +01:00
parent 450fdfcddf
commit b7ec6df8ec

View File

@ -14,7 +14,7 @@
Ticker ticker; Ticker ticker;
const byte RELAY_PIN = 12; 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; const byte BUTTON_PIN = 0;
bool fuzIsOpen = false; bool fuzIsOpen = false;
@ -320,12 +320,14 @@ void morseSOSLED() { // ... ___ ...
delay(500); delay(500);
} }
HTTPClient http2;
// http2.setReuse(true);
void notifyFuzIsOpen() { void notifyFuzIsOpen() {
HTTPClient http; http2.begin("http://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen));
http.begin("http://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen)); http2.setAuthorization(matrixUsername.c_str(), matrixPassword.c_str());
http.setAuthorization(matrixUsername.c_str(), matrixPassword.c_str()); int httpCode = http2.GET();
http.GET(); Serial.println("GET status return code: " + String(httpCode));
Serial.println("GET status body: " + http.getString()); http2.end();
} }
bool loggedInMatrix = false; bool loggedInMatrix = false;