/** BasicHTTPSClient.ino Created on: 20.08.2018 */ #include #include #include #include #include const uint8_t fingerprint[20] = {0x36, 0xAB, 0xB5, 0x84, 0x1E, 0xF1, 0xAA, 0xC2, 0x8E, 0x4B, 0x50, 0x24, 0xB2, 0xA3, 0x70, 0x55, 0xFB, 0x96, 0xF2, 0x43}; 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); // Or, if you happy to ignore the SSL certificate, then use the following line instead: // client->setInsecure(); HTTPClient https; Serial.print("[HTTPS] begin...\n"); if (https.begin(*client, "https://aikevadjaagup2021-default-rtdb.europe-west1.firebasedatabase.app/1007.json")) { // HTTPS https.addHeader("Content-Type", "application/json"); String teade="{\"yhendatud\":\"abc\"}"; // start connection and send HTTP header // int httpCode = https.POST(teade); //Märkige veebis, kas juhe on ühendatud int httpCode = https.PUT(teade); // 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); }