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();
|
Firmware getLatestVersionOnServer();
|
||||||
|
|
||||||
bool checkForUpdate();
|
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:
|
private:
|
||||||
bool _isHTTPS = false;
|
bool _isHTTPS = false;
|
||||||
@@ -22,7 +23,6 @@ class OTA {
|
|||||||
Version _currentVersion;
|
Version _currentVersion;
|
||||||
String _current_device_configuration;
|
String _current_device_configuration;
|
||||||
Firmware createErrorResponse(const String& errorMsg);
|
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_started();
|
||||||
void update_finished();
|
void update_finished();
|
||||||
void update_progress(int cur, int total);
|
void update_progress(int cur, int total);
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
#define water_level_min_key "water_level_min"
|
#define water_level_min_key "water_level_min"
|
||||||
#define water_level_max_key "water_level_max"
|
#define water_level_max_key "water_level_max"
|
||||||
#define water_volume_key "water_volume"
|
#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
|
#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);
|
AsyncWebServer server(80);
|
||||||
#define FORMAT_LITTLEFS_IF_FAILED true
|
#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) {
|
void run_ota(void* parameter) {
|
||||||
@@ -45,10 +59,12 @@ AsyncWebServer server(80);
|
|||||||
Firmware fw = ota.getLatestVersionOnServer();
|
Firmware fw = ota.getLatestVersionOnServer();
|
||||||
Log.verbose("we are done");
|
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());
|
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);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
prefs.begin("waterlevel", false);
|
prefs.begin("waterlevel", false);
|
||||||
|
|||||||
Reference in New Issue
Block a user