#include #include #include #include #include const uint8_t fingerprint[20] = {0x54, 0x11, 0xbf, 0x7d, 0x0c, 0x82, 0xe0, 0x9c, 0xc7, 0xb2, 0xf5, 0x74, 0x29, 0xd5, 0x91, 0xb5, 0x10, 0x1b, 0x30, 0xde}; 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://aikevadjaagup2021-default-rtdb.europe-west1.firebasedatabase.app/1031/teated/teade2.json")) { // HTTPS // if (https.begin(*client, "https://www.tlu.ee/~jaagup/")) { // HTTPS https.addHeader("Content-Type", "application/json"); int httpCode = https.POST("{\"sisu\":\"abc\"}"); // 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] ... 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] ... 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); }