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

When Saved Network is unavailable or credential changed #1

Closed
Darvesh7 opened this issue Apr 24, 2020 · 2 comments
Closed

When Saved Network is unavailable or credential changed #1

Darvesh7 opened this issue Apr 24, 2020 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@Darvesh7
Copy link

Hi, I tried the code on my Nano 33 iot and works fine. However there is an issue which I would like to bring forward. Let's say I setup the Arduino with a wifi credential on first use. Now the WiFi router had it credential changed or the Arduino has changed location and being use by someone else having different wifi-credential.

The present code, does not allow more than 1 credential to be entered. It always try to connect to the save credential on first setup, even if the network does not even exist.

It should be something like this:

if the stored SSID is not found, the WebServer/initial setup should start, default and advertised default SSID/PASS.

Is that something fixable ?

@khoih-prog
Copy link
Owner

khoih-prog commented Apr 24, 2020

Hi,
Thanks for using the library and find out an unintended bug. Just a difference in the way WiFiNINA behaves.

Please temporarily fix the code (will update in next release v1.0,3, with MultiWiFi feture) as follows:

In file WiFiManager_NINA_Lite_XXX.h, change the connectWiFi code from

bool connectWiFi(const char* ssid, const char* pass)
    {
      ....
      if ( WiFi.begin(ssid, pass)  )
      ...
      return true;
    }

to

bool connectWiFi(const char* ssid, const char* pass)
    {
      ....
      if ( WiFi.begin(ssid, pass) == WL_CONNECTED )
      ...
      return true;
    }

The following is the terminal output showing Config Portal will start after some attempts to connect WiFi fails (30s) as define in the code

#define TIMEOUT_CONNECT_WIFI			30000

HueNet3 is a faked / removed SSID to test

Start SAMD_WiFiNINA on SAMD NANO_33_IOT
*NN: CrCCSum=9694,CrRCSum=9694
*NN: CCSum=2155,RCSum=2155
*NN: Hdr=WIFININA,SSID=HueNet3,PW=****
*NN: i=0,id=sv1,data=account.ddns.net
*NN: i=1,id=tk1,data=****
*NN: i=2,id=sv2,data=account.duckdns.org
*NN: i=3,id=tk2,data=****
*NN: i=4,id=pt,data=8080
*NN: i=5,id=mq,data=mqtt-server
*NN: con2WF:start
*NN: con2WF:spentMsec=0
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=2512
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=4876
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=7241
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=9605
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=11970
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=14335
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=16699
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=19064
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=21428
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=23793
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:spentMsec=26157
*NN: Con2:HueNet3
WiFi-begin: return1 = 4
WiFi-begin: return2 = 4
*NN: NoW
*NN: con2WF:failed
*NN: b:NoW
*NN: SSID=WIFININA_51F485,PW=MyWIFININA_51F485   <= ConfigPortal reopened after 30s
*NN: IP=192.168.4.1,CH=10
WiFi-beginAP3: return1 = 7
WiFi-beginAP3: return2 = 7
FYour stored Credentials :
Blynk Server1 = account.ddns.net
Token1 = ****
Blynk Server2 = account.duckdns.org
Token2 = ****
Port = 8080
MQTT Server = mqtt-server
F

Please test and confirm the fix is OK.

@khoih-prog khoih-prog added the bug Something isn't working label Apr 24, 2020
@khoih-prog khoih-prog added the enhancement New feature or request label Apr 24, 2020
@khoih-prog
Copy link
Owner

Hi @Darvesh7
Thanks to your bug report, I fix and post the major release v1.0.3 with these new features:

Major Release v1.0.3

  1. Multiple WiFi Credentials (SSID, Password) and system will autoconnect to the available WiFi AP. It will then autoreconnect to the remaining WiFi AP if the current connection is lost.
  2. Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
  3. WiFi Password max length is 63, according to WPA2 standard
  4. Permit to input special chars such as % and # into data fields.
  5. Add option to have built-in, yet configurable RFC-952-conformed DHCP hostname.
  6. Fix bug

Your contribution is recognized in Contribution and Thanks.

Please test and confirm v1.0.3 is OK for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants