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

Commit

Permalink
v1.7.0 to fix the blocking issue in loop()
Browse files Browse the repository at this point in the history
### 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. Clean up
  • Loading branch information
khoih-prog committed Jan 8, 2022
1 parent 0a4c722 commit d64ce2d
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 61 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p

Please ensure to specify the following:

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

```
Arduino IDE version: 1.8.16
Arduino IDE version: 1.8.19
ESP8266 Core Version 3.0.2
OS: Ubuntu 20.04 LTS
Linux Inspiron 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Linux Inspiron 5.4.0-92-generic #103-Ubuntu SMP Fri Nov 26 16:13:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Context:
The board couldn't autoreconnect to Local Blynk Server after router power recycling.
Expand Down
101 changes: 80 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
* [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)
* [12.2 Disable manually input SSIDs](#122-disable-manually-input-ssids)
* [12.3 Select maximum number of SSIDs in the list](#123-select-maximum-number-of-ssids-in-the-list)
* [13. To avoid blocking in loop when WiFi is lost](#13-To-avoid-blocking-in-loop-when-wifi-is-lost)
* [13.1 Max times to try WiFi per loop](#131-max-times-to-try-wifi-per-loop)
* [13.2 Interval between reconnection WiFi if lost](#132-interval-between-reconnection-wifi-if-lost)
* [Examples](#examples)
* [ 1. ESP_WiFi](examples/ESP_WiFi)
* [ 2. ESP_WiFi_MQTT](examples/ESP_WiFi_MQTT)
Expand Down Expand Up @@ -138,8 +141,8 @@ This [**ESP_WiFiManager_Lite** library](https://github.com/khoih-prog/ESP_WiFiMa

## Prerequisites

1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
2. [`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/)
1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
2. [`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/)
3. [`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/). SPIFFS is deprecated from ESP8266 core 2.7.1+, to use LittleFS.
4. [`ESP_DoubleResetDetector v1.2.1+`](https://github.com/khoih-prog/ESP_DoubleResetDetector) if using DRD feature. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector).
5. [`ESP_MultiResetDetector v1.2.1+`](https://github.com/khoih-prog/ESP_MultiResetDetector) if using MRD feature. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_MultiResetDetector.svg?)](https://www.ardu-badge.com/ESP_MultiResetDetector).
Expand Down Expand Up @@ -470,6 +473,35 @@ The maximum number of SSIDs in the list is seletable from 2 to 15. If invalid nu
#define MAX_SSID_IN_LIST 8
```
#### 13. To avoid blocking in loop when WiFi is lost
#### 13.1 Max times to try WiFi per loop
To define max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
Default is 1 if not defined, and minimum is forced to be 1.
To use, uncomment in `defines.h`.
Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issue-1094004380)
```
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2
```
#### 13.2 Interval between reconnection WiFi if lost
Default is no interval between reconnection WiFi times if lost WiFi. Max permitted interval will be 10mins.
Uncomment to use. Be careful, WiFi reconnection will be delayed if using this method.
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.
Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561)
```
#define WIFI_RECON_INTERVAL 30000 // 30s
```
---
---
Expand Down Expand Up @@ -913,7 +945,10 @@ void loop()

// RTC Memory Address for the DoubleResetDetector to use
#define MRD_ADDRESS 0
#warning Using MULTI_RESETDETECTOR

#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
#warning Using MULTI_RESETDETECTOR
#endif
#else
#define DOUBLERESETDETECTOR_DEBUG true

Expand All @@ -923,7 +958,10 @@ void loop()

// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0
#warning Using DOUBLE_RESETDETECTOR

#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
#warning Using DOUBLE_RESETDETECTOR
#endif
#endif

/////////////////////////////////////////////
Expand All @@ -947,10 +985,6 @@ void loop()

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW false

// Force some params
#define TIMEOUT_RECONNECT_WIFI 10000L

Expand All @@ -963,9 +997,32 @@ void loop()
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5

// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
#define CONFIG_TIMEOUT 120000L
#define CONFIG_TIMEOUT 120000L

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true //false

// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 if not defined, and minimum 1.
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2

// Default no interval between recon WiFi if lost
// Max permitted interval will be 10mins
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
// 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.
//#define WIFI_RECON_INTERVAL 30000

/////////////////////////////////////////////

// Permit reset hardware if no WiFi to permit user another chance to access Config Portal.
#define RESET_IF_NO_WIFI false

/////////////////////////////////////////////

#define USE_DYNAMIC_PARAMETERS true
#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////

Expand All @@ -975,7 +1032,7 @@ void loop()
#define MANUAL_SSID_INPUT_ALLOWED true

// From 2-15
#define MAX_SSID_IN_LIST 8
#define MAX_SSID_IN_LIST 8

/////////////////////////////////////////////

Expand Down Expand Up @@ -1171,7 +1228,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp

```
Starting ESP_WiFi using LittleFS on ESP32_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFC0003
multiResetDetectorFlag = 0xFFFC0003
Expand Down Expand Up @@ -1242,7 +1299,7 @@ FFFFFFFFF

```
Starting ESP_WiFi using LittleFS on ESP32_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1314,7 +1371,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M

```
Starting ESP_WiFi_MQTT using LittleFS on ESP8266_NODEMCU
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1389,7 +1446,7 @@ NNN
Starting ESP_WiFi_MQTT using LittleFS on ESP8266_NODEMCU
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1481,7 +1538,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M

```
Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1594,7 +1651,7 @@ entry 0x4004c190
Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1696,7 +1753,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M

```
Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFC0003
multiResetDetectorFlag = 0xFFFC0003
Expand Down Expand Up @@ -1724,7 +1781,7 @@ NNNN NNNNN NNNNN NNNNN NN[WML] h:UpdLittleFS

```
Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1780,7 +1837,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp

```
Starting ESP_WiFi_MQTT using LittleFS on ESP32_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFC0003
multiResetDetectorFlag = 0xFFFC0003
Expand Down Expand Up @@ -1824,7 +1881,7 @@ N

```
Starting ESP_WiFi_MQTT using LittleFS on ESP32_DEV
ESP_WiFiManager_Lite v1.6.0
ESP_WiFiManager_Lite v1.7.0
ESP_MultiResetDetector v1.2.1
LittleFS Flag read = 0xFFFE0001
multiResetDetectorFlag = 0xFFFE0001
Expand Down Expand Up @@ -1935,6 +1992,8 @@ Submit issues to: [ESP_WiFiManager_Lite issues](https://github.com/khoih-prog/ES
23. Add support to **ESP32-C3 using EEPROM and SPIFFS**
24. Enable **scan of WiFi networks** for selection in Configuration Portal
25. Ready for ESP32 core v2.0.0+
26. Fix ESP8266 bug not easy to connect to Config Portal for ESP8266 core v3.0.0+
27. Fix the blocking issue in loop() with configurable `WIFI_RECON_INTERVAL`

---
---
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.7.0](#release-v170)
* [Release v1.6.0](#release-v160)
* [Release v1.5.1](#release-v151)
* [Major Release v1.5.0](#major-release-v150)
Expand All @@ -26,6 +27,13 @@

## Changelog

### 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](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18)
3. Configurable `WIFI_RECON_INTERVAL`. Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18#issuecomment-1006197561)
4. Clean up

### Release v1.6.0

1. Auto detect ESP32 core and use either built-in LittleFS or [LITTLEFS](https://github.com/lorol/LITTLEFS) library.
Expand Down
41 changes: 33 additions & 8 deletions examples/ESP_WiFi/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

// RTC Memory Address for the DoubleResetDetector to use
#define MRD_ADDRESS 0
#warning Using MULTI_RESETDETECTOR

#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
#warning Using MULTI_RESETDETECTOR
#endif
#else
#define DOUBLERESETDETECTOR_DEBUG true

Expand All @@ -43,7 +46,10 @@

// RTC Memory Address for the DoubleResetDetector to use
#define DRD_ADDRESS 0
#warning Using DOUBLE_RESETDETECTOR

#if (_ESP_WM_LITE_LOGLEVEL_ > 3)
#warning Using DOUBLE_RESETDETECTOR
#endif
#endif

/////////////////////////////////////////////
Expand All @@ -67,10 +73,6 @@

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW false

// Force some params
#define TIMEOUT_RECONNECT_WIFI 10000L

Expand All @@ -83,9 +85,32 @@
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5

// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
#define CONFIG_TIMEOUT 120000L
#define CONFIG_TIMEOUT 120000L

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true //false

// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 if not defined, and minimum 1.
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2

// Default no interval between recon WiFi if lost
// Max permitted interval will be 10mins
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
// 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.
//#define WIFI_RECON_INTERVAL 30000

/////////////////////////////////////////////

// Permit reset hardware if no WiFi to permit user another chance to access Config Portal.
#define RESET_IF_NO_WIFI false

/////////////////////////////////////////////

#define USE_DYNAMIC_PARAMETERS true
#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////

Expand Down
31 changes: 25 additions & 6 deletions examples/ESP_WiFi_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW false

// Force some params
#define TIMEOUT_RECONNECT_WIFI 10000L

Expand All @@ -83,9 +79,32 @@
#define CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET 5

// Config Timeout 120s (default 60s). Applicable only if Config Data is Valid
#define CONFIG_TIMEOUT 120000L
#define CONFIG_TIMEOUT 120000L

/////////////////////////////////////////////

// Permit input only one set of WiFi SSID/PWD. The other can be "NULL or "blank"
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true //false

// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 if not defined, and minimum 1.
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 2

// Default no interval between recon WiFi if lost
// Max permitted interval will be 10mins
// Uncomment to use. Be careful, WiFi reconnect will be delayed if using this method
// 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.
//#define WIFI_RECON_INTERVAL 30000

/////////////////////////////////////////////

// Permit reset hardware if no WiFi to permit user another chance to access Config Portal.
#define RESET_IF_NO_WIFI false

/////////////////////////////////////////////

#define USE_DYNAMIC_PARAMETERS true
#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////

Expand Down
Loading

0 comments on commit d64ce2d

Please sign in to comment.