[GH-ISSUE #1741] OTA UPDATE ISSUE #1474

Open
opened 2026-02-28 01:30:13 +03:00 by kerem · 1 comment
Owner

Originally created by @citygreenstech2019 on GitHub (May 20, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1741

Basic Infos

Hardware

WiFimanager Branch/Release: WiFiClient

Esp8266/Esp32:

Hardware: ESP32-S3

Core Version: 2.4.0, staging

Description

Problem description

Settings in IDE

ARDUINO IDE version 2.3.2

Module: ESP32-S3 dev module.

Additional libraries:

Sketch

#BEGIN
#include <Arduino.h>
#include <WiFi.h>
#include "function_comm.h"
#include "Root_Certificate.h"

void setup() {
void FIRMWARE_UPDATE() {
  strip.setPixelColor(0, strip.Color(255, 255, 0));  // yellow
  strip.show();
  delay(100);
  Serial.println(F(" "));
  Serial.println(F(" ---> FUNCTION : FIRMWARE_UPDATE "));

  WiFiClientSecure client;
  client.setCACert(rootCACertificate);
  t_httpUpdate_return ret = httpUpdate.update(client, URL_fw_Bin);

  switch (ret) {
    case HTTP_UPDATE_FAILED:
      Serial.printf(" HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str());
      break;

    case HTTP_UPDATE_NO_UPDATES:
      Serial.println(" HTTP_UPDATE_NO_UPDATES");
      break;

    case HTTP_UPDATE_OK:
      Serial.println(" HTTP_UPDATE_OK");
      break;
  }

  strip.setPixelColor(0, strip.Color(0, 0, 0));  // off
  strip.show();
}

/*|-----------------------------------------------------------------------------|
    Firmware Version Check
  |-----------------------------------------------------------------------------|*/

int FW_VERSION_CHECK(void) {
  Serial.println(F(" "));
  Serial.println(F(" ---> FUNCTION : FW_VERSION_CHECK "));

  // Debug print to indicate the start of the function
  Serial.println("Starting version check...");

  String payload;
  int httpCode;
  String fwurl = "";
  fwurl += URL_fw_Version;
  fwurl += "?";
  fwurl += String(rand());
  Serial.println(fwurl);
  WiFiClientSecure *client = new WiFiClientSecure;

  if (client) {
    client->setCACert(rootCACertificate);

    // Add a scoping block for HTTPClient https to make sure it is destroyed before WiFiClientSecure *client is
    HTTPClient https;

    if (https.begin(*client, fwurl)) {
      // start connection and send HTTP header
      vTaskDelay(100 / portTICK_PERIOD_MS);
      httpCode = https.GET();
      vTaskDelay(100 / portTICK_PERIOD_MS);

      // Debug print to indicate the status of the HTTP request
      // Serial.print("HTTP request status: ");
      // Serial.println(httpCode);

      // // Debug print to print HTTP_CODE_OK
      // Serial.print("HTTP_CODE_OK: ");
      // Serial.println(HTTP_CODE_OK);

      if (httpCode == HTTP_CODE_OK)  // if version received
      {
        payload = https.getString();  // save received version
      } 
      
      else 
      {
        Serial.print(" error in downloading version file: ");
        Serial.println(httpCode);
        ERR_CODE=700;// ERROR IN DOWNLOADING VERSION FILE
        tb.sendTelemetryData("ERR_CODE", ERR_CODE);
        Serial.print("Error code: ");
        Serial.println(ERR_CODE);
        String command = "ER1.txt=\"" + String(ERR_CODE, DEC) + "\"";
        Serial0.print(command);
        Serial0.write(0xff);
        Serial0.write(0xff);
        Serial0.write(0xff);

        // Construct command to set number box ER1
        command = "ER1.val=" + String(ERR_CODE, DEC);
        Serial0.print(command);
        Serial0.write(0xff);
        Serial0.write(0xff);
        Serial0.write(0xff);
      }
      https.end();
    }
    delete client;
  }

  if (httpCode == HTTP_CODE_OK)  // if version received
  {
    payload.trim();
    if (payload.equals(FirmwareVer)) {
      Serial.print(F(" Latest Firmware Exist-> Firmware Version: "));
      Serial.println(FirmwareVer);
      return 0;
    } else {
      Serial.print("New firmware found: ");
      Serial.println(payload);
      Serial.println("Uploading new firmware");
      return 1;
    }
  }
  return 0;
}


}

void loop() {
date and time function(),and other required functions
}
#END

Debug Messages

Active Firmware Version: 1.0
17:51:53.959 -> Firmware Update In Progress..
17:51:53.959 -> https://raw.githubusercontent.com/citygreenstech2019/BASIC_OTA/master/bin-version.txt?1270216262
17:51:54.000 -> [HTTPS] Begin...
17:51:54.000 -> [HTTPS] GET...
17:51:54.728 -> [HTTPS] GET... failed, error: connection refused
17:51:55.716 -> Active Firmware Version: 1.0

messages here
``` OTA update is unable to happen it is showing
"error in downloading version file -1 " and the connection is refused
Originally created by @citygreenstech2019 on GitHub (May 20, 2024). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1741 ### Basic Infos #### Hardware WiFimanager Branch/Release: WiFiClient Esp8266/Esp32: Hardware: ESP32-S3 Core Version: 2.4.0, staging ### Description Problem description ### Settings in IDE ARDUINO IDE version 2.3.2 Module: ESP32-S3 dev module. Additional libraries: ### Sketch ```cpp #BEGIN #include <Arduino.h> #include <WiFi.h> #include "function_comm.h" #include "Root_Certificate.h" void setup() { void FIRMWARE_UPDATE() { strip.setPixelColor(0, strip.Color(255, 255, 0)); // yellow strip.show(); delay(100); Serial.println(F(" ")); Serial.println(F(" ---> FUNCTION : FIRMWARE_UPDATE ")); WiFiClientSecure client; client.setCACert(rootCACertificate); t_httpUpdate_return ret = httpUpdate.update(client, URL_fw_Bin); switch (ret) { case HTTP_UPDATE_FAILED: Serial.printf(" HTTP_UPDATE_FAILD Error (%d): %s\n", httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str()); break; case HTTP_UPDATE_NO_UPDATES: Serial.println(" HTTP_UPDATE_NO_UPDATES"); break; case HTTP_UPDATE_OK: Serial.println(" HTTP_UPDATE_OK"); break; } strip.setPixelColor(0, strip.Color(0, 0, 0)); // off strip.show(); } /*|-----------------------------------------------------------------------------| Firmware Version Check |-----------------------------------------------------------------------------|*/ int FW_VERSION_CHECK(void) { Serial.println(F(" ")); Serial.println(F(" ---> FUNCTION : FW_VERSION_CHECK ")); // Debug print to indicate the start of the function Serial.println("Starting version check..."); String payload; int httpCode; String fwurl = ""; fwurl += URL_fw_Version; fwurl += "?"; fwurl += String(rand()); Serial.println(fwurl); WiFiClientSecure *client = new WiFiClientSecure; if (client) { client->setCACert(rootCACertificate); // Add a scoping block for HTTPClient https to make sure it is destroyed before WiFiClientSecure *client is HTTPClient https; if (https.begin(*client, fwurl)) { // start connection and send HTTP header vTaskDelay(100 / portTICK_PERIOD_MS); httpCode = https.GET(); vTaskDelay(100 / portTICK_PERIOD_MS); // Debug print to indicate the status of the HTTP request // Serial.print("HTTP request status: "); // Serial.println(httpCode); // // Debug print to print HTTP_CODE_OK // Serial.print("HTTP_CODE_OK: "); // Serial.println(HTTP_CODE_OK); if (httpCode == HTTP_CODE_OK) // if version received { payload = https.getString(); // save received version } else { Serial.print(" error in downloading version file: "); Serial.println(httpCode); ERR_CODE=700;// ERROR IN DOWNLOADING VERSION FILE tb.sendTelemetryData("ERR_CODE", ERR_CODE); Serial.print("Error code: "); Serial.println(ERR_CODE); String command = "ER1.txt=\"" + String(ERR_CODE, DEC) + "\""; Serial0.print(command); Serial0.write(0xff); Serial0.write(0xff); Serial0.write(0xff); // Construct command to set number box ER1 command = "ER1.val=" + String(ERR_CODE, DEC); Serial0.print(command); Serial0.write(0xff); Serial0.write(0xff); Serial0.write(0xff); } https.end(); } delete client; } if (httpCode == HTTP_CODE_OK) // if version received { payload.trim(); if (payload.equals(FirmwareVer)) { Serial.print(F(" Latest Firmware Exist-> Firmware Version: ")); Serial.println(FirmwareVer); return 0; } else { Serial.print("New firmware found: "); Serial.println(payload); Serial.println("Uploading new firmware"); return 1; } } return 0; } } void loop() { date and time function(),and other required functions } #END ``` ### Debug Messages Active Firmware Version: 1.0 17:51:53.959 -> Firmware Update In Progress.. 17:51:53.959 -> https://raw.githubusercontent.com/citygreenstech2019/BASIC_OTA/master/bin-version.txt?1270216262 17:51:54.000 -> [HTTPS] Begin... 17:51:54.000 -> [HTTPS] GET... 17:51:54.728 -> [HTTPS] GET... failed, error: connection refused 17:51:55.716 -> Active Firmware Version: 1.0 ``` messages here ``` OTA update is unable to happen it is showing "error in downloading version file -1 " and the connection is refused
Author
Owner

@alexhopeoconnor commented on GitHub (Jul 2, 2024):

I don't think this has anything to do with WiFiManager, have you posted this issue here by mistake?

<!-- gh-comment-id:2201799147 --> @alexhopeoconnor commented on GitHub (Jul 2, 2024): I don't think this has anything to do with WiFiManager, have you posted this issue here by mistake?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1474
No description provided.