Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lwIP2 Network Switching Bug #4727

Closed
6 tasks done
aerlon opened this issue May 14, 2018 · 6 comments
Closed
6 tasks done

lwIP2 Network Switching Bug #4727

aerlon opened this issue May 14, 2018 · 6 comments
Assignees
Milestone

Comments

@aerlon
Copy link
Contributor

aerlon commented May 14, 2018

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12

  • Core Version:
    SDK:2.2.1(cfd48f3)/Core:win-2.5.0-dev/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-7-g2b827f8)
    SDK:2.2.1(cfd48f3)/Core:win-2.5.0-dev/lwIP:1.4.0rc2
    SDK:2.2.1(cfd48f3)/Core:win-2.4.1/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1)
    SDK:2.2.1(cfd48f3)/Core:win-2.4.1/lwIP:1.4.0rc2

  • Development Env: Arduino IDE

  • Operating System: Windows

Settings in IDE

  • Module: NodeMCU 1.0
  • Flash Mode: dio
  • Flash Size: 4MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 115200

Problem Description

This bug has two shapes depending on which Arduino core for ESP8266 version is used:

  • Using the latest master branch and lwIP2: The station in lwIP2_NetworkSwitchingBug.ino (download below) becomes unable to connect to any WiFi network after the first it connects to. Only if WiFi.mode(WIFI_OFF) is called first will a network switch be possible. This is not a problem when using lwIP1.4.

  • Using Arduino core for ESP8266 version 2.4.1 with lwIP2: The station in lwIP2_NetworkSwitchingBug.ino (download below) becomes unable to connect to any server except the first it connects to. It can however still connect to any WiFi network. WiFi.mode(WIFI_OFF) does not help with this situation. This is not a problem when using lwIP1.4.

Instructions for reproducing bug:

  1. Download and unzip the .ino files in lwIP2_NetworkSwitchingBug.zip.
  2. Make sure you are using either Arduino core for ESP8266 version 2.4.1 or the latest master branch.
  3. Make sure you are using lwIP1.4.
  4. Add AP1.ino to one ESP8266, AP2.ino to another and lwIP2_NetworkSwitchingBug.ino to a third.
  5. Observe serial output from lwIP2_NetworkSwitchingBug.ino.
  6. Power off the AP that lwIP2_NetworkSwitchingBug.ino connected to.
  7. Observe serial output from lwIP2_NetworkSwitchingBug.ino.
  8. Power up the disconnected AP.
  9. Re-upload lwIP2_NetworkSwitchingBug.ino using lwIP2.
  10. Observe serial output from lwIP2_NetworkSwitchingBug.ino.
  11. Power off the AP that lwIP2_NetworkSwitchingBug.ino connected to.
  12. Observe serial output from lwIP2_NetworkSwitchingBug.ino.
  13. Optional: If the latest master branch is used, uncomment WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_STA); at line 12 of lwIP2_NetworkSwitchingBug.ino and re-start from step 8.

Note: This may be a more detailed description of issue #4711 .

@d-a-v d-a-v self-assigned this May 14, 2018
@devyte devyte added this to the 2.4.2 milestone Jun 17, 2018
@d-a-v
Copy link
Collaborator

d-a-v commented Jun 18, 2018

Thanks for reporting, can you please try this:

cd tools/sdk/lwip2
make latestmaster

I will be doing more tests before making a PR for it.

(this is the same fix as for #4792)

@aerlon
Copy link
Contributor Author

aerlon commented Jun 19, 2018

I can confirm that this lwIP2 update seems to solve both the issue reported here and the related issue in PR #4718. WiFI connection did seem a bit unstable in PR #4718 with the lwIP2 fix applied, but since the fix is WIP I guess that may be expected.

@d-a-v
Copy link
Collaborator

d-a-v commented Jun 19, 2018

Instability is not expected with this fix, any detail is appreciated.

@aerlon
Copy link
Contributor Author

aerlon commented Jun 22, 2018

Based on more testing it would seem that the instability is roughly the same with the new fix as has previously been the case for lwIP2. lwIP2 does still cause more disconnects and lost server responses than lwIP1.4 when using the mesh network code, though.

What has changed with the new lwIP2 fix is the behaviour when a server becomes unavailable. Before the fix only one evaluation of curr_client.connect(SERVER_IP_ADDR, SERVER_PORT) occurred in the client code of #4718 for this situation, whereas now two evaluations happen immediately following each other (both fail). I'll see if I can isolate the cause of this in the coming days.

@aerlon aerlon mentioned this issue Jun 24, 2018
6 tasks
@aerlon
Copy link
Contributor Author

aerlon commented Jun 24, 2018

I've located the problem with the lwIP2 fix. Turns out WiFi.disconnect() must now be called twice to disconnect from a WiFi network (or at least to have WiFi.status() not be WL_CONNECTED). More details can be found in issue #4843.

@aerlon
Copy link
Contributor Author

aerlon commented Jun 26, 2018

Closing this since issue #4843 is now fixed, so there are no more (known) problems with the bug fix.

@aerlon aerlon closed this as completed Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants