Chat freely about anything...

User avatar
By Masoud Navidi
#88152 OK! I've found the solution.
there was a mistake in sample code. the sample code needed 2 parts, URL and URI. but when I concatenated them together, my problem was solved.
here is the code for those who may need it:

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <FS.h>
#include "ESP8266httpUpdate.h"

/********************************************************
 ********************************************************
 ********************************************************/
const char* ssid = "********";  // modify this
const char* password = "********";   // modify this

const char* host = "https://server/steamer_v1_2.bin";   // modify this

/********************************************************
 ********************************************************
 ********************************************************/
void setup() {
  Serial.begin(115200);
 
  WiFi.mode(WIFI_STA);

  for (uint8_t t = 4; t > 0; t--)
  {
    Serial.printf("[SETUP] WAIT %d...\n", t);
    Serial.flush();
    delay(1000);
  }

  Serial.println();
  Serial.print("connecting to ");
  Serial.println(ssid);

  if (WiFi.SSID() != ssid) {
    WiFi.begin(ssid, password);
  }
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // configure time
  configTime(3 * 3600, 0, "pool.ntp.org");

  BearSSL::WiFiClientSecure client;
  const uint8_t fingerprint[20] = {0xdd, 0xa5, 0x2d, 0x31, 0x25,
                                   0x31, 0xae, 0x7a, 0x10, 0x0b,
                                   0x68, 0xba, 0x22, 0x84, 0x1a,
                                   0x94, 0xec, 0x79, 0xb4, 0xbb};   // modify this
  client.setFingerprint(fingerprint);

  auto ret = ESPhttpUpdate.update(client, host);
  // if successful, ESP will restart
  Serial.println("update failed");
  Serial.println((int) ret);
}

/********************************************************
 ********************************************************
 ********************************************************/
void loop() {
}