First version able to OTA update
All checks were successful
Test compiling project / test (push) Successful in 2m17s
All checks were successful
Test compiling project / test (push) Successful in 2m17s
This commit is contained in:
@@ -15,6 +15,7 @@ class OTA {
|
||||
Firmware getLatestVersionOnServer();
|
||||
|
||||
bool checkForUpdate();
|
||||
void run_ota_update(String url, std::function<void()> callback_started, std::function<void()> callback_finished, std::function<void(int, int)> callback_progress, std::function<void(int)> callback_error);
|
||||
|
||||
private:
|
||||
bool _isHTTPS = false;
|
||||
@@ -22,7 +23,6 @@ class OTA {
|
||||
Version _currentVersion;
|
||||
String _current_device_configuration;
|
||||
Firmware createErrorResponse(const String& errorMsg);
|
||||
void run_ota_update(String url, std::function<void()> callback_started, std::function<void()> callback_finished, std::function<void(int, int)> callback_progress, std::function<void(int)> callback_error);
|
||||
void update_started();
|
||||
void update_finished();
|
||||
void update_progress(int cur, int total);
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
#define water_level_min_key "water_level_min"
|
||||
#define water_level_max_key "water_level_max"
|
||||
#define water_volume_key "water_volume"
|
||||
#define current_software_version Version{0, 0, 3}
|
||||
#define current_software_version Version{0, 0, 4}
|
||||
|
||||
#define RESISTOR_VALUE 4
|
||||
18
src/main.cpp
18
src/main.cpp
@@ -37,7 +37,21 @@ extern "C" int rom_phy_get_vdd33();
|
||||
|
||||
AsyncWebServer server(80);
|
||||
#define FORMAT_LITTLEFS_IF_FAILED true
|
||||
void update_started() {
|
||||
Log.verbose("OTA Update started");
|
||||
}
|
||||
|
||||
void update_finished() {
|
||||
Log.verbose("OTA Update finished");
|
||||
}
|
||||
|
||||
void update_progress(int cur, int total) {
|
||||
Log.verbose("OTA Update progress: %d/%d", cur, total);
|
||||
}
|
||||
|
||||
void update_error(int err) {
|
||||
Log.error("OTA Update error: %d", err);
|
||||
}
|
||||
|
||||
|
||||
void run_ota(void* parameter) {
|
||||
@@ -45,10 +59,12 @@ AsyncWebServer server(80);
|
||||
Firmware fw = ota.getLatestVersionOnServer();
|
||||
Log.verbose("we are done");
|
||||
Serial.printf("Firmware Info: Valid: %d, Version: %d.%d.%d, URL: %s\n", fw.valid, fw.version.major, fw.version.minor, fw.version.patch, fw.url.c_str());
|
||||
|
||||
ota.run_ota_update(fw.url, update_started, update_finished, update_progress, update_error);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
prefs.begin("waterlevel", false);
|
||||
|
||||
Reference in New Issue
Block a user