Browse Source

Ping presence-button.glitch.me via (insecure) HTTPS

master
Lomanic 4 months ago
parent
commit
a0d852c1ed
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      main.ino

+ 7
- 2
main.ino View File

@@ -9,6 +9,8 @@
9 9
 #include <ArduinoJson.h>          //https://github.com/bblanchon/ArduinoJson
10 10
 #include <ESP8266mDNS.h>          // https://tttapa.github.io/ESP8266/Chap08%20-%20mDNS.html
11 11
 
12
+#include <WiFiClientSecure.h> 
13
+
12 14
 //for LED status
13 15
 #include <Ticker.h>
14 16
 Ticker ticker;
@@ -258,10 +260,11 @@ void morseSOSLED() { // ... ___ ...
258 260
   delay(500);
259 261
 }
260 262
 
263
+BearSSL::WiFiClientSecure secureClient;
261 264
 HTTPClient http2;
262 265
 // http2.setReuse(true);
263 266
 void notifyFuzIsOpen() {
264
-  http2.begin("http://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen));
267
+  http2.begin(secureClient, "https://presence-button.glitch.me/status?fuzisopen=" + String(fuzIsOpen));
265 268
   http2.setAuthorization(matrixUsername.c_str(), matrixPassword.c_str());
266 269
   int httpCode = http2.GET();
267 270
   Serial.println("GET status return code: " + String(httpCode));
@@ -436,6 +439,8 @@ void setup() {
436 439
     Serial.println("mDNS responder started");
437 440
   }
438 441
   MDNS.addService("http", "tcp", 80);
442
+
443
+  secureClient.setInsecure();
439 444
 }
440 445
 
441 446
 bool buttonState = HIGH;
@@ -480,6 +485,6 @@ void loop() {
480 485
     digitalWrite(RELAY_PIN, LOW);
481 486
     fuzIsOpen = true;
482 487
   }
483
-  digitalWrite(LED_PIN, LOW); // light up the LED, in case we encounter temporary failure in getMessages()
488
+  digitalWrite(LED_PIN, LOW); // ensure the LED is lit
484 489
   previousButtonState = buttonState;
485 490
 }

Loading…
Cancel
Save