-
Notifications
You must be signed in to change notification settings - Fork 10
WiFiManager connection attempt to unconfigured ("blank") SSID after restart on SAMD #8
Comments
Hi @bizprof Again thanks for your informative and accurate bug report 👍 . A snap shot
|
Great, thank you for the quick reaction! If I may add another (hopefully small) request, it's about the comments in defines.h, in this section of the code: // Force some params in Blynk, only valid for library version 1.0.1 and later It took me a while to understand these parameters, especially since they are quite a way down from the top of the file, and the reference to "Blynk" threw me off in the beginning, as I am not using Blynk (yet). Maybe you can change the comment to make it a bit more intuitive? Thank you as always! Michael |
Sure will do. If you can suggest or add some comments somewhere, please don't hesitate. |
On this particular code section, maybe something along the lines of:
Hope I captured the correct meanings/intent of those parameters? |
Will change as follows:
|
👍 |
The new WiFiManager_NINA_Lite release v1.1.3 has been published. Please test. Release v1.1.3
|
### Release v1.1.3 1. Fix invalid "blank" or NULL Config Data treated as Valid. Check [WiFiManager connection attempt to unconfigured ("blank") SSID after restart on SAMD #8](khoih-prog/WiFiManager_NINA_Lite#8) 2. Fix compiler warnings.
Thanks for the new release. Did a quick test, it now works for my scenario, when no SSID is configured. Entering config with just the first SSID/Pwd set:
After reset it should connect to first SSID, but doesn't:
|
This behaviour is intended. Both SSID/PWD must be valid, you have to input the same SSID/PWD even you need only one set. Never leave anything "blank" or NULL. The trade-off was made to simplify/shorten the code. |
Ok, that's fine then. Suggest to highlight the first 4 input fields in the CP as mandatory (e.g., by adding an asterisk or a short comment to the input field labels), to make it clearer to the end user. Thanks! |
OK. Will do for next release. |
Hi Michael,
The enhancement has been made and new WiFiManager_NINA_Lite v1.2.0 published. Please check To use and input only one set of WiFi SSID and PWD and verify. Looking forward to receiving more bug reports and enhancement requests from you. Thanks and Regards, KH Release v1.2.0
|
Hi Khoi, this is great, appreciate the quick turnaround! Have done some tests, and it works well for my scenario. More along the lines of an enhancement request (I don't want to publish it as such, though, before I hear your feedback): From looking at your code, I think you are halfway there already to make the number of SSID/Pwd inputs more generic. You got NUM_WIFI_CREDENTIALS, which is currently set to 2, but could be 1 (which would take care of the single SSID scenario), or potentially even bigger numbers. And you have already programmed the dynamic parameters, so combining these approaches, it might make a huge difference in usability of the CP for new users, when only as many paramters are shown as need to be configured. Looking forward to your feedback. Thanks! Michael |
Glad that you see what I intended (NUM_WIFI_CREDENTIALS) for long future. I still think 2 is the best number (to provide backup and reliability). More than 2 is unrealistic, even not complicated to handle (much simpler than dynamic params). Not many users are as sophisticated as you are They treat the library as fast food and are not willing to contribute and give back. I always got complaint about too many configurable parameters, and the code requires user to spend some time to read README and understand how to configure. Just a few:
But I'll leave it for future expansion, if reality requires. Thanks. |
Hi Khoi, Thanks for the feedback. I agree, it's hard to balance broad functionality with ease of use. Pretty much every company that makes standard software (MS, Oracle, SAP, and even many Open Source projects) have run into this problem. The usual approach is to make it look simple enough at first glance, by hiding the more advanced settings. For specific requirements, there is a ton of parameters to tweak (just think of how many entries there are in the Windows registry!). I like your fast food metaphor, that sums it up very well. I'm not good at coding, but I'm trying to contribute in a different way. Can't expect something for nothing all the time. You must have been working way past midnight your time yesterday to get the new release out. People take it for granted, which is a very short-sighted position! Please don't despair. I have chosen this WiFiManager for a reason, and I hope many others will, too. You are tackling the problem of cross-platform software compatibility/portability, which was the steepest learning curve for me as an Arduino newbie. Took me a while to understand why the programs I wrote for one board could not be made to work on a different board. Your more generic development approach is certainly the right way forward! All the best, Michael |
Thanks for your understanding. It's the passion, the knowledge that my works can somehow helps someone (as I had been helped) and the user's appreciation keep me going, thru many long days and nights. Hopefully, my retired days are still long enough to permit me to keep going. Best Regards, |
Hi Khoi, Thought I'd suggest some code changes which don't mess with the other functionality, but in the end (and, under the hood, so to say) get to a flexible number of WiFi credentials, determined by NUM_WIFI_CREDENTIALS. My first suggestion (probably the easiest one), starts on code line 818 in WiFiManager_NINA_Lite_SAMD.h, where the display of WiFi credentials could be made dynamic:
The log would now looks like this:
Let me know what you think, just trying to help... Regards, Michael |
And around line 1064:
|
Around line 1258:
|
Hi @bizprof Again thanks much for your willingness to help here and I'm impressed with your suggestion. You'll see this knowledge gaining by yourself, via direct experience, by reading and understanding the code, will follow you the whole life. This is contrary to what I meant by fast food metaphor.
As I said, it's easy for me to make this NUM_WIFI_CREDENTIALS dynamic, especially back to 1 as the old day. Or even several more. The other unknown dynamic params are much harder to implement. I certainly will have a look later to add optional NUM_WIFI_CREDENTIALS = 1, if you insist this is helpful for certain use-case, even I still prefer 2 as a way to push and make users familiar with more reliable usage. Sometimes good habits must be forced onto you to change bad ones. But just continue with your experiment of code changing. It'll definitely be helpful to you as well as me. Hopefully some day I pass to you to co-maintain this library. |
Thanks, Khoi! Trying my best not to mess up your code. One little change at a time. There are 4 more code sections in WiFiManager_NINA_Lite_SAMD.h (I assume the files for the other platforms are similar?) that would need to be adapted. As they are quite dependend on each other, will tackle this tomorrow, perhaps. The good thing is, you might get rid of the just introduced REQUIRE_ONE_SET_SSID_PW parameter - it would be covered by the NUM_WIFI_CREDENTIALS = 1 setting :-) |
Hi Khoi, quick question in regards to the code in handleRequest. I see that you used the standard strcpy and strncpy functions, which in turn forced you to handle low-level string operations, such as terminating parameters with "0", if they are shorter than the allocated variable. Would you be open to using the strlcpy function instead, which does that by default? Please let me know before I spend time modifying it. Thanks! |
Hi Michael, Thanks a lot to identify many possible improvements which I'm sure too many to count 👍 .
Using strcpy and strncpy is my bad old-and-die-hard habit 👎 to do it the hard way. Using strlcpy is much better and safer. I'll certainly retest and include in the code after you finalize via PR (Pull-Request). |
Hi Michael, As we're having many discussions which can be personal, lengthy and contains too many details and sometimes erroneous. I think they are suitable to put in a private repo. I'm opening General_Discussion and invite you (and several other contributing people) in where we can freely discuss many improvements to many other libraries, including this one. |
That's a great idea! I'm not too familiar with GitHub yet, just wanted to avoid opening up a new Issue all the time. I'll try the PR route, too, please bear with me, as I have never done that before :-) |
That's where I'll show you steps-be-steps to familiarize with GitHub, PR, etc. |
Already sent you the invitation to the private repo. Pls accept, then you will have access. |
### Major Releases v1.1.0 1. Add support to RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico** v1.6.2+ core](https://github.com/earlephilhower/arduino-pico). 2. Add support to RP2040-based boards, such as **Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** v2.1.0+ core](https://github.com/arduino/ArduinoCore-mbed). 3. Enable scan of WiFi networks for selection in Configuration Portal. Check [PR for v1.3.0 - Enable scan of WiFi networks #10](khoih-prog/WiFiManager_NINA_Lite#10). Now you can select optional **SCAN_WIFI_NETWORKS**, **MANUAL_SSID_INPUT_ALLOWED** to be able to manually input SSID, not only from a scanned SSID lists and **MAX_SSID_IN_LIST** (from 2-6 for ESP8266-AT or 2-15 for other) 4. Use more efficient [FlashStorage_SAMD v1.1.0](https://github.com/khoih-prog/FlashStorage_SAMD) and [FlashStorage_STM32 v1.0.0](https://github.com/khoih-prog/FlashStorage_STM32) 5. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](khoih-prog/Blynk_WM#25) 6. Configurable **Customs HTML Headers**, including Customs Style, Customs Head Elements, CORS Header. 7. Fix MultiWiFi connection bug. Check [SAMD MultiWiFi issues when first WiFi SSID configured in CP is invalid or not available #6](khoih-prog/WiFiManager_NINA_Lite#6) 8. Fix invalid "blank" or NULL Config Data treated as Valid. Check [WiFiManager connection attempt to unconfigured ("blank") SSID after restart on SAMD #8](khoih-prog/WiFiManager_NINA_Lite#8) 9. Permit optionally inputting one set of WiFi SSID/PWD by using `REQUIRE_ONE_SET_SSID_PW == true` 10. Enforce WiFi Password minimum length of 8 chars 11. Enhance MultiWiFi connection logic 12. Minor enhancement to not display garbage when data is invalid 13. Tested with new [Arduino Core for STM32 v2.0.0](https://github.com/stm32duino/Arduino_Core_STM32) and add support to new STM32L5 boards 14. Optimize code. 15. Update examples 16. Update `Packages' Patches 17. Fix compiler warnings.
### Major Releases v1.1.0 1. Add support to RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Earle Philhower's arduino-pico** v1.6.2+ core](https://github.com/earlephilhower/arduino-pico). 2. Add support to RP2040-based boards, such as **Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** v2.1.0+ core](https://github.com/arduino/ArduinoCore-mbed). 3. Enable scan of WiFi networks for selection in Configuration Portal. Check [PR for v1.3.0 - Enable scan of WiFi networks #10](khoih-prog/WiFiManager_NINA_Lite#10). Now you can select optional **SCAN_WIFI_NETWORKS**, **MANUAL_SSID_INPUT_ALLOWED** to be able to manually input SSID, not only from a scanned SSID lists and **MAX_SSID_IN_LIST** (from 2-6 for ESP8266-AT or 2-15 for other) 4. Use more efficient [FlashStorage_SAMD v1.1.0](https://github.com/khoih-prog/FlashStorage_SAMD) and [FlashStorage_STM32 v1.0.0](https://github.com/khoih-prog/FlashStorage_STM32) 5. Add functions to control Config Portal from software or Virtual Switches. Check [How to trigger a Config Portal from code #25](khoih-prog/Blynk_WM#25) 6. Configurable **Customs HTML Headers**, including Customs Style, Customs Head Elements, CORS Header. 7. Fix MultiWiFi connection bug. Check [SAMD MultiWiFi issues when first WiFi SSID configured in CP is invalid or not available #6](khoih-prog/WiFiManager_NINA_Lite#6) 8. Fix invalid "blank" or NULL Config Data treated as Valid. Check [WiFiManager connection attempt to unconfigured ("blank") SSID after restart on SAMD #8](khoih-prog/WiFiManager_NINA_Lite#8) 9. Permit optionally inputting one set of WiFi SSID/PWD by using `REQUIRE_ONE_SET_SSID_PW == true` 10. Enforce WiFi Password minimum length of 8 chars 11. Enhance MultiWiFi connection logic 12. Minor enhancement to not display garbage when data is invalid 13. Tested with new [Arduino Core for STM32 v2.0.0](https://github.com/stm32duino/Arduino_Core_STM32) and add support to new STM32L5 boards 14. Optimize code. 15. Update examples 16. Update `Packages' Patches 17. Fix compiler warnings.
Describe the bug
I have encountered a situation where WiFiManager tries to connect to unconfigured SSIDs (stored with the default value "blank" in EEPROM) after power cycling the board. This is unwanted behavior, as in some use cases WiFi parameters will have to be configured much later, or WiFi might be unavailable for longer periods of operation. This version of WiFiManager seems to be blocking the CPU while connection attempts are made, which impacts normal operation of the board (in my case, running a Nixie clock).
Steps to Reproduce
Using the supplied example script SAMD_WiFiNINA.ino (without Dynamic parameters, and RESET_IF_CONFIG_TIMEOUT set to "false" in defines.h), After loading the script, I let the CP time out without connecting to it at all. I disconnect the board from power and then reconnect. The script now tries to connect to SSID "blank" multiple times. Only then it goes into the CP. After the CP times out, the script tries to connect to the "blank" SSIDs again. And so on. See log below.
Expected behavior
I expect the script to behave the same each time the board restarts. I.e., if I do not configure any SSIDs, it should stay in CP mode forever, as it does the first time the script is loaded (indicated by the log entry "[WN] bg:Stay forever in CP:No ConfigDat").
Actual behavior
The "blank" entries seem to be mistaken for actual config data, and hence there is an attempt to connect to them, with all the performance impact that entails. Maybe don't store blank entries at all, but leave them as unconfigured. Similar scenarios might occur when only one of the SSIDs is configured, and the other one is left "blank".
Debug log
FIRST run of the script (going straight into CP, as expected):
SUBSEQUENT runs of the script after reconnecting board:
Information
Really appreciate you taking the time looking into these issues.
WiFiManager_NINA_Light does a wonderful job, hence I'm using it in different scenarios, which might push its boundaries.
Keep up the great work. Thank you!
The text was updated successfully, but these errors were encountered: