/** BasicHTTPSClient.ino Created on: 20.08.2018 */ #include #include #include #include #include // Fingerprint for demo URL, expires on June 2, 2021, needs to be updated well before this date //const uint8_t fingerprint[20] = {0x40, 0xaf, 0x00, 0x6b, 0xec, 0x90, 0x22, 0x41, 0x8e, 0xa3, 0xad, 0xfa, 0x1a, 0xe8, 0x25, 0x41, 0x1d, 0x1a, 0x54, 0xb3}; const uint8_t fingerprint[20] = {0xa9, 0xf0, 0x22, 0xf1, 0x1e, 0x1e, 0x81, 0xde, 0x69, 0x53, 0x1f, 0xc2, 0xad, 0x0e, 0xc0, 0x77, 0x8d, 0x42, 0x12, 0x61}; //0x00, 0xec, 0xe0, 0xb2, 0x78, 0x12, c8, 0xdd, 0xd6, 0xd6, 0xa2, 0x30, 0x7f, 0x96, 0xfe, 0xbd, 0x8e //0xa9, 0xf0, 0x22, 0xf1, 0x1e, 0x1e, 0x81, 0xde, 0x69, 0x53, 0x1f, 0xc2, 0xad, 0x0e, 0xc0, 0x77, 0x8d, 0x42, 0x12, 0x61 ESP8266WiFiMulti WiFiMulti; void setup() { Serial.begin(115200); // Serial.setDebugOutput(true); Serial.println(); Serial.println(); Serial.println(); for (uint8_t t = 4; t > 0; t--) { Serial.printf("[SETUP] WAIT %d...\n", t); Serial.flush(); delay(1000); } WiFi.mode(WIFI_STA); WiFiMulti.addAP("TLU", ""); } void loop() { // wait for WiFi connection if ((WiFiMulti.run() == WL_CONNECTED)) { std::unique_ptrclient(new BearSSL::WiFiClientSecure); client->setFingerprint(fingerprint); HTTPClient https; Serial.print("[HTTPS] begin...\n"); // if (https.begin(*client, "https://jigsaw.w3.org/HTTP/connection.html")) { // HTTPS if (https.begin(*client, "https://aikevadjaagup2021-default-rtdb.europe-west1.firebasedatabase.app/0212/lamp.json")) { // HTTPS Serial.print("[HTTPS] GET...\n"); // start connection and send HTTP header int httpCode = https.GET(); // httpCode will be negative on error if (httpCode > 0) { // HTTP header has been send and Server response header has been handled Serial.printf("[HTTPS] GET... code: %d\n", httpCode); // file found at server if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { String payload = https.getString(); Serial.println(payload); } } else { Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str()); } https.end(); } else { Serial.printf("[HTTPS] Unable to connect\n"); } } Serial.println("Wait 10s before next round..."); delay(10000); }