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

Commit

Permalink
v1.5.0 to fix the blocking issue in loop()
Browse files Browse the repository at this point in the history
### Release v1.5.0

1. Fix the blocking issue in loop(). Check [retries block the main loop #18](#18)
2. Drop support to `AVR Mega`
3. Update `Packages' Patches`
  • Loading branch information
khoih-prog committed Jan 5, 2022
1 parent 33e8c73 commit 7a37010
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 99 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP8266 core v3.0.2, ArduinoCore-mbed v2.5.2, etc.)
* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP8266 core v3.0.2, ArduinoCore-mbed v2.6.1, etc.)
* 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,11 +26,11 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.16
Arduino IDE version: 1.8.19
Nano_RP2040_Connect board
ArduinoCore-mbed v2.5.2
ArduinoCore-mbed v2.6.1
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 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
121 changes: 63 additions & 58 deletions README.md

Large diffs are not rendered by default.

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.5.0](#release-v150)
* [Release v1.4.1](#release-v141)
* [Major Release v1.4.0](#major-release-v140)
* [Release v1.3.1](#release-v131)
Expand All @@ -34,6 +35,13 @@

## Changelog

### Release v1.5.0

1. Fix the blocking issue in loop(). Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/18)
2. Drop support to `AVR Mega`
3. Update `Packages' Patches`


### Release v1.4.1

1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix
Expand Down
6 changes: 6 additions & 0 deletions examples/RP2040_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/RP2040_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/SAMD_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW true

// 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/SAMD_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/SAM_DUE_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/SAM_DUE_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/STM32_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/STM32_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 5 additions & 1 deletion examples/Teensy_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW false

#define USE_DYNAMIC_PARAMETERS true
// 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

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

#define USE_DYNAMIC_PARAMETERS true

Expand Down
6 changes: 6 additions & 0 deletions examples/Teensy_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/nRF52_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions examples/nRF52_WiFiNINA_MQTT/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@
// Default is false (if not defined) => must input 2 sets of SSID/PWD
#define REQUIRE_ONE_SET_SSID_PW 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

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

#define USE_DYNAMIC_PARAMETERS true

/////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "WiFiManager_NINA_Lite",
"version": "1.4.1",
"version": "1.5.0",
"keywords": "wifi, wi-fi, MutiWiFi, WiFiNINA, SAM DUE, SAMD, nRF52, STM32, rpi-pico, rp2040, nano-rp2040-connect, Credentials, config-portal, dynamic-params, FlashStorage-SAMD, FlashStorage-STM32, DueFlashStorage, LittleFS, Double-Reset, FlashStorage, light-weight, EEPROM, AVR Mega",
"description": "Library to configure MultiWiFi/Credentials at runtime for AVR Mega, Teensy, SAM DUE, SAMD21, SAMD51, STM32F/L/H/G/WB/MP1, nRF52, RP2040-based (Nano RP2040 Connect, RASPBERRY_PI_PICO) boards, etc. using WiFiNINA modules/shields. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS, EEPROM, FlashStorage_SAMD, FlashStorage_STM32 or DueFlashStorage. DoubleDetectDetector feature permits entering Config Portal as requested",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=WiFiManager_NINA_Lite
version=1.4.1
version=1.5.0
author=Khoi Hoang
maintainer=Khoi Hoang <khoih.prog@gmail.com>
license=MIT
Expand Down
8 changes: 4 additions & 4 deletions platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ lib_compat_mode = strict

lib_deps =
; PlatformIO 4.x
; WiFiNINA_Generic@>=1.8.13
; WiFiWebServer@>=1.4.2
; WiFiNINA_Generic@>=1.8.14-3
; WiFiWebServer@>=1.5.3
; Functional-Vlpp@>=1.0.2
; DoubleResetDetector_Generic@>=1.7.3
; FlashStorage_SAMD@>=1.2.1
; FlashStorage_STM32@>=1.1.0
; PlatformIO 5.x
khoih-prog/WiFiNINA_Generic@>=1.8.13
khoih-prog/WiFiWebServer@>=1.4.2
khoih-prog/WiFiNINA_Generic@>=1.8.14-3
khoih-prog/WiFiWebServer@>=1.5.3
khoih-prog/Functional-Vlpp@>=1.0.2
khoih-prog/DoubleResetDetector_Generic@>=1.7.3
khoih-prog/FlashStorage_SAMD@>=1.2.1
Expand Down
21 changes: 17 additions & 4 deletions src/WiFiManager_NINA_Lite_DUE.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.4.1
Version: 1.5.0

Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -28,7 +28,8 @@
1.3.0 Michael H 21/04/2021 Enable scan of WiFi networks for selection in Configuration Portal
1.3.1 K Hoang 15/05/2021 Fix createHTML bug.
1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed or Arduino-pico core
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.5.0 K Hoang 05/01/2022 Fix the blocking issue in loop()
**********************************************************************************************************************************/

#ifndef WiFiManager_NINA_Lite_DUE_h
Expand All @@ -47,7 +48,7 @@
#error This code is intended to run on the SAM DUE platform! Please check your Tools->Board setting.
#endif

#define WIFIMANAGER_NINA_LITE_VERSION "WiFiManager_NINA_Lite v1.4.1"
#define WIFIMANAGER_NINA_LITE_VERSION "WiFiManager_NINA_Lite v1.5.0"

#include <WiFiWebServer.h>
#include <WiFiManager_NINA_Lite_Debug.h>
Expand Down Expand Up @@ -1398,6 +1399,16 @@ class WiFiManager_NINA_Lite

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

// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 and minimum 1.
#if !defined(MAX_NUM_WIFI_RECON_TRIES_PER_LOOP)
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1
#else
#if (MAX_NUM_WIFI_RECON_TRIES_PER_LOOP < 1)
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1
#endif
#endif

// New connection logic from v1.2.0
bool connectMultiWiFi(int retry_time)
{
Expand Down Expand Up @@ -1457,7 +1468,9 @@ class WiFiManager_NINA_Lite

uint8_t numIndexTried = 0;

while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) )
uint8_t numWiFiReconTries = 0;

while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) && (numWiFiReconTries++ < MAX_NUM_WIFI_RECON_TRIES_PER_LOOP) )
{
while ( 0 < retry_time )
{
Expand Down
5 changes: 3 additions & 2 deletions src/WiFiManager_NINA_Lite_Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.4.1
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -28,7 +28,8 @@
1.3.0 Michael H 21/04/2021 Enable scan of WiFi networks for selection in Configuration Portal
1.3.1 K Hoang 15/05/2021 Fix createHTML bug.
1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed or Arduino-pico core
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.5.0 K Hoang 05/01/2022 Fix the blocking issue in loop()
**********************************************************************************************************************************/

#ifndef WiFiManager_NINA_Lite_Debug_h
Expand Down
21 changes: 17 additions & 4 deletions src/WiFiManager_NINA_Lite_RP2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.4.1
Version: 1.5.0

Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -28,7 +28,8 @@
1.3.0 Michael H 21/04/2021 Enable scan of WiFi networks for selection in Configuration Portal
1.3.1 K Hoang 15/05/2021 Fix createHTML bug.
1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using Arduino mbed or Arduino-pico core
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.4.1 K Hoang 12/10/2021 Update `platform.ini` and `library.json`
1.5.0 K Hoang 05/01/2022 Fix the blocking issue in loop()
**********************************************************************************************************************************/

#ifndef WiFiManager_NINA_Lite_RP2040_h
Expand All @@ -44,7 +45,7 @@
#error This code is intended to run on the RP2040 platform! Please check your Tools->Board setting.
#endif

#define WIFIMANAGER_NINA_LITE_VERSION "WiFiManager_NINA_Lite v1.4.1"
#define WIFIMANAGER_NINA_LITE_VERSION "WiFiManager_NINA_Lite v1.5.0"

#include <WiFiWebServer.h>

Expand Down Expand Up @@ -1627,6 +1628,16 @@ class WiFiManager_NINA_Lite

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

// Max times to try WiFi per loop() iteration. To avoid blocking issue in loop()
// Default 1 and minimum 1.
#if !defined(MAX_NUM_WIFI_RECON_TRIES_PER_LOOP)
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1
#else
#if (MAX_NUM_WIFI_RECON_TRIES_PER_LOOP < 1)
#define MAX_NUM_WIFI_RECON_TRIES_PER_LOOP 1
#endif
#endif

// New connection logic from v1.2.0
bool connectMultiWiFi(int retry_time)
{
Expand Down Expand Up @@ -1686,7 +1697,9 @@ class WiFiManager_NINA_Lite

uint8_t numIndexTried = 0;

while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) )
uint8_t numWiFiReconTries = 0;

while ( !wifi_connected && (numIndexTried++ < NUM_WIFI_CREDENTIALS) && (numWiFiReconTries++ < MAX_NUM_WIFI_RECON_TRIES_PER_LOOP) )
{
while ( 0 < retry_time )
{
Expand Down
Loading

0 comments on commit 7a37010

Please sign in to comment.