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

SAMD MultiWiFi issues when first WiFi SSID configured in CP is invalid or not available #6

Closed
bizprof opened this issue Mar 30, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@bizprof
Copy link
Collaborator

bizprof commented Mar 30, 2021

Describe the bug

Using the supplied SAMD example, I have configured WiFi credentials for 2 separate networks (i.e., first SSID for home, second SSID for work).

The example script is using "WiFiManager_NINA->begin()" in setup(), and then "WiFiManager_NINA->run()" in loop().

The following happens:
When the first set of credentials points to an available SSID, all is fine and the board connects to this SSID as expected.
But when the first SSID is not available, the board does not connect to the second SSID, even though it is valid and available.
Instead, it fails while trying to connect to the first SSID, and then goes straight into CP mode. It does not even try the second SSID.

If I now let the CP time out and do not enter any new values, the script eventually reports that it has connected to the second SSID, but the IP address listed is 0.0.0.0, and the router does not recognise this connection (the MAC address of the board does not show up in the router logs at all).

Steps to Reproduce

Using the supplied example script SAMD_WiFiNINA.ino (without Dynamic parameters) and specifying an invalid/unavailable SSID as the first SSID in CP, and a valid/available SSID as the second SSID, then restarting the board

Expected behavior

I expect the "connectMultiWiFi" routine to go through all configured SSIDs, until it finds the first SSID it can connect to. This should be kept consistent between both "WiFiManager_NINA->begin()" and "WiFiManager_NINA->run()".

Actual behavior

See above. "WiFiManager_NINA->begin()" does not try the second SSID, but goes into the CP instead after trying the first, unavailable, SSID. "WiFiManager_NINA->run()" seems to connect to the second SSID, but returns an invalid IP address (0.0.0.0), even though it reports the status as "WL_CONNECTED". See logfile below. I was able to patch the invalid IP address behaviour by inserting a "WiFi.end()" call into the beginning of the "connectMultiWiFi" routine in source file WiFiManager_NINA_Lite_SAMD.h (Editor screenshot below). That allows for a valid IP address to be assigned by DHCP. I assume the board must have been left in some undefined state after coming out of AP mode from the CP, and the WiFi.end() fixes that..

2021-03-30 17_40_16-_C__Users_heinrich_Documents_Arduino_libraries_WiFiManager_NINA_Lite_src_WiFiMan

Debug log

FIRST run of the script (going straight into CP to store credentials):

Starting SAMD_WiFiNINA on SAMD NANO_33_IOT
WiFiManager_NINA_Lite v1.1.1
[WN] Hostname=SAMD-Master-Controller
Flag read = 0xffffffff
No doubleResetDetected
SetFlag write = 0xd0d01234
[WN] CCSum=0xe11e,RCSum=0xffffffff
[WN] InitCfgFile,sz=236
[WN] SaveEEPROM,Sz=1024,DataSz=0,WCSum=0xc7d
[WN] bg: isForcedConfigPortal = false
[WN] bg:Stay forever in CP:No ConfigDat
[WN] SSID=WIFININA_51F485,PW=MyWIFININA_51F485
[WN] IP=192.168.4.1,CH=9
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
FFFF[WN] h:UpdEEPROM
[WN] SaveEEPROM,Sz=1024,DataSz=0,WCSum=0x1309
[WN] h:Rst

SUBSEQUENT runs of the script after reconnecting board: (Credentials obfuscated, comments marked "--->")

Starting SAMD_WiFiNINA on SAMD NANO_33_IOT
WiFiManager_NINA_Lite v1.1.1
[WN] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WN] CCSum=0x1309,RCSum=0x1309
[WN] ======= Start Stored Config Data =======
[WN] Hdr=WIFININA,SSID=InvalidSSID,PW=something
[WN] SSID1=,PW1=
[WN] BName=blank
[WN] con2WF:SSID=InvalidSSID,PW=something
[WN] Failed using index=0, retry_time=0
[WN] con2WF:failed
[WN] b:NoW ---> It should now try the second SSID, but goes to CP instead
[WN] SSID=WIFININA_51F485,PW=MyWIFININA_51F485
[WN] IP=192.168.4.1,CH=10 ---> I let the CP time out and do not enter new values
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
F[WN] r:WLost&TOut.ConW.Retry#1
[WN] r:WLost.ReconW
[WN] con2WF:SSID=,PW=
[WN] con2WF:OK
[WN] SSID=****,RSSI=-28
[WN] IP=0.0.0.0 ---> Invalid IP address, has not been assigned by router (MAC address does not show in router log)
[WN] r:WOK
[WN] r:gotWBack
HHHHHHHHH ---> But there is no connection, and IP address is invalid

Information

Please ensure to specify the following:

  • Arduino IDE version: 1.8.13 on Windows 10
  • Board: Arduino NANO 33 IoT with latest firmware
@khoih-prog
Copy link
Owner

@bizprof

Thanks a lots for your impressive and informative bug report / description, which will help me a lots to find out and fix the bug.
I definitely spend time on this very soon.

Regards,

@khoih-prog khoih-prog added the bug Something isn't working label Mar 30, 2021
@bizprof
Copy link
Collaborator Author

bizprof commented Mar 30, 2021 via email

@khoih-prog
Copy link
Owner

Hi Michael,

Already fix the issue, will post the new release within today. Hereafter is the debug terminal showing you the result.
Your contribution will be noted and appreciated.


Starting SAMD_WiFiNINA on SAMD NANO_33_IOT
WiFiManager_NINA_Lite v1.1.1
[WN] Set CustomsStyle to : <style>div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}button{background-color:blue;color:white;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}</style>
[WN] Set CustomsHeadElement to : <style>html{filter: invert(10%);}</style>
[WN] Set CORS Header to : Your Access-Control-Allow-Origin
[WN] Hostname=SAMD-Master-Controller
Flag read = 0xd0d04321
No doubleResetDetected
SetFlag write = 0xd0d01234
[WN] CCSum=0x111d,RCSum=0x111d
[WN] ChkCrR:pdata=1,len=34
[WN] ChkCrR:pdata=2,len=34
[WN] ChkCrR:pdata=3,len=34
[WN] ChkCrR:pdata=4,len=34
[WN] ChkCrR:pdata=8080,len=6
[WN] ChkCrR:pdata=5,len=34
[WN] ChkCrR:CrCCsum=0x1cf,CrRCsum=0x1cf
[WN] CrCCSum=1cf,CrRCSum=1cf
[WN] Valid Stored Dynamic Data
[WN] ======= Start Stored Config Data =======
[WN] Hdr=WIFININA,SSID=HueNet5,PW=********   <====== Fake SSID
[WN] SSID1=HueNet1,PW1=********              <== Real SSID
[WN] BName=Nano33IoT
[WN] i=0,id=sv1,data=1
[WN] i=1,id=tk1,data=2
[WN] i=2,id=sv2,data=3
[WN] i=3,id=tk2,data=4
[WN] i=4,id=prt,data=8080
[WN] i=5,id=mqt,data=5
[WN] ConMultiWifi
[WN] con2WF:SSID=HueNet5,PW=********
[WN] Remaining retry_time=3
[WN] Remaining retry_time=2
[WN] Remaining retry_time=1
[WN] Failed using index=1, retry_time=0
[WN] Remaining retry_time=3
[WN] WOK, lastConnectedIndex=1
[WN] con2WF:OK
[WN] IP=192.168.2.83
[WN] SSID=HueNet1,RSSI=-25     <==== Connected to read SSID
[WN] IP=192.168.2.83           <==== with correct IP
[WN] b:WOK
Stop doubleResetDetecting
ClearFlag write = 0xd0d04321
H
Your stored Credentials :
Blynk Server1 = 1
Token1 = 2
Blynk Server2 = 3
Token2 = 4
Port = 8080
MQTT Server = 5

@bizprof
Copy link
Collaborator Author

bizprof commented Mar 30, 2021 via email

khoih-prog added a commit that referenced this issue Mar 30, 2021
### Release v1.1.2

1. Fix MultiWiFi connection bug. Check [SAMD MultiWiFi issues when first WiFi SSID configured in CP is invalid or not available #6](#6)
@khoih-prog
Copy link
Owner

khoih-prog commented Mar 30, 2021

Dear Michael,

Thanks for your contribution which has been noted in Contributions and Thanks

The new WiFiManager_NINA_Lite v1.1.2 has been published to fix the issue.

Please test and I love to have more impressive bug reports from you 👍


Release v1.1.2

  1. Fix MultiWiFi connection bug. Check SAMD MultiWiFi issues when first WiFi SSID configured in CP is invalid or not available #6

@bizprof
Copy link
Collaborator Author

bizprof commented Mar 30, 2021 via email

@khoih-prog
Copy link
Owner

Thanks for your help. Looking forward to receiving more of your bug reports 👍

khoih-prog added a commit to khoih-prog/WiFiManager_Generic_Lite that referenced this issue Mar 30, 2021
### Release v1.1.2

1. 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)
2. Bump up to version v1.1.2 to sync with [WiFiManager_NINA_Lite](https://github.com/khoih-prog/WiFiManager_NINA_Lite)
khoih-prog added a commit to khoih-prog/WiFiManager_Generic_Lite that referenced this issue Mar 30, 2021
### Release v1.1.2

1. 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)
2. Bump up to version v1.1.2 to sync with [WiFiManager_NINA_Lite](https://github.com/khoih-prog/WiFiManager_NINA_Lite)
khoih-prog added a commit to khoih-prog/Blynk_WiFiNINA_WM that referenced this issue Jun 1, 2021
### 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.
khoih-prog added a commit to khoih-prog/Blynk_WiFiNINA_WM that referenced this issue Jun 1, 2021
### 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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants