Skip to content

Commit e9ea5fb

Browse files
committed
Fix issues and improve file handling.
1 parent 4b56e83 commit e9ea5fb

File tree

18 files changed

+4277
-2675
lines changed

18 files changed

+4277
-2675
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 mobizt
3+
Copyright (c) 2022 mobizt
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The ESPForm for Arduino v 1.0.6
1+
# The ESPForm for Arduino v 1.0.7
22

33

44
The simple HTML Form Elements data interchange library for ESP32/ESP8266 through the Webserver.
@@ -305,7 +305,7 @@ See [Full Examples](/examples) for the usages, below are the screenshots of thes
305305
306306
The MIT License (MIT)
307307
308-
Copyright (c) 2021 K. Suwatchai (Mobizt)
308+
Copyright (c) 2022 K. Suwatchai (Mobizt)
309309
310310
311311
Permission is hereby granted, free of charge, to any person returning a copy of

examples/Chart/Chart.ino

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
#include <ESPForm.h>
99

10-
//For HTML content
10+
// For HTML content
1111
#include "html.h"
1212

13-
//Your WiFi SSID and Password
13+
// Your WiFi SSID and Password
1414
#define WIFI_SSID "Your_WiFi_SSID"
1515
#define WIFI_PASSWORD "Your_WiFi_Password"
1616

17-
//The AP
17+
// The AP
1818
String apSSID = "ESPForm";
1919
String apPSW = "12345678";
2020

@@ -34,7 +34,7 @@ void formElementEventCallback(ESPFormClass::HTMLElementItem element)
3434
Serial.println("***********************************");
3535
Serial.println();
3636

37-
//If first knob value changed
37+
// If first knob value changed
3838
if (element.id == "clear-btn")
3939
{
4040
ESPForm.runScript("clearData()");
@@ -44,7 +44,7 @@ void formElementEventCallback(ESPFormClass::HTMLElementItem element)
4444
void serverTimeoutCallback()
4545
{
4646

47-
//If server timeout (no client connected within specific time)
47+
// If server timeout (no client connected within specific time)
4848
Serial.println("***********************************");
4949
Serial.println("Server timed out");
5050
Serial.println("***********************************");
@@ -63,10 +63,10 @@ void setup()
6363
WiFi.disconnect(true);
6464
WiFi.persistent(false);
6565

66-
//Set WiFi mode to STA (create ESP own network) or AP + STA (create ESP own network and join the WiFi network)
66+
// Set WiFi mode to STA (create ESP own network) or AP + STA (create ESP own network and join the WiFi network)
6767
WiFi.mode(WIFI_AP_STA);
6868

69-
//For STA only or AP + STA mode
69+
// For STA only or AP + STA mode
7070
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
7171
Serial.print("Connecting to Wi-Fi");
7272
while (WiFi.status() != WL_CONNECTED)
@@ -79,54 +79,58 @@ void setup()
7979
Serial.println(WiFi.localIP());
8080
Serial.println();
8181

82-
//generate seed numbers
82+
// generate seed numbers
83+
#if defined(ESP32)
84+
randomSeed(analogRead(34));
85+
#elif defined(ESP8266)
8386
randomSeed(analogRead(0));
87+
#endif
8488

85-
//Set the system time via NTP server
89+
// Set the system time via NTP server
8690
Serial.println("***********************************");
8791
Serial.println("Set up time...");
8892
ESPForm.setClock(timezone);
8993
Serial.println("***********************************");
9094
Serial.println();
9195

92-
//FLASH_FS is defined in ESPFormFS.h
96+
// DEFAULT_FLASH_FS is defined in ESPFormFS.h
9397
#if defined(ESP32)
94-
FLASH_FS.begin(true);
98+
DEFAULT_FLASH_FS.begin(true);
9599
#elif defined(ESP8266)
96-
FLASH_FS.begin();
100+
DEFAULT_FLASH_FS.begin();
97101
#endif
98102

99-
//Element Event Config existed?
100-
if (!FLASH_FS.exists("/chart-test.json"))
103+
// Element Event Config existed?
104+
if (!DEFAULT_FLASH_FS.exists("/chart-test.json"))
101105
{
102106

103-
//Add html element event listener, id "knob1" for onchange event
107+
// Add html element event listener, id "knob1" for onchange event
104108
ESPForm.addElementEventListener("clear-btn", ESPFormClass::EVENT_ON_CLICK);
105109

106110
/*
107111
If the id of html elements changed, please update the ElementEventListener config
108112
*/
109113

110-
//Save notification config
114+
// Save notification config
111115
ESPForm.saveElementEventConfig("/chart-test.json", esp_form_storage_flash);
112116
}
113117
else
114118
{
115-
//Load notification config
119+
// Load notification config
116120
ESPForm.loadElementEventConfig("/chart-test.json", esp_form_storage_flash);
117121
}
118122

119-
//Add the html contents (in html.h) for the web page rendering
123+
// Add the html contents (in html.h) for the web page rendering
120124

121-
//flash uint8_t array, file name, size of array, gzip compression
125+
// flash uint8_t array, file name, size of array, gzip compression
122126
ESPForm.addFileData(index_html_gz, "index.html", sizeof(index_html_gz), true);
123127
ESPForm.addFileData(main_js_gz, "main.js", sizeof(main_js_gz), true);
124128
ESPForm.addFileData(highcharts_js_gz, "highcharts.js", sizeof(highcharts_js_gz), true);
125129

126-
//If AP only or AP + STA mode, set the AP's SSID and Password
130+
// If AP only or AP + STA mode, set the AP's SSID and Password
127131
ESPForm.setAP(apSSID.c_str(), apPSW.c_str());
128132

129-
//Start ESPForm's Webserver
133+
// Start ESPForm's Webserver
130134
ESPForm.begin(formElementEventCallback, serverTimeoutCallback, serverTimeout, true);
131135

132136
ESPForm.startServer();
@@ -143,7 +147,7 @@ void setup()
143147

144148
void loop()
145149
{
146-
//If a client existed
150+
// If a client existed
147151
if (ESPForm.getClientCount() > 0)
148152
{
149153

examples/Knob/Knob.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ void setup()
7878
Serial.println(WiFi.localIP());
7979
Serial.println();
8080

81-
//FLASH_FS is defined in ESPFormFS.h
81+
//DEFAULT_FLASH_FS is defined in ESPFormFS.h
8282
#if defined(ESP32)
83-
FLASH_FS.begin(true);
83+
DEFAULT_FLASH_FS.begin(true);
8484
#elif defined(ESP8266)
85-
FLASH_FS.begin();
85+
DEFAULT_FLASH_FS.begin();
8686
#endif
8787

8888
//Element Event Config existed?
89-
if (!FLASH_FS.exists("/knob-test.json"))
89+
if (!DEFAULT_FLASH_FS.exists("/knob-test.json"))
9090
{
9191

9292
//Add html element event listener, id "knob1" for onchange event

examples/WiFiSettings/WiFiSettings.ino

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ bool loadConfig()
148148
void deleteConfigFile(const String &filename)
149149
{
150150
Serial.println("MAIN: Delete config file...");
151-
//FLASH_FS is defined in ESPFormFS.h
151+
//DEFAULT_FLASH_FS is defined in ESPFormFS.h
152152
#if defined(ESP32)
153-
FLASH_FS.begin(true);
153+
DEFAULT_FLASH_FS.begin(true);
154154
#elif defined(ESP8266)
155-
FLASH_FS.begin();
155+
DEFAULT_FLASH_FS.begin();
156156
#endif
157157

158-
if (FLASH_FS.exists(filename))
159-
FLASH_FS.remove(filename);
158+
if (DEFAULT_FLASH_FS.exists(filename))
159+
DEFAULT_FLASH_FS.remove(filename);
160160

161161
Serial.println("MAIN: Success");
162162
Serial.println();
@@ -166,14 +166,14 @@ bool loadWiFiConfig(const String &filename)
166166
{
167167

168168
Serial.print("MAIN: Load WiFi config...");
169-
//FLASH_FS is defined in ESPFormFS.h
169+
//DEFAULT_FLASH_FS is defined in ESPFormFS.h
170170
#if defined(ESP32)
171-
FLASH_FS.begin(true);
171+
DEFAULT_FLASH_FS.begin(true);
172172
#elif defined(ESP8266)
173-
FLASH_FS.begin();
173+
DEFAULT_FLASH_FS.begin();
174174
#endif
175175

176-
if (!FLASH_FS.exists(filename))
176+
if (!DEFAULT_FLASH_FS.exists(filename))
177177
{
178178
Serial.println(" file is not existed");
179179
//Add new config.

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
},
99
"frameworks": "arduino",
1010
"platforms": "esp32, esp8266",
11-
"version": "1.0.6"
11+
"version": "1.0.7"
1212
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=ESPForm for Arduino
22

3-
version=1.0.6
3+
version=1.0.7
44

55
author=Mobizt
66

0 commit comments

Comments
 (0)