Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit b3b4206

Browse files
authored
v1.0.8
### Releases 1.0.8 1. Fix setSTAStaticIPConfig issue. 2. Add LittleFS support for ESP8266 core 2.7.1+ in examples to replace deprecated SPIFFS. 3. Restructure code.
1 parent 721102e commit b3b4206

27 files changed

+2918
-325
lines changed

README.md

+36-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
77
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP_WiFiManager.svg)](http://github.com/khoih-prog/ESP_WiFiManager/issues)
88

9+
### Releases 1.0.8
10+
11+
1. Fix setSTAStaticIPConfig issue. See [Static Station IP doesn't work](https://github.com/khoih-prog/ESP_WiFiManager/issues/17)
12+
2. Add LittleFS support for ESP8266 core 2.7.1+ in examples to replace deprecated SPIFFS.
13+
3. Restructure code.
14+
915
### Releases 1.0.7
1016

1117
1. Use `just-in-time` scanWiFiNetworks() to reduce connection time necessary for battery-operated DeepSleep application. Thanks to [CrispinP](https://github.com/CrispinP) for identifying, requesting and testing. See [Starting WiFIManger is very slow (2000ms)](https://github.com/khoih-prog/ESP_WiFiManager/issues/6)
@@ -21,6 +27,8 @@
2127
1. Add function getConfigPortalPW()
2228
2. Add 4 new complicated examples compatible with ArduinoJson 6.0.0+ :[AutoConnect](examples/AutoConnect), [AutoConnectWithFeedback](examples/AutoConnectWithFeedback), [AutoConnectWithFeedbackLED](examples/AutoConnectWithFeedbackLED) and [AutoConnectWithFSParameters](examples/AutoConnectWithFSParameters)
2329

30+
---
31+
2432
This library is based on, modified, bug-fixed and improved from:
2533

2634
1. [`Tzapu WiFiManager`](https://github.com/tzapu/WiFiManager)
@@ -31,11 +39,12 @@ to add support to `ESP32` besides `ESP8266`.
3139
This is an `ESP32 / ESP8266` WiFi Connection manager with fallback web ConfigPortal.
3240
It's using a web ConfigPortal, served from the `ESP32 / ESP8266`, and operating as an access point.
3341

42+
---
43+
3444
## Prerequisite
3545
1. [`Arduino IDE 1.8.12 or later` for Arduino](https://www.arduino.cc/en/Main/Software)
36-
2. `Arduino AVR core 1.8.2 or later` for Arduino (Use Arduino Board Manager)
37-
3. [`ESP8266 Core 2.6.3 or newer`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
38-
4. [`ESP32 Core 1.0.4 or newer`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
46+
2. [`ESP8266 Core 2.7.1 or newer`](https://github.com/esp8266/Arduino) for ESP8266-based boards.
47+
3. [`ESP32 Core 1.0.4 or newer`](https://github.com/espressif/arduino-esp32) for ESP32-based boards
3948

4049
## How It Works
4150

@@ -48,7 +57,7 @@ It's using a web ConfigPortal, served from the `ESP32 / ESP8266`, and operating
4857
String ssid = "ESP_" + String(ESP_getChipId(), HEX);
4958
const char* password = "your_password";
5059
```
51-
then connect WebBrower to configurable ConfigPortal IP address, default is 192.168.4.1
60+
then connect WebBrowser to configurable ConfigPortal IP address, default is 192.168.4.1
5261

5362
- Choose one of the access points scanned, enter password, click ***Save***.
5463
- ESP will restart, then try to connect to the WiFi netwotk using STA-only mode, ***without running the ConfigPortal WebServer and WiFi AP***. See [Accessing manager after connection](https://github.com/khoih-prog/ESP_WiFiManager/issues/15).
@@ -70,6 +79,8 @@ The best and easiest way is to use `Arduino Library Manager`. Search for `ESP_Wi
7079
4. Copy whole
7180
- `ESP_WiFiManager-master/src` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
7281

82+
---
83+
7384
### Using
7485
- Include in your sketch
7586
```cpp
@@ -144,10 +155,13 @@ Also see examples:
144155
4. [ConfigOnDoubleReset](examples/ConfigOnDoubleReset) (now support ArduinoJson 6.0.0+ as well as 5.13.5-)
145156
5. [ConfigPortalParamsOnSwitch](examples/ConfigPortalParamsOnSwitch) (now support ArduinoJson 6.0.0+ as well as 5.13.5-)
146157
6. [ESP_FSWebServer](examples/ESP_FSWebServer)
147-
7. [AutoConnect](examples/AutoConnect)
148-
8. [AutoConnectWithFeedback](examples/AutoConnectWithFeedback)
149-
9. [AutoConnectWithFeedbackLED](examples/AutoConnectWithFeedbackLED)
150-
10. [AutoConnectWithFSParameters](examples/AutoConnectWithFSParameters)
158+
7. [ESP32_FSWebServer](examples/ESP32_FSWebServer)
159+
8. [AutoConnect](examples/AutoConnect)
160+
9. [AutoConnectWithFeedback](examples/AutoConnectWithFeedback)
161+
10. [AutoConnectWithFeedbackLED](examples/AutoConnectWithFeedbackLED)
162+
11. [AutoConnectWithFSParameters](examples/AutoConnectWithFSParameters)
163+
164+
---
151165

152166
## So, how it works?
153167
In `ConfigPortal Mode`, it starts an access point called `ESP_XXXXXX`. Connect to it using the `configurable password` you can define in the code. For example, `your_password` (see examples):
@@ -185,6 +199,8 @@ Enter your credentials, then click ***Save***. The WiFi Credentials will be save
185199

186200
If you're already connected to a listed WiFi AP and don't want to change anything, just select ***Exit Portal*** from the `Main` page to reboot the board and connect to the previously-stored AP. The WiFi Credentials are still intact.
187201

202+
---
203+
188204
## Documentation
189205

190206
#### Password protect the configuration Access Point
@@ -361,6 +377,14 @@ Sometimes, the library will only work if you update the `ESP32 / ESP8266` core t
361377

362378
If you connect to the created configuration Access Point but the ConfigPortal does not show up, just open a browser and type in the IP of the web portal, by default `192.168.4.1`.
363379

380+
---
381+
382+
### Releases 1.0.8
383+
384+
1. Fix setSTAStaticIPConfig issue. See [Static Station IP doesn't work](https://github.com/khoih-prog/ESP_WiFiManager/issues/17)
385+
2. Add LittleFS support for ESP8266 core 2.7.1+ in examples to replace deprecated SPIFFS.
386+
3. Restructure code.
387+
364388
### Releases 1.0.7
365389

366390
1. Use `just-in-time` scanWiFiNetworks() to reduce connection time necessary for battery-operated DeepSleep application. Thanks to [CrispinP](https://github.com/CrispinP) for identifying, requesting and testing. See [Starting WiFIManger is very slow (2000ms)](https://github.com/khoih-prog/ESP_WiFiManager/issues/6)
@@ -419,11 +443,15 @@ See [KenTaylor's version](https://github.com/kentaylor/WiFiManager) for previous
419443
- Fix bug that keeps ConfigPortal in endless loop if Portal/Router SSID or Password is NULL.
420444
- Add example ConfigPortalParamsOnSwitch to enable ConfigPortal credentials to be reconfigurable using ConfigPortal.
421445

446+
---
447+
422448
### Contributions and thanks
449+
423450
1. Based on and modified from [Tzapu](https://github.com/tzapu/WiFiManager) and [KenTaylor's version]( https://github.com/kentaylor/WiFiManager)
424451
2. Thanks to [Amorphous](https://community.blynk.cc/t/esp-wifimanager-for-esp32-and-esp8266/42257/13) for the static DNS feature and code, included in v1.0.5
425452
3. Thanks to [CrispinP](https://github.com/CrispinP) for idea to add HostName (v1.0.4) and request to reduce the unnecessary waiting time in ESP_WiFiManager constructor (v1.0.6+). See [Starting WiFIManger is very slow (2000ms)](https://github.com/khoih-prog/ESP_WiFiManager/issues/6)
426453
4. Thanks to [OttoKlaasen](https://github.com/OttoKlaasen) for reporting [Having issue to read the SPIFF file](https://github.com/khoih-prog/ESP_WiFiManager/issues/14) bug in examples.
454+
5. Thanks to [Giuseppe](https://github.com/Gius-8) for reporting [Static Station IP doesn't work](https://github.com/khoih-prog/ESP_WiFiManager/issues/17) bug.
427455

428456
### Contributing
429457

examples/AutoConnect/AutoConnect.ino

+14-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
ESP_WiFiManager is a library for the ESP8266/ESP32 platform (https://github.com/esp8266/Arduino) to enable easy
66
configuration and reconfiguration of WiFi credentials using a Captive Portal.
77
8-
Forked from Tzapu https://github.com/tzapu/WiFiManager
8+
Modified from Tzapu https://github.com/tzapu/WiFiManager
99
and from Ken Taylor https://github.com/kentaylor
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
1212
Licensed under MIT license
13-
Version: 1.0.7
13+
Version: 1.0.8
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,8 +21,12 @@
2121
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
2222
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
2323
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
24-
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
24+
1.0.7 K Hoang 14/04/2020 Use just-in-time scanWiFiNetworks(). Fix bug relating SPIFFS in examples
25+
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
2526
*****************************************************************************************************************************/
27+
#if !( defined(ESP8266) || defined(ESP32) )
28+
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
29+
#endif
2630

2731
//Ported to ESP32
2832
#ifdef ESP32
@@ -52,6 +56,12 @@
5256
String Router_SSID;
5357
String Router_Pass;
5458

59+
IPAddress stationIP = IPAddress(192, 168, 2, 114);
60+
IPAddress gatewayIP = IPAddress(192, 168, 2, 1);
61+
IPAddress netMask = IPAddress(255, 255, 255, 0);
62+
IPAddress dns1IP = gatewayIP;
63+
IPAddress dns2IP = IPAddress(8, 8, 8, 8);
64+
5565
void heartBeatPrint(void)
5666
{
5767
static int num = 1;
@@ -103,8 +113,7 @@ void setup()
103113

104114
ESP_wifiManager.setMinimumSignalQuality(-1);
105115
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5+
106-
ESP_wifiManager.setSTAStaticIPConfig(IPAddress(192, 168, 2, 114), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0),
107-
IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8));
116+
ESP_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
108117

109118
// We can't use WiFi.SSID() in ESP32 as it's only valid after connected.
110119
// SSID and Password stored in ESP32 wifi_ap_record_t and wifi_config_t are also cleared in reboot

examples/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino

+57-36
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
ESP_WiFiManager is a library for the ESP8266/ESP32 platform (https://github.com/esp8266/Arduino) to enable easy
66
configuration and reconfiguration of WiFi credentials using a Captive Portal.
77
8-
Forked from Tzapu https://github.com/tzapu/WiFiManager
8+
Modified from Tzapu https://github.com/tzapu/WiFiManager
99
and from Ken Taylor https://github.com/kentaylor
1010
1111
Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager
1212
Licensed under MIT license
13-
Version: 1.0.7
13+
Version: 1.0.8
1414
1515
Version Modified By Date Comments
1616
------- ----------- ---------- -----------
@@ -21,35 +21,51 @@
2121
1.0.4 K Hoang 07/01/2020 Add RFC952 setHostname feature.
2222
1.0.5 K Hoang 15/01/2020 Add configurable DNS feature. Thanks to @Amorphous of https://community.blynk.cc
2323
1.0.6 K Hoang 03/02/2020 Add support for ArduinoJson version 6.0.0+ ( tested with v6.14.1 )
24-
1.0.7 K Hoang 13/04/2020 Reduce start time, fix SPIFFS bug in examples, update README.md
24+
1.0.7 K Hoang 14/04/2020 Use just-in-time scanWiFiNetworks(). Fix bug relating SPIFFS in examples
25+
1.0.8 K Hoang 10/06/2020 Fix STAstaticIP issue. Restructure code. Add LittleFS support for ESP8266 core 2.7.1+
2526
*****************************************************************************************************************************/
27+
#if !( defined(ESP8266) || defined(ESP32) )
28+
#error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting.
29+
#endif
2630

31+
#include <FS.h>
32+
2733
//Ported to ESP32
2834
#ifdef ESP32
29-
#include <FS.h>
30-
#include "SPIFFS.h"
31-
#include <esp_wifi.h>
32-
#include <WiFi.h>
33-
#include <WiFiClient.h>
34-
35-
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
36-
37-
#define LED_BUILTIN 2
38-
#define LED_ON HIGH
39-
#define LED_OFF LOW
35+
#include "SPIFFS.h"
36+
#include <esp_wifi.h>
37+
#include <WiFi.h>
38+
#include <WiFiClient.h>
39+
40+
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
41+
42+
#define LED_BUILTIN 2
43+
#define LED_ON HIGH
44+
#define LED_OFF LOW
45+
46+
#define FileFS SPIFFS
4047

4148
#else
42-
#include <FS.h> //this needs to be first, or it all crashes and burns...
43-
44-
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
45-
//needed for library
46-
#include <DNSServer.h>
47-
#include <ESP8266WebServer.h>
4849

49-
#define ESP_getChipId() (ESP.getChipId())
50-
51-
#define LED_ON LOW
52-
#define LED_OFF HIGH
50+
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
51+
//needed for library
52+
#include <DNSServer.h>
53+
#include <ESP8266WebServer.h>
54+
55+
#define ESP_getChipId() (ESP.getChipId())
56+
57+
#define LED_ON LOW
58+
#define LED_OFF HIGH
59+
60+
#define USE_LITTLEFS true
61+
62+
#if USE_LITTLEFS
63+
#define FileFS LittleFS
64+
#else
65+
#define FileFS SPIFFS
66+
#endif
67+
68+
#include <LittleFS.h>
5369
#endif
5470

5571
// Pin D2 mapped to pin GPIO2/ADC12 of ESP32, or GPIO2/TXD1 of NodeMCU control on-board LED
@@ -70,6 +86,12 @@ String Router_Pass;
7086
String AP_SSID;
7187
String AP_PASS;
7288

89+
IPAddress stationIP = IPAddress(192, 168, 2, 114);
90+
IPAddress gatewayIP = IPAddress(192, 168, 2, 1);
91+
IPAddress netMask = IPAddress(255, 255, 255, 0);
92+
IPAddress dns1IP = gatewayIP;
93+
IPAddress dns2IP = IPAddress(8, 8, 8, 8);
94+
7395
//define your default values here, if there are different values in configFileName (config.json), they are overwritten.
7496
#define BLYNK_SERVER_LEN 64
7597
#define BLYNK_TOKEN_LEN 32
@@ -95,23 +117,23 @@ void saveConfigCallback(void)
95117
shouldSaveConfig = true;
96118
}
97119

98-
bool loadSPIFFSConfigFile(void)
120+
bool loadFileFSConfigFile(void)
99121
{
100122
//clean FS, for testing
101-
//SPIFFS.format();
123+
//FileFS.format();
102124

103125
//read configuration from FS json
104126
Serial.println("Mounting FS...");
105127

106-
if (SPIFFS.begin())
128+
if (FileFS.begin())
107129
{
108130
Serial.println("Mounted file system");
109131

110-
if (SPIFFS.exists(configFileName))
132+
if (FileFS.exists(configFileName))
111133
{
112134
//file exists, reading and loading
113135
Serial.println("Reading config file");
114-
File configFile = SPIFFS.open(configFileName, "r");
136+
File configFile = FileFS.open(configFileName, "r");
115137

116138
if (configFile)
117139
{
@@ -203,7 +225,7 @@ bool loadSPIFFSConfigFile(void)
203225
return true;
204226
}
205227

206-
bool saveSPIFFSConfigFile(void)
228+
bool saveFileFSConfigFile(void)
207229
{
208230
Serial.println("Saving config");
209231

@@ -221,7 +243,7 @@ bool saveSPIFFSConfigFile(void)
221243
json["mqtt_server"] = mqtt_server;
222244
json["mqtt_port"] = mqtt_port;
223245

224-
File configFile = SPIFFS.open(configFileName, "w");
246+
File configFile = FileFS.open(configFileName, "w");
225247

226248
if (!configFile)
227249
{
@@ -302,7 +324,7 @@ void setup()
302324
Serial.begin(115200);
303325
Serial.println("\nStarting AutoConnectWithFSParams");
304326

305-
loadSPIFFSConfigFile();
327+
loadFileFSConfigFile();
306328

307329
// The extra parameters to be configured (can be either global or just in the setup)
308330
// After connecting, parameter.getValue() will get you the configured value
@@ -344,12 +366,11 @@ void setup()
344366

345367
ESP_wifiManager.setMinimumSignalQuality(-1);
346368
// Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5+
347-
ESP_wifiManager.setSTAStaticIPConfig(IPAddress(192, 168, 2, 114), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0),
348-
IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8));
369+
ESP_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask, dns1IP, dns2IP);
349370

350371
// We can't use WiFi.SSID() in ESP32 as it's only valid after connected.
351372
// SSID and Password stored in ESP32 wifi_ap_record_t and wifi_config_t are also cleared in reboot
352-
// Have to create a new function to store in EEPROM/SPIFFS for this purpose
373+
// Have to create a new function to store in EEPROM/SPIFFS/LittleFS for this purpose
353374
Router_SSID = ESP_wifiManager.WiFi_SSID();
354375
Router_Pass = ESP_wifiManager.WiFi_Pass();
355376

@@ -403,7 +424,7 @@ void setup()
403424
//save the custom parameters to FS
404425
if (shouldSaveConfig)
405426
{
406-
saveSPIFFSConfigFile();
427+
saveFileFSConfigFile();
407428
}
408429

409430
Serial.println("local ip");

0 commit comments

Comments
 (0)