chrisjoyce911 / esp32FOTA

Experiments in firmware OTA updates for ESP32 dev boards
The Unlicense
363 stars 89 forks source link

No firmware URL, aborting #141

Open Atorcha opened 10 months ago

Atorcha commented 10 months ago

This is part of my code.

void setup(void)
{
    Serial.begin(115200);
    Serial.setDebugOutput(true);
    esp32FOTA.setManifestURL( manifest_url );
    esp32FOTA.printConfig();
    sensors.begin();
    nvs.begin("datos",false); // use "datos" namespace
    READfromNVS();
    READLoginfromNVS();  
    WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);  
    connectWIFI();   
   // bool updatedNeeded = esp32FOTA.execHTTPcheck();    
    if (MUST_UPDATE == true) {
        nvs.putBool("must_update", false);
        Serial.println("Ha reiniciado ...y empieza actualizacion");       
        esp32FOTA.execOTA();
        delay (2000);
    }   
    ESPUI.setVerbosity(Verbosity::Verbose); //Turn ON verbose debugging
    timeClient.begin(); // Initialize a NTPClient to get time
    timeClient.setTimeOffset(3600); // Set offset time in seconds to adjust for your timezone, for example:
    // GMT +1 = 3600
    timeClient.update();

Check is triggered by a button.

Serial.println("Check update");  // Check version firmware    
    bool updatedNeeded = esp32FOTA.execHTTPcheck(); 
    if (updatedNeeded)
      {
        // necesita_update();
        nvs.putBool("must_update", true);
        Serial.println("Necesita actualizar...y reinicia");
        delay (3000);
        ESP.restart(); // Restart ESP32     
      } 
        Serial.println("NO necesita actualizar...");
        break;
    }