From 718ca9e11da0af702e202ade7cbfbf5d0322ad03 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 16:54:38 +0100 Subject: [PATCH 01/12] Fix config setters not allocating memory properly --- src/esp32FOTA.cpp | 46 +++++++++++++++++++++++++++++++++++++--------- src/esp32FOTA.hpp | 10 ++++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/esp32FOTA.cpp b/src/esp32FOTA.cpp index 3cd3a83..ccdd113 100644 --- a/src/esp32FOTA.cpp +++ b/src/esp32FOTA.cpp @@ -124,19 +124,29 @@ esp32FOTA::esp32FOTA( FOTAConfig_t cfg ) } -void esp32FOTA::setString( const char *dest, const char* src ) +void esp32FOTA::setString( char **dest, const char* src ) { - if( !src ) return; - dest = (const char*)calloc( strlen(src)+1, sizeof(char)); - strcpy( (char*)dest, src ); + if( !src ) { + log_e("Can't set string to empty source"); + return; + } + if( *dest != nullptr ) free( *dest ); + *dest = (char*)malloc( strlen(src)+1 ); + if( *dest == NULL ) { + log_e("Unable to allocate %d bytes", strlen(src)+1); + return; + } + //strcpy( dest, src); + memcpy( *dest, src, strlen(src)+1); + log_d("Assigned value: %s <= %s", *dest, src ); } esp32FOTA::esp32FOTA(const char* firmwareType, int firmwareVersion, bool validate, bool allow_insecure_https) { - setString( _cfg.name, firmwareType ); - _cfg.name = firmwareType; + setString( &_cfg.name, firmwareType ); + //_cfg.name = (char*)firmwareType; _cfg.sem = SemverClass( firmwareVersion ); _cfg.check_sig = validate; _cfg.unsafe = allow_insecure_https; @@ -148,7 +158,8 @@ esp32FOTA::esp32FOTA(const char* firmwareType, int firmwareVersion, bool validat esp32FOTA::esp32FOTA(const char* firmwareType, const char* firmwareSemanticVersion, bool validate, bool allow_insecure_https) { - setString( _cfg.name, firmwareType ); + setString( &_cfg.name, firmwareType ); + //_cfg.name = (char*)firmwareType; _cfg.check_sig = validate; _cfg.unsafe = allow_insecure_https; _cfg.sem = SemverClass( firmwareSemanticVersion ); @@ -161,8 +172,8 @@ esp32FOTA::esp32FOTA(const char* firmwareType, const char* firmwareSemanticVersi void esp32FOTA::setConfig( FOTAConfig_t cfg ) { - setString( _cfg.name, cfg.name ); - setString( _cfg.manifest_url, cfg.manifest_url ); + setString( &_cfg.name, cfg.name ); + setString( &_cfg.manifest_url, cfg.manifest_url ); _cfg.sem = cfg.sem; _cfg.check_sig = cfg.check_sig; @@ -173,6 +184,23 @@ void esp32FOTA::setConfig( FOTAConfig_t cfg ) } +void esp32FOTA::printConfig( FOTAConfig_t *cfg ) +{ + if( cfg == nullptr ) cfg = &_cfg; + Serial.printf("Name: %s\nManifest URL:%s\nSemantic Version: %d.%d.%d\nCheck Sig: %s\nUnsafe: %s\nUse Device ID: %s\nRootCA: %s\nPubKey: %s\n", + cfg->name ? cfg->name : "None", + cfg->manifest_url ? cfg->manifest_url : "None", + cfg->sem.ver()->major, + cfg->sem.ver()->minor, + cfg->sem.ver()->patch, + cfg->check_sig ?"true":"false", + cfg->unsafe ?"true":"false", + cfg->use_device_id ?"true":"false", + cfg->root_ca ?"true":"false", + cfg->pub_key ?"true":"false" + ); +} + void esp32FOTA::setCertFileSystem( fs::FS *cert_filesystem ) diff --git a/src/esp32FOTA.hpp b/src/esp32FOTA.hpp index 98e8a52..4396114 100644 --- a/src/esp32FOTA.hpp +++ b/src/esp32FOTA.hpp @@ -189,8 +189,8 @@ class CryptoMemAsset : public CryptoAsset struct FOTAConfig_t { - const char* name { nullptr }; - const char* manifest_url { nullptr }; + char* name { nullptr }; + char* manifest_url { nullptr }; SemverClass sem {0}; bool check_sig { false }; bool unsafe { false }; @@ -242,9 +242,11 @@ class esp32FOTA // config setter void setConfig( FOTAConfig_t cfg ); + void printConfig( FOTAConfig_t *cfg=nullptr ); // Manually specify the manifest url, this is provided as a transition between legagy and new config system - void setManifestURL( const String &manifest_url ) { setString( _cfg.manifest_url, manifest_url.c_str() ); } + void setManifestURL( const char* manifest_url ) { setString( &_cfg.manifest_url, manifest_url ); } + void setManifestURL( const String &manifest_url ) { setManifestURL( manifest_url.c_str() ); } // use this to set "Authorization: Basic" or other specific headers to be sent with the queries void setExtraHTTPHeader( String name, String value ) { extraHTTPHeaders[name] = value; } @@ -329,7 +331,7 @@ class esp32FOTA void setupStream(); void stopStream(); - void setString( const char *dest, const char* src ); // mem allocator + void setString( char **dest, const char* src ); // mem allocator FOTAConfig_t _cfg; From 4e481963cbfe71b487f06ef3ba4c03f2847395a9 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 16:54:51 +0100 Subject: [PATCH 02/12] update examples --- examples/HTTP/HTTP/HTTP.ino | 8 +++--- examples/HTTP/HTTPS/HTTPS.ino | 15 ++++++----- .../HTTPS_without_root_cert.ino | 10 +++----- .../HTTP_signature_check.ino | 10 ++++---- examples/anyFS/anyFS.ino | 6 ++--- examples/forceUpdate/forceUpdate.ino | 22 ++++++++-------- examples/withDeviceID/withDeviceID.ino | 25 +++++++++---------- 7 files changed, 44 insertions(+), 52 deletions(-) diff --git a/examples/HTTP/HTTP/HTTP.ino b/examples/HTTP/HTTP/HTTP.ino index eeb22ba..c0bff83 100644 --- a/examples/HTTP/HTTP/HTTP.ino +++ b/examples/HTTP/HTTP/HTTP.ino @@ -17,9 +17,6 @@ #include #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; // esp32fota esp32fota("", , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, false); @@ -32,7 +29,7 @@ void setup_wifi() Serial.print("Connecting to "); Serial.println(ssid); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -46,8 +43,9 @@ void setup_wifi() void setup() { - esp32FOTA.setManifestURL( manifest_url ); Serial.begin(115200); + esp32FOTA.setManifestURL( manifest_url ); + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/HTTP/HTTPS/HTTPS.ino b/examples/HTTP/HTTPS/HTTPS.ino index aeb52c4..9ac45af 100644 --- a/examples/HTTP/HTTPS/HTTPS.ino +++ b/examples/HTTP/HTTPS/HTTPS.ino @@ -24,13 +24,11 @@ #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; - // esp32fota esp32fota("", , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, false); -const char* manifest_url = "http://server/fota/fota.json"; +const char* manifest_url = "https://server/fota/fota.json"; + +CryptoFileAsset *MyRootCA = new CryptoFileAsset( "/root_ca.pem", &SPIFFS ); void setup_wifi() { @@ -38,7 +36,7 @@ void setup_wifi() Serial.print("Connecting to "); Serial.println(ssid); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -52,11 +50,12 @@ void setup_wifi() void setup() { + Serial.begin(115200); // Provide spiffs with root_ca.pem to validate server certificate SPIFFS.begin(true); - esp32FOTA.setManifestURL( manifest_url ); - Serial.begin(115200); + esp32FOTA.setRootCA( MyRootCA ); + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino b/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino index 38857ef..1f59fd5 100644 --- a/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino +++ b/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino @@ -23,10 +23,6 @@ #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; - // esp32fota esp32fota("", , , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, false, true); const char* manifest_url = "http://server/fota/fota.json"; @@ -37,7 +33,7 @@ void setup_wifi() Serial.print("Connecting to "); Serial.println(ssid); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -51,9 +47,9 @@ void setup_wifi() void setup() { - - esp32FOTA.checkURL = manifest_url; Serial.begin(115200); + esp32FOTA.setManifestURL( manifest_url ); + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino b/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino index bd82d89..b45a4d2 100644 --- a/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino +++ b/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino @@ -21,14 +21,12 @@ #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; // esp32fota esp32fota("", , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, true); const char* manifest_url = "http://server/fota/fota.json"; +CryptoFileAsset *MyRSAKey = new CryptoFileAsset( "/rsa_key.pub", &SPIFFS ); void setup_wifi() { @@ -39,7 +37,7 @@ void setup_wifi() // Need to provide SPIFFS with rsa_key.pub inside. SPIFFS.begin( true ); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -53,8 +51,10 @@ void setup_wifi() void setup() { - esp32FOTA.setManifestURL( manifest_url ); Serial.begin(115200); + esp32FOTA.setManifestURL( manifest_url ); + esp32FOTA.setPubKey( MyRSAKey ); + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/anyFS.ino b/examples/anyFS/anyFS.ino index ef0c051..e2cb853 100644 --- a/examples/anyFS/anyFS.ino +++ b/examples/anyFS/anyFS.ino @@ -81,8 +81,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; @@ -92,7 +92,7 @@ void setup() FOTA.setConfig( cfg ); } - + FOTA.printConfig(); // FOTA.setStatusChecker( WiFiConnected ); diff --git a/examples/forceUpdate/forceUpdate.ino b/examples/forceUpdate/forceUpdate.ino index 44a9a13..1c2aa13 100644 --- a/examples/forceUpdate/forceUpdate.ino +++ b/examples/forceUpdate/forceUpdate.ino @@ -17,29 +17,19 @@ #include #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; // esp32fota esp32fota("", , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, false); const char* manifest_url = "http://server/fota/fota.json"; -void setup() -{ - esp32FOTA.setManifestURL( manifest_url ); - Serial.begin(115200); - setup_wifi(); -} - void setup_wifi() { delay(10); Serial.print("Connecting to "); Serial.println(ssid); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -51,6 +41,16 @@ void setup_wifi() Serial.println(WiFi.localIP()); } + +void setup() +{ + Serial.begin(115200); + esp32FOTA.setManifestURL( manifest_url ); + esp32FOTA.printConfig(); + setup_wifi(); +} + + void loop() { delay(2000); diff --git a/examples/withDeviceID/withDeviceID.ino b/examples/withDeviceID/withDeviceID.ino index b4689b1..64e9127 100644 --- a/examples/withDeviceID/withDeviceID.ino +++ b/examples/withDeviceID/withDeviceID.ino @@ -17,30 +17,18 @@ #include #include -// Change to your WiFi credentials -const char *ssid = ""; -const char *password = ""; // esp32fota esp32fota("", , ); esp32FOTA esp32FOTA("esp32-fota-http", 1, false); const char* manifest_url = "http://server/fota/fota.json"; -void setup() -{ - Serial.begin(115200); - setup_wifi(); - - esp32FOTA.setManifestURL( manifest_url ); - esp32FOTA.useDeviceId( true ); -} - void setup_wifi() { delay(10); Serial.print("Connecting to "); Serial.println(ssid); - WiFi.begin(ssid, password); + WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) { @@ -52,6 +40,17 @@ void setup_wifi() Serial.println(WiFi.localIP()); } + +void setup() +{ + Serial.begin(115200); + esp32FOTA.setManifestURL( manifest_url ); + esp32FOTA.useDeviceId( true ); + esp32FOTA.printConfig(); + setup_wifi(); +} + + void loop() { bool updatedNeeded = esp32FOTA.execHTTPcheck(); From f2d7f4900bff10c5495c4b286348cb56a48fbd92 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 16:55:03 +0100 Subject: [PATCH 03/12] bump version --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index bbfb216..e666db7 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "esp32FOTA", - "version": "0.2.6", + "version": "0.2.7", "keywords": "firmware, OTA, Over The Air Updates, ArduinoOTA", "description": "Allows for firmware to be updated from a webserver, the device can check for updates at any time. Uses a simple JSON file to outline if a new firmware is avaiable.", "examples": "examples/*/*.ino", diff --git a/library.properties b/library.properties index d7f08ad..11a9da3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=esp32FOTA -version=0.2.6 +version=0.2.7 author=Chris Joyce maintainer=Chris Joyce sentence=A simple library for firmware OTA updates From 8737d74599f5e5a9330d264f1c5739a617ba7ae0 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 16:59:14 +0100 Subject: [PATCH 04/12] update examples --- examples/HTTP/HTTP/HTTP.ino | 4 +--- examples/HTTP/HTTPS/HTTPS.ino | 3 +-- .../HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino | 3 +-- examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino | 3 +-- examples/forceUpdate/forceUpdate.ino | 3 +-- examples/withDeviceID/withDeviceID.ino | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/examples/HTTP/HTTP/HTTP.ino b/examples/HTTP/HTTP/HTTP.ino index c0bff83..0f58694 100644 --- a/examples/HTTP/HTTP/HTTP.ino +++ b/examples/HTTP/HTTP/HTTP.ino @@ -26,9 +26,7 @@ const char* manifest_url = "http://server/fota/fota.json"; void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); - + Serial.print("Connecting to WiFi"); WiFi.begin(); // no WiFi creds in this demo :-) while (WiFi.status() != WL_CONNECTED) diff --git a/examples/HTTP/HTTPS/HTTPS.ino b/examples/HTTP/HTTPS/HTTPS.ino index 9ac45af..dfbab0e 100644 --- a/examples/HTTP/HTTPS/HTTPS.ino +++ b/examples/HTTP/HTTPS/HTTPS.ino @@ -33,8 +33,7 @@ CryptoFileAsset *MyRootCA = new CryptoFileAsset( "/root_ca.pem", &SPIFFS ); void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.print("Connecting to WiFi"); WiFi.begin(); // no WiFi creds in this demo :-) diff --git a/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino b/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino index 1f59fd5..ac19647 100644 --- a/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino +++ b/examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino @@ -30,8 +30,7 @@ const char* manifest_url = "http://server/fota/fota.json"; void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.print("Connecting to WiFi"); WiFi.begin(); // no WiFi creds in this demo :-) diff --git a/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino b/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino index b45a4d2..ae56dff 100644 --- a/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino +++ b/examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino @@ -31,8 +31,7 @@ CryptoFileAsset *MyRSAKey = new CryptoFileAsset( "/rsa_key.pub", &SPIFFS ); void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.print("Connecting to WiFi"); // Need to provide SPIFFS with rsa_key.pub inside. SPIFFS.begin( true ); diff --git a/examples/forceUpdate/forceUpdate.ino b/examples/forceUpdate/forceUpdate.ino index 1c2aa13..23c6e6c 100644 --- a/examples/forceUpdate/forceUpdate.ino +++ b/examples/forceUpdate/forceUpdate.ino @@ -26,8 +26,7 @@ const char* manifest_url = "http://server/fota/fota.json"; void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.print("Connecting to WiFi"); WiFi.begin(); // no WiFi creds in this demo :-) diff --git a/examples/withDeviceID/withDeviceID.ino b/examples/withDeviceID/withDeviceID.ino index 64e9127..7849ac0 100644 --- a/examples/withDeviceID/withDeviceID.ino +++ b/examples/withDeviceID/withDeviceID.ino @@ -25,8 +25,7 @@ const char* manifest_url = "http://server/fota/fota.json"; void setup_wifi() { delay(10); - Serial.print("Connecting to "); - Serial.println(ssid); + Serial.print("Connecting to WiFi"); WiFi.begin(); // no WiFi creds in this demo :-) From 4e0c0640d20bd1fb1f2f9492f8aa9b1704bdda84 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:12:25 +0100 Subject: [PATCH 05/12] fix workflows --- .github/workflows/arduino.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 11b2613..7b8b017 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -23,14 +23,27 @@ jobs: - name: esp32:esp32 source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json libraries: | - - name: esp32FOTA - path: ./ - name: ArduinoJson - name: ESP32-targz - name: esp32-flashz source-url: https://github.com/vortigont/esp32-flashz.git - #sketch-paths: | - #- examples/HTTP/HTTP/HTTP.ino + sketch-paths: | + - examples/withDeviceID/withDeviceID.ino + - examples/forceUpdate/forceUpdate.ino + - examples/HTTP/HTTP_signature_check/HTTP_signature_check.ino + - examples/HTTP/HTTPS/HTTPS.ino + - examples/HTTP/HTTPS_without_root_cert/HTTPS_without_root_cert.ino + - examples/HTTP/HTTP/HTTP.ino + - examples/anyFS/anyFS.ino + - examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino + - examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino + - examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino + - examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino + - examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino + - examples/anyFS/test/99.final-stage/99.final-stage.ino + - examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino + - examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino + cli-compile-flags: | - --warnings="default" From 5cd478c9218b4e248ac619f9f0285afde49c11e6 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:16:44 +0100 Subject: [PATCH 06/12] fix workflows --- .github/workflows/arduino.yml | 2 ++ examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino | 4 ++-- examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino | 4 ++-- examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino | 4 ++-- examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino | 4 ++-- examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino | 4 ++-- examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino | 4 ++-- examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino | 4 ++-- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 7b8b017..9956a4b 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -23,6 +23,8 @@ jobs: - name: esp32:esp32 source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json libraries: | + - name: esp32FOTA + path: ./ - name: ArduinoJson - name: ESP32-targz - name: esp32-flashz diff --git a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino index 792ff53..89861f0 100644 --- a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino +++ b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino @@ -62,8 +62,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino index 73b1031..e7e00ff 100644 --- a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino +++ b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino @@ -62,8 +62,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino index 9aa631e..3288620 100644 --- a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino +++ b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino @@ -61,8 +61,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino index f770a08..ac21b0f 100644 --- a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino +++ b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino @@ -70,8 +70,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino index c542b4f..8965d11 100644 --- a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino +++ b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino @@ -67,8 +67,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino index a729b9b..9f893f8 100644 --- a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino +++ b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino @@ -70,8 +70,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; diff --git a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino index 4de37e0..f6b1a3c 100644 --- a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino +++ b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino @@ -66,8 +66,8 @@ void setup() { auto cfg = FOTA.getConfig(); - cfg.name = firmware_name; - cfg.manifest_url = FOTA_URL; + cfg.name = (char*)firmware_name; + cfg.manifest_url = (char*)FOTA_URL; cfg.sem = SemverClass( firmware_version_major, firmware_version_minor, firmware_version_patch ); cfg.check_sig = check_signature; cfg.unsafe = disable_security; From a5162d0c0a50944be5b0e3dbf06720b60aa6061b Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:24:00 +0100 Subject: [PATCH 07/12] fix workflows --- .github/workflows/arduino.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 9956a4b..80ac8c1 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -13,6 +13,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Compile examples uses: arduino/compile-sketches@v1 @@ -25,6 +27,7 @@ jobs: libraries: | - name: esp32FOTA path: ./ + version: ${{ github.event.pull_request.head.sha }} - name: ArduinoJson - name: ESP32-targz - name: esp32-flashz From 4925148531492f4bdf4a97c2a7999d0dd42f5b0b Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:27:02 +0100 Subject: [PATCH 08/12] fix workflows --- .github/workflows/arduino.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 80ac8c1..e4275d2 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -13,8 +13,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} + #with: + #ref: ${{ github.event.ref }} - name: Compile examples uses: arduino/compile-sketches@v1 @@ -27,7 +27,7 @@ jobs: libraries: | - name: esp32FOTA path: ./ - version: ${{ github.event.pull_request.head.sha }} + version: ${{ github.event.ref }} - name: ArduinoJson - name: ESP32-targz - name: esp32-flashz From 178243eb75b032b19ecfbceffc796b82a39dbe1f Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:30:24 +0100 Subject: [PATCH 09/12] fix workflows --- .github/workflows/arduino.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index e4275d2..01e8289 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -13,21 +13,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - #with: - #ref: ${{ github.event.ref }} - name: Compile examples uses: arduino/compile-sketches@v1 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + #github-token: ${{ secrets.GITHUB_TOKEN }} fqbn: esp32:esp32:esp32 platforms: | - name: esp32:esp32 source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json libraries: | - name: esp32FOTA - path: ./ - version: ${{ github.event.ref }} + source-path: ./ - name: ArduinoJson - name: ESP32-targz - name: esp32-flashz From 07b3eb49d93fcf25a23b9095567cda1afbbf242d Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:48:58 +0100 Subject: [PATCH 10/12] added printConfig() --- .github/workflows/arduino.yml | 1 - examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino | 1 + examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino | 1 + examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino | 1 + examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino | 1 + examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino | 1 + examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino | 1 + examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino | 1 + src/debug/test_fota_common.h | 2 +- 9 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 01e8289..c69e893 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -17,7 +17,6 @@ jobs: - name: Compile examples uses: arduino/compile-sketches@v1 with: - #github-token: ${{ secrets.GITHUB_TOKEN }} fqbn: esp32:esp32:esp32 platforms: | - name: esp32:esp32 diff --git a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino index 89861f0..ec3c1a8 100644 --- a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino +++ b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino @@ -71,6 +71,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino index e7e00ff..760ba41 100644 --- a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino +++ b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino @@ -71,6 +71,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino index 3288620..f017c74 100644 --- a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino +++ b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino @@ -70,6 +70,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino index ac21b0f..94b2786 100644 --- a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino +++ b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino @@ -79,6 +79,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino index 8965d11..9bf87a4 100644 --- a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino +++ b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino @@ -76,6 +76,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino index 9f893f8..e62dfb3 100644 --- a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino +++ b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino @@ -79,6 +79,7 @@ void setup() cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); diff --git a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino index f6b1a3c..1364546 100644 --- a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino +++ b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino @@ -75,6 +75,7 @@ void setup() cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } + esp32FOTA.printConfig(); setup_wifi(); } diff --git a/src/debug/test_fota_common.h b/src/debug/test_fota_common.h index 67e54ab..8d0eab4 100644 --- a/src/debug/test_fota_common.h +++ b/src/debug/test_fota_common.h @@ -6,7 +6,7 @@ extern int firmware_version_minor; extern int firmware_version_patch; #if !defined FOTA_URL - #define FOTA_URL "http://server/fota/fota.json" + #define FOTA_URL "http://phpsecu.re/esp32/esp32fota/firmware.json" #endif extern const char* firmware_name; From 7fa8e81f9649f304d0737dce9ae163339e8862bd Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:52:40 +0100 Subject: [PATCH 11/12] added printConfig() --- src/debug/test_fota_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/test_fota_common.h b/src/debug/test_fota_common.h index 8d0eab4..67e54ab 100644 --- a/src/debug/test_fota_common.h +++ b/src/debug/test_fota_common.h @@ -6,7 +6,7 @@ extern int firmware_version_minor; extern int firmware_version_patch; #if !defined FOTA_URL - #define FOTA_URL "http://phpsecu.re/esp32/esp32fota/firmware.json" + #define FOTA_URL "http://server/fota/fota.json" #endif extern const char* firmware_name; From 744c362bc984b7fabc5bb15b1c95c9fa15115d95 Mon Sep 17 00:00:00 2001 From: tobozo Date: Sat, 10 Dec 2022 17:58:10 +0100 Subject: [PATCH 12/12] added printConfig() --- examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino | 2 +- examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino | 2 +- examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino | 2 +- examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino | 2 +- examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino | 2 +- examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino | 2 +- examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino index ec3c1a8..6942cf2 100644 --- a/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino +++ b/examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino @@ -71,7 +71,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino index 760ba41..35a422a 100644 --- a/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino +++ b/examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino @@ -71,7 +71,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino index f017c74..ff46a3d 100644 --- a/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino +++ b/examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino @@ -70,7 +70,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino index 94b2786..e6aeadc 100644 --- a/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino +++ b/examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino @@ -79,7 +79,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino index 9bf87a4..8d15a3f 100644 --- a/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino +++ b/examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino @@ -76,7 +76,7 @@ void setup() //cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); } diff --git a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino index e62dfb3..8aa1663 100644 --- a/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino +++ b/examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino @@ -79,7 +79,7 @@ void setup() cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); diff --git a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino index 1364546..a80b081 100644 --- a/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino +++ b/examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino @@ -75,7 +75,7 @@ void setup() cfg.pub_key = MyRSAKey; FOTA.setConfig( cfg ); } - esp32FOTA.printConfig(); + FOTA.printConfig(); setup_wifi(); }