Restart WiFi

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Restart WiFi

#1 Post by mackowiakp » 12 Sep 2022, 03:53

I am only asking for confirmation or deny that I am thinking right.
If I have selected in Menu -> Tools -> Advanced -> Restart WiFi Lost Conn: and I am connected to the AP, then with the "WifiDisconnect" command, the WiFi stack is reloaded and its reinitialization.
Of course, depending on the selected option "Use Last Connected AP from RTC:", the connection is made to the last known AP or to the best available at the moment.
In older FW this option does not work and always connects to the last known AP if available.
Am I thinking right?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Restart WiFi

#2 Post by TD-er » 12 Sep 2022, 09:08

As always: "It depends" :)

There is some threshold on whether to use a reconnect or connecting to the "next one" or perform a scan and start all over.

There are some values involved here:
- Whether an active connection is considered "stable". If stable, the node may try to reconnect first.
- Scan results are considered "valid" for so many minutes after being detected during scan

A connection is considered "stable" when being connected for some time (I think it is 5 minutes)
After performing a scan, each WiFi candidate has a lifespan, which will be renewed when found again on a new scan.

The "Use Last Connected AP from RTC:" only has effect when rebooting.
Or in other words, when unchecked, the currently connected AP is not stored in RTC memory.

The "Restart WiFi Lost Conn:" option may be the default right now regardless of its checked state (or on either ESP32 or ESP8266, not sure)
What it does is it will turn the WiFi radio off and on again when a connection is lost.
This does reset (or at least I hope it does) all internal states of the closed source WiFi code.

So now the procedure:

Code: Select all

Scenario 1: Reconnect/warm boot
- Turn on WiFi
- Retry last known SSID/BSSID/channel (with "Use Last Connected AP from RTC" set)
Failed: -> Cold boot scenario


Scenario 2: Cold boot with known credentials
- Collect known credentials
- Perform scan (when no candidates present from last scan)
- Sort known credentials based on scan
- Loop:
  - Select credentials[N}
  - Try connect
  - Failed: 
    - ++N
    - If no more credentials:
      - start AP
      - If no-one connected to AP:  restart scenario 2


Scenario 3: No known credentials
- Perform scan (to speed up setup page)
- start AP (when scan completes)
The scan on scenario2 is only done if there are still candidates left to try to connect to.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Restart WiFi

#3 Post by mackowiakp » 12 Sep 2022, 11:23

THX for the precise (as always) explanation !

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests