Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Very slow connection to WiFi - almost 3.2 seconds, even if the static IP is used. #2798

Copy link
Copy link
Closed
@robertgregor

Description

@robertgregor
Issue body actions

Hi,
I have latest 1.0.3 rc1 installed and have simple sketch:

#include <WiFi.h>

boolean connected=false;

IPAddress getIpAddr(String ip) {
IPAddress addr;
int iparr[4];
iparr[0] = ip.toInt();
for (int i=1; i<4; i++) {
ip.remove(0, ip.indexOf('.')+1);
iparr[i] = ip.toInt();
}
return IPAddress(iparr[0], iparr[1], iparr[2], iparr[3]);
}

void connectToWifiNoWait(String ssid, String pwd, String ip, String gw, String mask, String dns1, String dns2, String bssid, String chnl ) {
if (WiFi.status() == WL_CONNECTED) return;
Serial.println(PSTR("Connecting wifi..."));
WiFi.persistent(true);
WiFi.setAutoConnect(true);
WiFi.setAutoReconnect(true);
if (ip.length() != 0) {
WiFi.config(getIpAddr(ip), getIpAddr(gw), getIpAddr(mask), getIpAddr(dns1), getIpAddr(dns2));
Serial.println(PSTR("Config called..."));
}
if ((ssid.length() != 0) && (pwd.length() == 0)) {
WiFi.begin(ssid.c_str());
Serial.println(PSTR("Begin with ssid called..."));
} else if ((ssid.length() != 0) && (pwd.length() != 0)) {
if (bssid.length() == 0) {
WiFi.begin(ssid.c_str(), pwd.c_str());
Serial.println(PSTR("Begin with ssid and password called..."));
} else {
byte iparr[6];
for (int i=0; i<6; i++) {
String part = "0x" + bssid.substring(0,bssid.indexOf(':'));
bssid.remove(0, bssid.indexOf(':')+1);
iparr[i] = strtol(part.c_str(),NULL,0);
}
WiFi.begin(ssid.c_str(), pwd.c_str(), chnl.toInt(), iparr);
Serial.println(PSTR("Begin with ssid, password, channel and bssid called..."));
}
}
}

void setup() {
Serial.begin(115200);
connectToWifiNoWait("Bob", "xxxxx", "192.168.1.50", "192.168.1.1", "255.255.255.0", "94.142.233.120", "94.142.233.140", "F8:D1:11:24:B3:84", "4" );
WiFi.setAutoReconnect(true);
}

void loop() {
// put your main code here, to run repeatedly:
if (WiFi.status() == WL_CONNECTED) {
if (!connected) {
Serial.print("Connected: ");
Serial.println(millis(), DEC);
connected=true;
Serial.printf("IP: %d.%d.%d.%d, time: %d",WiFi.localIP()[0],WiFi.localIP()[1],WiFi.localIP()[2],WiFi.localIP()[3], millis());
}
}
}

As is seen, I will do simple config and then will try to connect. My problem is, that connection to wifi takes almost 3.5 seconds:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:928
ho 0 tail 12 room 4
load:0x40078000,len:8424
ho 0 tail 12 room 4
load:0x40080400,len:5868
entry 0x4008069c
Connecting wifi...
Config called...
Begin with ssid, password, channel and bssid called...
Connected: 3499
IP: 192.168.1.50, time: 3499

Any idea, what can be the problem? Almost the same code using esp 8266 was working in 100 - 200 ms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.