Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was 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

Description

@bizprof

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions