Skip to content

If WiFi.softAP() after WiFi connected, then Blynk can't work. #3884

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

Closed
bestpika opened this issue Nov 27, 2017 · 16 comments
Closed

If WiFi.softAP() after WiFi connected, then Blynk can't work. #3884

bestpika opened this issue Nov 27, 2017 · 16 comments

Comments

@bestpika
Copy link

bestpika commented Nov 27, 2017

Basic Infos

Hardware

Hardware: WeMos D1 mini
Core Version: 7b09ae5
Blynk Version: blynkkk/blynk-library@dd7fe1f

Description

If WiFi.softAP() after WiFi connected, then Blynk can't work.
But 5c01841 is okay.

Sketch

Not work

#define BLYNK_PRINT Serial

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

void setup()
{
  Serial.begin(115200);
  Serial.println();
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin("STA ssid", "STA passphrase");

  int wait = 0;
  while (!WiFi.isConnected() && wait++ < 10) {
    Serial.print(".");
    delay(1000);
  }
  WiFi.softAP("AP ssid", "AP passphrase");

  Blynk.config("Blynk Token", "blynk-cloud.com");
  Blynk.connect();
}

void loop()
{
  Blynk.run();
}

Serial

[10495]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino

[10499] Connecting to blynk-cloud.com:8442
[15500] Connecting to blynk-cloud.com:8442
[20501] Connecting to blynk-cloud.com:8442

Work

#define BLYNK_PRINT Serial

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

void setup()
{
  Serial.begin(115200);
  Serial.println();
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin("STA ssid", "STA passphrase");

  WiFi.softAP("AP ssid", "AP passphrase");
  int wait = 0;
  while (!WiFi.isConnected() && wait++ < 10) {
    Serial.print(".");
    delay(1000);
  }

  Blynk.config("Blynk Token", "blynk-cloud.com");
  Blynk.connect();
}

void loop()
{
  Blynk.run();
}

Serial

[8525]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino

[8527] Connecting to blynk-cloud.com:8442
[8695] Ready (ping: 77ms).

Debug Messages

wifi evt: 2
wifi evt: 0
wifi evt: 3

[9634] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino

[9635] Connecting to blynk-cloud.com:8442
[hostByName] request IP for: blynk-cloud.com
[hostByName] Host: blynk-cloud.com IP: 188.166.206.43
wifi evt: 7
wifi evt: 7
[14636] Connecting to blynk-cloud.com:8442
[hostByName] request IP for: blynk-cloud.com
[hostByName] Host: blynk-cloud.com IP: 188.166.206.43
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
[19637] Connecting to blynk-cloud.com:8442
[hostByName] request IP for: blynk-cloud.com
[hostByName] Host: blynk-cloud.com IP: 188.166.206.43
wifi evt: 7
wifi evt: 7
[24638] Connecting to blynk-cloud.com:8442
[hostByName] request IP for: blynk-cloud.com
[hostByName] Host: blynk-cloud.com IP: 188.166.206.43
wifi evt: 7
@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017

Can you retry with core version 7b09ae5 (latest master) and with lwip-v1.4 instead of v2 in menus ?

@bestpika
Copy link
Author

bestpika commented Nov 27, 2017

@d-a-v I can't find lwip-v1.4
image

@bestpika
Copy link
Author

I try Prebuilt Source (gcc), then it work.
image

wifi evt: 2
wifi evt: 0
wifi evt: 3

[9869] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.4.10 on Arduino

[9871] Connecting to blynk-cloud.com:8442
[hostByName] request IP for: blynk-cloud.com
[hostByName] Host: blynk-cloud.com IP: 188.166.206.43
[10050] Ready (ping: 75ms).
wifi evt: 7
wifi evt: 7
wifi evt: 7

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017 via email

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017

So lwip-v2 is the cause. I'll work on it. Thanks for the report !

@bestpika
Copy link
Author

Thank you.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017

I can't reproduce it. It works with both sketch.
Can you remove your ++wait<10 test and re-check ?

@bestpika
Copy link
Author

bestpika commented Nov 27, 2017

This bug have to check WiFi.isConnected() == true then start WiFi.softAP().
I try over ten times.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017

Apparently my softAP password was not long enough :]
I finally could reproduce the bug. I also added the simple web server in your sketch.
Oddly, with lwip2 + webserver and softAP after STA, blinky does not work but webserver works on both interfaces.

tcpdump shows the ARP request and answer for blynk-cloud.com resolving.

Now digging into Blynk lib...

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 27, 2017

@bestpika Are you trying with exactly the sketches above ?
I could reproduce the bug only because I forgot to remove an ESP.eraseConfig() lost in my tryings.

Both your sketches are OK with lwip2 here.
I need more input, or someone else try.

It may be not related but I also noticed blink services takes 5 seconds more everytime I reset the ESP right after beeing connected (I guess it is a fair protection against buggy device).

@bestpika
Copy link
Author

bestpika commented Nov 27, 2017

I will try tomorrow.
By the way, I using Arduino IDE 1.8.5 and Windows 10 Enterprise 1703 x64.

@devyte
Copy link
Collaborator

devyte commented Nov 27, 2017

My quick test seems to agree with @d-a-v .
Closing as can't reproduce.

@devyte devyte closed this as completed Nov 27, 2017
@bestpika
Copy link
Author

Today I try over 20 times.
Not work still not work.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 28, 2017

Are you using exactly the sketch above with your IDs ?

@bestpika
Copy link
Author

bestpika commented Nov 28, 2017

@d-a-v yes.
I only modify STA ssid, STA passphrase, AP ssid, AP passphrase, Blynk Token.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 28, 2017

@devyte I think this is an interesting issue with lwip-v1.4 working where lwip2 does not, so I think it is worth investigating a bit more.
@bestpika can you activate lwip2 log and retry ?
you need to:

cd tools/sdk/lwip2
make

edit builder/glue/gluedebug.h and change ULWIPDEBUG from 0 to 1, then

make install

In your sketch, add Serial.setDebugOutput(true); right after Serial.begin(), then restart your failing sketch.
If you can post the console somewhere so we can check the IP traffic.

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