Skip to content

Commit 65eb506

Browse files
authored
Merge pull request #103 from chrisjoyce911/0.2.4
0.2.4
2 parents 4ed3c95 + 63e325f commit 65eb506

File tree

21 files changed

+194
-272
lines changed

21 files changed

+194
-272
lines changed

.github/workflows/gen-test-suite.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ jobs:
111111
# Avoid multiline: flatten JSON
112112
- id: set-env
113113
run: |
114-
content='${{ toJson(env) }}'
115-
content="${content//'%'/'%25'}"
116-
content="${content//$'\n'/'%0A'}"
117-
content="${content//$'\r'/'%0D'}"
118-
echo "::set-output name=env::$content"
114+
content='${{ toJson(env) }}' # convert env vars to json
115+
content="${content//'%'/'%25'}" # escape percent entities
116+
content="${content//$'\n'/''}" # remove lf
117+
content="${content//$'\r'/''}" # remove cr
118+
echo "env=${content}" >> $GITHUB_OUTPUT
119+
119120
120121
121122
gen_keys:
@@ -165,7 +166,7 @@ jobs:
165166
cat $pub_key_h_path
166167
167168
- name: Upload RootCA/PubKey as artifact
168-
uses: actions/upload-artifact@v2
169+
uses: actions/upload-artifact@v3
169170
with:
170171
name: Certs
171172
path: |
@@ -197,7 +198,7 @@ jobs:
197198
steps:
198199

199200
- name: Checkout Current
200-
uses: actions/checkout@v2
201+
uses: actions/checkout@v3
201202
with:
202203
ref: ${{ github.event.pull_request.head.sha }}
203204

@@ -223,14 +224,14 @@ jobs:
223224
cp ${{env.cert_path}}/pub_key.h $pub_key_c_path
224225
225226
- name: Checkout esp32-flashz
226-
uses: actions/checkout@v2
227+
uses: actions/checkout@v3
227228
with:
228229
repository: vortigont/esp32-flashz
229230
ref: main
230231
path: CustomflashZ # must contain string "Custom"
231232

232233
- name: Checkout ESP32-targz
233-
uses: actions/checkout@v2
234+
uses: actions/checkout@v3
234235
with:
235236
repository: tobozo/ESP32-targz
236237
ref: master
@@ -297,7 +298,7 @@ jobs:
297298
cat firmware.sign ${{env.littlefs_bin_path}} > ${{env.littlefs_signed_bin_path}}
298299
299300
- name: Update TestSuite artifact
300-
uses: actions/upload-artifact@v2
301+
uses: actions/upload-artifact@v3
301302
with:
302303
name: TestSuite
303304
path: |
@@ -315,7 +316,7 @@ jobs:
315316
steps:
316317

317318
- name: Checkout
318-
uses: actions/checkout@v2
319+
uses: actions/checkout@v3
319320
with:
320321
ref: ${{ github.event.pull_request.head.sha }}
321322

@@ -334,14 +335,14 @@ jobs:
334335
# rm ${{env.privkey_path}}
335336
336337
- name: Update TestSuite artifacts with new JSON Manifest
337-
uses: actions/upload-artifact@v2
338+
uses: actions/upload-artifact@v3
338339
with:
339340
name: TestSuite
340341
path: |
341342
${{env.artifact_path}}/**
342343
343344
- name: Delete Cert/Signature/Privkey artifact
344-
uses: geekyeggo/delete-artifact@v1
345+
uses: geekyeggo/delete-artifact@v2
345346
with:
346347
name: Certs
347348

.github/workflows/platformio.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
matrix:
2727
python-version: [3.7]
2828
steps:
29-
- uses: actions/checkout@v1
29+
- uses: actions/checkout@v3
3030
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v1
31+
uses: actions/setup-python@v4
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434
- name: Install dependencies
@@ -51,7 +51,7 @@ jobs:
5151
lint:
5252
runs-on: ubuntu-latest
5353
steps:
54-
- uses: actions/checkout@v2
54+
- uses: actions/checkout@v3
5555
- uses: arduino/arduino-lint-action@v1
5656
with:
5757
project-type: library

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ A simple library to add support for Over-The-Air (OTA) updates to your project.
1313

1414
## Features
1515

16+
- [x] Zlib or gzip compressed firmware support
17+
- [x] SPIFFS/LittleFS partition Update [#25], [#47], [#60], [#92] (thanks to all participants)
18+
- [x] Any fs::FS support (SPIFFS/LITTLEFS/SD) for cert/signature storage [#79], [#74], [#91], [#92] (thanks to all participants)
19+
- [x] Seamless http/https
1620
- [x] Web update (requires web server)
1721
- [x] Batch firmware sync
1822
- [x] Force firmware update [#8]
1923
- [x] https support [#26] ( Thanks to @fbambusi )
2024
- [x] Signature check of downloaded firmware-image [#65]
21-
- [x] https or https
2225
- [x] Signature verification
2326
- [x] Semantic versioning support
24-
- [x] Any fs::FS support (SPIFFS/LITTLEFS/SD) for cert/signature storage [#79], [#74], [#91], [#92] (thanks to all participants)
25-
- [x] SPIFFS/LittleFS partition Update [#25], [#47], [#60], [#92] (thanks to all participants)
2627
- [ ] Checking for update via bin headers [#15]
2728

2829
## How it works
@@ -34,7 +35,7 @@ There are a few things that need to be in place for an update to work.
3435
- A webserver with the firmware information in a JSON file
3536
- Firmware version
3637
- Firmware type
37-
- Firmware bin
38+
- Firmware bin (can optionnally be compressed with zlib or gzip)
3839
- For https or signature check: SPIFFS with root_ca.pem (https) and rsa_key.pem (signature check)
3940

4041
You can supply http or https URLs. If you are using https, you need the root_ca.pem in your SPIFFS partition. For the actual firmware it will use https when you define port 443 or 4433. Otherwise it will use plain http.
@@ -155,11 +156,13 @@ const char *password = "";
155156

156157
esp32FOTA esp32FOTA("esp32-fota-http", "1.0.0");
157158

159+
const char* manifest_url = "http://server/fota/fota.json";
160+
158161
void setup()
159162
{
160163
Serial.begin(115200);
161164
setup_wifi();
162-
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
165+
esp32FOTA.setManifestURL( manifest_url );
163166
// esp32FOTA.useDeviceId( true ); // optionally append the device ID to the HTTP query
164167
}
165168

@@ -190,11 +193,14 @@ void loop()
190193
Late init is possible using `FOTAConfig_t`, allowing more complex configurations:
191194
192195
```cpp
196+
#include <SPIFFS.h> // include filesystem *before* esp32FOTA librart
193197
#include <esp32FOTA.hpp>
194-
#include <SPIFFS.h>
195198
196199
esp32FOTA FOTA;
197200
201+
const char* manifest_url = "http://server/fota/fota.json";
202+
const char* fota_name = "esp32-fota-http";
203+
198204
// CryptoFileAsset *MyRootCA = new CryptoFileAsset( "/root_ca.pem", &SPIFFS );
199205
// CryptoFileAsset *MyRSAKey = new CryptoFileAsset( "/rsa_key.pub", &SD );
200206
@@ -205,8 +211,8 @@ void setup()
205211
206212
{
207213
auto cfg = FOTA.getConfig();
208-
cfg.name = "esp32-fota-http";
209-
cfg.manifest_url = "http://server/fota/fota.json";
214+
cfg.name = fota_name;
215+
cfg.manifest_url = manifest_url;
210216
cfg.sem = SemverClass( 1, 0, 0 ); // major, minor, patch
211217
cfg.check_sig = false; // verify signed firmware with rsa public key
212218
cfg.unsafe = true; // disable certificate check when using TLS
@@ -335,10 +341,13 @@ CryptoFileAsset *MyPubKey = new CryptoFileAsset("RSA Key", "/rsa_key.pub", &SD);
335341
Then later in the `setup()`:
336342

337343
```C++
344+
345+
const char* manifest_url = "http://server/fota/fota.json";
346+
338347
void setup()
339348
{
340349
// (...)
341-
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
350+
esp32FOTA.setManifestURL( manifest_url );
342351
esp32FOTA.setRootCA( MyRootCA );
343352
esp32FOTA.setPubKey( MyPubKey );
344353
}

examples/HTTP/HTTP.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const char *password = "";
2424
// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
2525
esp32FOTA esp32FOTA("esp32-fota-http", 1, false);
2626

27+
const char* manifest_url = "http://server/fota/fota.json";
28+
2729
void setup_wifi()
2830
{
2931
delay(10);
@@ -44,7 +46,7 @@ void setup_wifi()
4446

4547
void setup()
4648
{
47-
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
49+
esp32FOTA.setManifestURL( manifest_url );
4850
Serial.begin(115200);
4951
setup_wifi();
5052
}

examples/HTTP/HTTPS.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const char *password = "";
3030

3131
// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
3232
esp32FOTA esp32FOTA("esp32-fota-http", 1, false);
33+
const char* manifest_url = "http://server/fota/fota.json";
3334

3435
void setup_wifi()
3536
{
@@ -54,7 +55,7 @@ void setup()
5455
// Provide spiffs with root_ca.pem to validate server certificate
5556
SPIFFS.begin(true);
5657

57-
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
58+
esp32FOTA.setManifestURL( manifest_url );
5859
Serial.begin(115200);
5960
setup_wifi();
6061
}

examples/HTTP/HTTPS_without_root_cert.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
esp32 firmware OTA
3-
3+
44
Purpose: Perform an OTA update from a bin located on a webserver (HTTPS) without having a root cert
55
66
Setup:
77
Step 1 : Set your WiFi (ssid & password)
88
Step 2 : set esp32fota()
9-
9+
1010
Upload:
1111
Step 1 : Menu > Sketch > Export Compiled Library. The bin file will be saved in the sketch folder (Menu > Sketch > Show Sketch folder)
1212
Step 2 : Upload it to your webserver
@@ -29,6 +29,7 @@ const char *password = "";
2929

3030
// esp32fota esp32fota("<Type of Firmware for this device>", <this version>, <validate signature>, <allow insecure https>);
3131
esp32FOTA esp32FOTA("esp32-fota-http", 1, false, true);
32+
const char* manifest_url = "http://server/fota/fota.json";
3233

3334
void setup_wifi()
3435
{
@@ -50,8 +51,8 @@ void setup_wifi()
5051

5152
void setup()
5253
{
53-
54-
esp32FOTA.checkURL = "https://server/fota/fota.json";
54+
55+
esp32FOTA.checkURL = manifest_url;
5556
Serial.begin(115200);
5657
setup_wifi();
5758
}

examples/HTTP/HTTP_signature_check.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const char *password = "";
2828
// esp32fota esp32fota("<Type of Firme for this device>", <this version>, <validate signature>);
2929
esp32FOTA esp32FOTA("esp32-fota-http", 1, true);
3030

31+
const char* manifest_url = "http://server/fota/fota.json";
32+
3133
void setup_wifi()
3234
{
3335
delay(10);
@@ -51,7 +53,7 @@ void setup_wifi()
5153

5254
void setup()
5355
{
54-
esp32FOTA.setManifestURL( "http://server/fota/fota.json" );
56+
esp32FOTA.setManifestURL( manifest_url );
5557
Serial.begin(115200);
5658
setup_wifi();
5759
}

examples/anyFS/test/1.1.nosecurity/1.1.nosecurity.ino

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,22 @@
1414

1515
#include <ESP32-targz.h> // optional ESP32-targz for gzip compressed firmwares
1616
#include <esp32FOTA.hpp>
17+
#include <debug/test_fota_common.h>
1718

1819
// esp32fota settings
1920
int firmware_version_major = 1;
2021
int firmware_version_minor = 1;
2122
int firmware_version_patch = 0;
2223

23-
#if !defined FOTA_URL
24-
#define FOTA_URL "http://server/fota/fota.json"
25-
#endif
24+
// #define FOTA_URL "http://server/fota/fota.json"
25+
2626
const char* firmware_name = "esp32-fota-http";
2727
const bool check_signature = false;
2828
const bool disable_security = true;
2929
// for debug only
30+
const char* title = "1.1";
3031
const char* description = "Basic example with no security and no filesystem";
3132

32-
const char* fota_debug_fmt = R"DBG_FMT(
33-
34-
***************** STAGE %s *****************
35-
36-
Description : %s
37-
Firmware type : %s
38-
Firmware version : %i.%i.%i
39-
Signature check : %s
40-
TLS Cert check : %s
41-
Compression : %s
42-
43-
********************************************
44-
45-
)DBG_FMT";
46-
47-
48-
// esp32fota esp32fota("<Type of Firmware for this device>", <this version>, <validate signature>, <allow insecure TLS>);
49-
// esp32FOTA esp32FOTA( String(firmware_name), firmware_version, check_signature, disable_security );
50-
5133

5234
esp32FOTA FOTA;
5335

@@ -76,17 +58,7 @@ void setup()
7658
{
7759
Serial.begin(115200);
7860

79-
Serial.printf( fota_debug_fmt,
80-
"1.1",
81-
description,
82-
firmware_name,
83-
firmware_version_major,
84-
firmware_version_minor,
85-
firmware_version_patch,
86-
check_signature ?"Enabled":"Disabled",
87-
disable_security ?"Disabled":"Enabled",
88-
FOTA.zlibSupported() ?"Enabled":"Disabled"
89-
);
61+
PrintFOTAInfo();
9062

9163
{
9264
auto cfg = FOTA.getConfig();
@@ -103,6 +75,7 @@ void setup()
10375
setup_wifi();
10476
}
10577

78+
10679
void loop()
10780
{
10881
FOTA.handle();

0 commit comments

Comments
 (0)