Skip to content

Commit 5030f95

Browse files
committed
updated examples
1 parent af14c4d commit 5030f95

File tree

7 files changed

+37
-117
lines changed

7 files changed

+37
-117
lines changed

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();

examples/anyFS/test/1.2.nosecurity.gz/1.2.nosecurity.gz.ino

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414

1515
#include <flashz.hpp> // optional esp32-flashz for gzipped 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 = 2;
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.2";
3031
const char* description = "Basic *gzipped* example with no security and no filesystem";
3132

3233
const char* fota_debug_fmt = R"DBG_FMT(
@@ -76,17 +77,7 @@ void setup()
7677
{
7778
Serial.begin(115200);
7879

79-
Serial.printf( fota_debug_fmt,
80-
"1.2",
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-
);
80+
PrintFOTAInfo();
9081

9182
{
9283
auto cfg = FOTA.getConfig();

examples/anyFS/test/1.3.nosecurity.zz/1.3.nosecurity.zz.ino

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@
1313
*/
1414

1515
#include <esp32FOTA.hpp>
16+
#include <debug/test_fota_common.h>
1617

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

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

3132
const char* fota_debug_fmt = R"DBG_FMT(
@@ -75,17 +76,7 @@ void setup()
7576
{
7677
Serial.begin(115200);
7778

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

9081
{
9182
auto cfg = FOTA.getConfig();

examples/anyFS/test/2.cert-in-spiffs/2.cert-in-spiffs.ino

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
#include <SPIFFS.h> // include filesystem **before** esp32fota !!
1010
#include <esp32fota.h>
11+
#include <debug/test_fota_common.h>
1112

1213
// esp32fota settings
1314
int firmware_version_major = 2;
1415
int firmware_version_minor = 0;
1516
int firmware_version_patch = 0;
1617

17-
#if !defined FOTA_URL
18-
#define FOTA_URL "http://server/fota/fota.json"
19-
#endif
18+
// #define FOTA_URL "http://server/fota/fota.json"
19+
2020
const char* firmware_name = "esp32-fota-http";
2121
const bool check_signature = false;
2222
const bool disable_security = false;
2323
// for debug only
24+
const char* title = "2";
2425
const char* description = "SPIFFS example with security";
2526

2627
const char* fota_debug_fmt = R"DBG_FMT(
@@ -76,17 +77,7 @@ void setup()
7677
{
7778
Serial.begin(115200);
7879

79-
Serial.printf( fota_debug_fmt,
80-
"2",
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-
);
80+
PrintFOTAInfo();
9081

9182
// Provide filesystem with root_ca.pem to validate server certificate
9283
if( ! SPIFFS.begin( false ) ) {

examples/anyFS/test/3.cert-in-progmem/3.cert-in-progmem.ino

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <esp32fota.h>
11+
#include <debug/test_fota_common.h>
1112

1213
#include "root_ca.h"
1314

@@ -16,13 +17,13 @@ int firmware_version_major = 3;
1617
int firmware_version_minor = 0;
1718
int firmware_version_patch = 0;
1819

19-
#if !defined FOTA_URL
20-
#define FOTA_URL "http://server/fota/fota.json"
21-
#endif
20+
// #define FOTA_URL "http://server/fota/fota.json"
21+
2222
const char* firmware_name = "esp32-fota-http";
2323
const bool check_signature = false;
2424
const bool disable_security = false;
2525
// for debug only
26+
const char* title = "3";
2627
const char* description = "PROGMEM example with security";
2728

2829
const char* fota_debug_fmt = R"DBG_FMT(
@@ -80,17 +81,7 @@ void setup()
8081
{
8182
Serial.begin(115200);
8283

83-
Serial.printf( fota_debug_fmt,
84-
"3",
85-
description,
86-
firmware_name,
87-
firmware_version_major,
88-
firmware_version_minor,
89-
firmware_version_patch,
90-
check_signature ?"Enabled":"Disabled",
91-
disable_security ?"Disabled":"Enabled",
92-
FOTA.zlibSupported() ?"Enabled":"Disabled"
93-
);
84+
PrintFOTAInfo();
9485

9586
{
9687
auto cfg = FOTA.getConfig();

examples/anyFS/test/4.cert-in-littlefs/4.cert-in-littlefs.ino

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
#include <LittleFS.h> // include filesystem **before** esp32fota !!
1010
#include <esp32fota.h>
11+
#include <debug/test_fota_common.h>
1112

1213
// esp32fota settings
1314
int firmware_version_major = 4;
1415
int firmware_version_minor = 0;
1516
int firmware_version_patch = 0;
1617

17-
#if !defined FOTA_URL
18-
#define FOTA_URL "http://server/fota/fota.json"
19-
#endif
18+
// #define FOTA_URL "http://server/fota/fota.json"
19+
2020
const char* firmware_name = "esp32-fota-http";
2121
const bool check_signature = true;
2222
const bool disable_security = false;
2323
// for debug only
24+
const char* title = "4";
2425
const char* description = "LittleFS example with enforced security";
2526

2627
const char* fota_debug_fmt = R"DBG_FMT(
@@ -77,17 +78,8 @@ void setup()
7778
{
7879
Serial.begin(115200);
7980

80-
Serial.printf( fota_debug_fmt,
81-
"4",
82-
description,
83-
firmware_name,
84-
firmware_version_major,
85-
firmware_version_minor,
86-
firmware_version_patch,
87-
check_signature ?"Enabled":"Disabled",
88-
disable_security ?"Disabled":"Enabled",
89-
FOTA.zlibSupported() ?"Enabled":"Disabled"
90-
);
81+
PrintFOTAInfo();
82+
9183
// Provide filesystem with root_ca.pem to validate server certificate
9284
if( ! LittleFS.begin( false ) ) {
9385
Serial.println("LittleFS Mounting failed, aborting!");

examples/anyFS/test/5.sig-in-progmem/5.sig-in-progmem.ino

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <esp32fota.h>
11+
#include <debug/test_fota_common.h>
1112

1213
#include "root_ca.h"
1314
#include "pub_key.h"
@@ -17,13 +18,13 @@ int firmware_version_major = 5;
1718
int firmware_version_minor = 0;
1819
int firmware_version_patch = 0;
1920

20-
#if !defined FOTA_URL
21-
#define FOTA_URL "http://server/fota/fota.json"
22-
#endif
21+
// #define FOTA_URL "http://server/fota/fota.json"
22+
2323
const char* firmware_name = "esp32-fota-http";
2424
const bool check_signature = true;
2525
const bool disable_security = false;
2626
// for debug only
27+
const char* title = "5";
2728
const char* description = "PROGMEM example with enforced security";
2829

2930
const char* fota_debug_fmt = R"DBG_FMT(
@@ -78,17 +79,7 @@ void setup()
7879
{
7980
Serial.begin(115200);
8081

81-
Serial.printf( fota_debug_fmt,
82-
"5",
83-
description,
84-
firmware_name,
85-
firmware_version_major,
86-
firmware_version_minor,
87-
firmware_version_patch,
88-
check_signature ?"Enabled":"Disabled",
89-
disable_security ?"Disabled":"Enabled",
90-
FOTA.zlibSupported() ?"Enabled":"Disabled"
91-
);
82+
PrintFOTAInfo();
9283

9384
{
9485
auto cfg = FOTA.getConfig();

0 commit comments

Comments
 (0)