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

Commit c895470

Browse files
authored
v1.7.0 to fix the blocking issue in loop()
### Major Release v1.7.0 1. Fix ESP8266 bug not easy to connect to Config Portal for ESP8266 core v3.0.0+ 2. Fix the blocking issue in loop(). Check [retries block the main loop #18](khoih-prog/WiFiManager_NINA_Lite#18) 3. Configurable `WIFI_RECON_INTERVAL`. Check [retries block the main loop #18](khoih-prog/WiFiManager_NINA_Lite#18 (comment)) 4. Optimize library code by using `reference-passing` instead of `value-passing` 5. Clean up
1 parent c6b49bb commit c895470

File tree

9 files changed

+286
-114
lines changed

9 files changed

+286
-114
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.16) or Platform.io version
18-
* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.1)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.2)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.16
29+
Arduino IDE version: 1.8.19
3030
ESP8266 Core Version 3.0.2
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux xy-Inspiron-3593 5.4.0-92-generic #103-Ubuntu SMP Fri Nov 26 16:13:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
The board couldn't autoreconnect to Local Blynk Server after router power recycling.

README.md

Lines changed: 80 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
* [12.1 Enable auto-scan of WiFi networks for selection in Configuration Portal](#121-enable-auto-scan-of-wifi-networks-for-selection-in-configuration-portal)
4646
* [12.2 Disable manually input SSIDs](#122-disable-manually-input-ssids)
4747
* [12.3 Select maximum number of SSIDs in the list](#123-select-maximum-number-of-ssids-in-the-list)
48+
* [13. To avoid blocking in loop when WiFi is lost](#13-To-avoid-blocking-in-loop-when-wifi-is-lost)
49+
* [13.1 Max times to try WiFi per loop](#131-max-times-to-try-wifi-per-loop)
50+
* [13.2 Interval between reconnection WiFi if lost](#132-interval-between-reconnection-wifi-if-lost)
4851
* [Examples](#examples)
4952
* [ 1. ESPAsync_WiFi](examples/ESPAsync_WiFi)
5053
* [ 2. ESPAsync_WiFi_MQTT](examples/ESPAsync_WiFi_MQTT)
@@ -161,9 +164,9 @@ This [**ESPAsync_WiFiManager_Lite** library](https://github.com/khoih-prog/ESPAs
161164

162165
## Prerequisites
163166

164-
1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
167+
1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
165168
2. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). To use ESP8266 core 2.7.1+ for LittleFS.
166-
3. [`ESP32 Core 2.0.1+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/)
169+
3. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/)
167170
4. [`ESPAsyncWebServer v1.2.3+`](https://github.com/me-no-dev/ESPAsyncWebServer) for all ESP32/ESP8266-based boards.
168171
5. [`ESPAsyncTCP v1.2.2+`](https://github.com/me-no-dev/ESPAsyncTCP) for ESP8266-based boards.
169172
6. [`AsyncTCP v1.1.1+`](https://github.com/me-no-dev/AsyncTCP) for ESP32-based boards
@@ -494,6 +497,35 @@ The maximum number of SSIDs in the list is seletable from 2 to 15. If invalid nu
494497
#define MAX_SSID_IN_LIST 8
495498
```
496499
500+
#### 13. To avoid blocking in loop when WiFi is lost
501+
502+
#### 13.1 Max times to try WiFi per loop
503+
504+
To define max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
505+
506+
Default is 1 if not defined, and minimum is forced to be 1.
507+
508+
To use, uncomment in `defines.h`.
509+
510+
Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issue-1094004380)
511+
512+
```
513+
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2
514+
```
515+
516+
#### 13.2 Interval between reconnection WiFi if lost
517+
518+
Default is no interval between reconnection WiFi times if lost WiFi. Max permitted interval will be 10mins.
519+
520+
Uncomment to use. Be careful, WiFi reconnection will be delayed if using this method.
521+
522+
Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks.
523+
524+
Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561)
525+
526+
```
527+
#define WIFI_RECON_INTERVAL 30000 // 30s
528+
```
497529
498530
---
499531
---
@@ -938,7 +970,10 @@ void loop()
938970

939971
// RTC Memory Address for the DoubleResetDetector to use
940972
#define MRD_ADDRESS 0
941-
#warning Using MULTI_RESETDETECTOR
973+
974+
#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
975+
#warning Using MULTI_RESETDETECTOR
976+
#endif
942977
#else
943978
#define DOUBLERESETDETECTOR_DEBUG true
944979

@@ -948,7 +983,10 @@ void loop()
948983

949984
// RTC Memory Address for the DoubleResetDetector to use
950985
#define DRD_ADDRESS 0
951-
#warning Using DOUBLE_RESETDETECTOR
986+
987+
#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
988+
#warning Using DOUBLE_RESETDETECTOR
989+
#endif
952990
#endif
953991

954992
/////////////////////////////////////////////
@@ -972,10 +1010,6 @@ void loop()
9721010

9731011
/////////////////////////////////////////////
9741012

975-
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
976-
// Default is false (if not defined) => must input 2 sets of SSID/PWD
977-
#define REQUIRE_ONE_SET_SSID_PW false
978-
9791013
// Force some params
9801014
#define TIMEOUT_RECONNECT_WIFI 10000L
9811015

@@ -988,9 +1022,32 @@ void loop()
9881022
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5
9891023

9901024
// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
991-
#define CONFIG_TIMEOUT 120000L
1025+
#define CONFIG_TIMEOUT 120000L
1026+
1027+
/////////////////////////////////////////////
1028+
1029+
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
1030+
// Default is false (if not defined) => must input 2 sets of SSID/PWD
1031+
#define REQUIRE_ONE_SET_SSID_PW true //false
1032+
1033+
// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
1034+
// Default 1 if not defined, and minimum 1.
1035+
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2
1036+
1037+
// Default no interval between recon WiFi if lost
1038+
// Max permitted interval will be 10mins
1039+
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
1040+
// Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks.
1041+
#define WIFI_RECON_INTERVAL 30000
1042+
1043+
/////////////////////////////////////////////
1044+
1045+
// Permit reset hardware if no WiFi to permit user another chance to access Config Portal.
1046+
#define RESET_IF_NO_WIFI false
1047+
1048+
/////////////////////////////////////////////
9921049

993-
#define USE_DYNAMIC_PARAMETERS true
1050+
#define USE_DYNAMIC_PARAMETERS true
9941051

9951052
/////////////////////////////////////////////
9961053

@@ -1196,7 +1253,7 @@ This is the terminal output when running [**ESPAsync_WiFi_MQTT**](examples/ESPAs
11961253

11971254
```
11981255
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32_DEV
1199-
ESPAsync_WiFiManager_Lite v1.6.0
1256+
ESPAsync_WiFiManager_Lite v1.7.0
12001257
ESP_MultiResetDetector v1.2.1
12011258
LittleFS Flag read = 0xFFFE0001
12021259
multiResetDetectorFlag = 0xFFFE0001
@@ -1271,7 +1328,7 @@ NNN
12711328
12721329
12731330
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32_DEV
1274-
ESPAsync_WiFiManager_Lite v1.6.0
1331+
ESPAsync_WiFiManager_Lite v1.7.0
12751332
ESP_MultiResetDetector v1.2.1
12761333
LittleFS Flag read = 0xFFFE0001
12771334
multiResetDetectorFlag = 0xFFFE0001
@@ -1363,7 +1420,7 @@ This is the terminal output when running [**ESPAsync_WiFi_MQTT**](examples/ESPAs
13631420

13641421
```
13651422
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP8266_NODEMCU
1366-
ESPAsync_WiFiManager_Lite v1.6.0
1423+
ESPAsync_WiFiManager_Lite v1.7.0
13671424
ESP_MultiResetDetector v1.2.1
13681425
LittleFS Flag read = 0xFFFE0001
13691426
multiResetDetectorFlag = 0xFFFE0001
@@ -1438,7 +1495,7 @@ NNN
14381495
14391496
14401497
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP8266_NODEMCU
1441-
ESPAsync_WiFiManager_Lite v1.6.0
1498+
ESPAsync_WiFiManager_Lite v1.7.0
14421499
ESP_MultiResetDetector v1.2.1
14431500
LittleFS Flag read = 0xFFFE0001
14441501
multiResetDetectorFlag = 0xFFFE0001
@@ -1529,7 +1586,7 @@ This is the terminal output when running [**ESPAsync_WiFi_MQTT**](examples/ESPAs
15291586

15301587
```
15311588
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32S2_DEV
1532-
ESPAsync_WiFiManager_Lite v1.6.0
1589+
ESPAsync_WiFiManager_Lite v1.7.0
15331590
ESP_MultiResetDetector v1.2.1
15341591
LittleFS Flag read = 0xFFFE0001
15351592
multiResetDetectorFlag = 0xFFFE0001
@@ -1642,7 +1699,7 @@ entry 0x4004c190
16421699
16431700
16441701
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32S2_DEV
1645-
ESPAsync_WiFiManager_Lite v1.6.0
1702+
ESPAsync_WiFiManager_Lite v1.7.0
16461703
ESP_MultiResetDetector v1.2.1
16471704
LittleFS Flag read = 0xFFFE0001
16481705
multiResetDetectorFlag = 0xFFFE0001
@@ -1745,7 +1802,7 @@ This is the terminal output when running [**ESPAsync_WiFi_MQTT**](examples/ESPAs
17451802

17461803
```
17471804
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32S2_DEV
1748-
ESPAsync_WiFiManager_Lite v1.6.0
1805+
ESPAsync_WiFiManager_Lite v1.7.0
17491806
ESP_MultiResetDetector v1.2.1
17501807
LittleFS Flag read = 0xFFFC0003
17511808
multiResetDetectorFlag = 0xFFFC0003
@@ -1788,7 +1845,7 @@ entry 0x4004c190
17881845

17891846
```
17901847
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32S2_DEV
1791-
ESPAsync_WiFiManager_Lite v1.6.0
1848+
ESPAsync_WiFiManager_Lite v1.7.0
17921849
ESP_MultiResetDetector v1.2.1
17931850
LittleFS Flag read = 0xFFFE0001
17941851
multiResetDetectorFlag = 0xFFFE0001
@@ -1844,7 +1901,7 @@ This is the terminal output when running [**ESPAsync_WiFi_MQTT**](examples/ESPAs
18441901

18451902
```
18461903
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32_DEV
1847-
ESPAsync_WiFiManager_Lite v1.6.0
1904+
ESPAsync_WiFiManager_Lite v1.7.0
18481905
ESP_MultiResetDetector v1.2.1
18491906
LittleFS Flag read = 0xFFFC0003
18501907
multiResetDetectorFlag = 0xFFFC0003
@@ -1889,7 +1946,7 @@ NNNN NNNNN NNNNN N
18891946

18901947
```
18911948
Starting ESPAsync_WiFi_MQTT using LittleFS on ESP32_DEV
1892-
ESPAsync_WiFiManager_Lite v1.6.0
1949+
ESPAsync_WiFiManager_Lite v1.7.0
18931950
ESP_MultiResetDetector v1.2.1
18941951
LittleFS Flag read = 0xFFFE0001
18951952
multiResetDetectorFlag = 0xFFFE0001
@@ -2000,6 +2057,9 @@ Submit issues to: [ESPAsync_WiFiManager_Lite issues](https://github.com/khoih-pr
20002057
20. Add support to **ESP32-C3 using EEPROM and SPIFFS**
20012058
21. Enable **scan of WiFi networks** for selection in Configuration Portal
20022059
22. Ready for ESP32 core v2.0.0+
2060+
23. Fix ESP8266 bug not easy to connect to Config Portal for ESP8266 core v3.0.0+
2061+
24. Fix the blocking issue in loop() with configurable `WIFI_RECON_INTERVAL`
2062+
25. Optimize library code by using `reference-passing` instead of `value-passing`
20032063

20042064
---
20052065
---

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Major Release v1.7.0](#major-release-v170)
1516
* [Release v1.6.0](#release-v160)
1617
* [Release v1.5.1](#release-v151)
1718
* [Major Release v1.5.0](#major-release-v150)
@@ -27,6 +28,14 @@
2728

2829
## Changelog
2930

31+
### Major Release v1.7.0
32+
33+
1. Fix ESP8266 bug not easy to connect to Config Portal for ESP8266 core v3.0.0+
34+
2. Fix the blocking issue in loop(). Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18)
35+
3. Configurable `WIFI_RECON_INTERVAL`. Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561)
36+
4. Optimize library code by using `reference-passing` instead of `value-passing`
37+
5. Clean up
38+
3039
### Release v1.6.0
3140

3241
1. Auto detect ESP32 core and use either built-in LittleFS or [LITTLEFS](https://github.com/lorol/LITTLEFS) library.

examples/ESPAsync_WiFi/defines.h

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333

3434
// RTC Memory Address for the DoubleResetDetector to use
3535
#define MRD_ADDRESS 0
36-
#warning Using MULTI_RESETDETECTOR
36+
37+
#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
38+
#warning Using MULTI_RESETDETECTOR
39+
#endif
3740
#else
3841
#define DOUBLERESETDETECTOR_DEBUG true
3942

@@ -43,7 +46,10 @@
4346

4447
// RTC Memory Address for the DoubleResetDetector to use
4548
#define DRD_ADDRESS 0
46-
#warning Using DOUBLE_RESETDETECTOR
49+
50+
#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
51+
#warning Using DOUBLE_RESETDETECTOR
52+
#endif
4753
#endif
4854

4955
/////////////////////////////////////////////
@@ -67,10 +73,6 @@
6773

6874
/////////////////////////////////////////////
6975

70-
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
71-
// Default is false (if not defined) => must input 2 sets of SSID/PWD
72-
#define REQUIRE_ONE_SET_SSID_PW false
73-
7476
// Force some params
7577
#define TIMEOUT_RECONNECT_WIFI 10000L
7678

@@ -83,9 +85,32 @@
8385
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5
8486

8587
// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
86-
#define CONFIG_TIMEOUT 120000L
88+
#define CONFIG_TIMEOUT 120000L
89+
90+
/////////////////////////////////////////////
91+
92+
// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
93+
// Default is false (if not defined) => must input 2 sets of SSID/PWD
94+
#define REQUIRE_ONE_SET_SSID_PW true //false
95+
96+
// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
97+
// Default 1 if not defined, and minimum 1.
98+
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2
99+
100+
// Default no interval between recon WiFi if lost
101+
// Max permitted interval will be 10mins
102+
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
103+
// Only use whenever urgent tasks in loop() can't be delayed. But if so, it's better you have to rewrite your code, e.g. using higher priority tasks.
104+
#define WIFI_RECON_INTERVAL 30000
105+
106+
/////////////////////////////////////////////
107+
108+
// Permit reset hardware if no WiFi to permit user another chance to access Config Portal.
109+
#define RESET_IF_NO_WIFI false
110+
111+
/////////////////////////////////////////////
87112

88-
#define USE_DYNAMIC_PARAMETERS true
113+
#define USE_DYNAMIC_PARAMETERS true
89114

90115
/////////////////////////////////////////////
91116

0 commit comments

Comments
 (0)