Chat freely about anything...

User avatar
By rith87
#10577 I'm playing around with the IoT Demo from Electrodragon (http://www.electrodragon.com/w/ESP8266_IoT, sample code R1) and I've noticed that the ESP8266 takes a while to connect to the wifi network. I added some print outs for the IP address and the return code for espconn_connect() and here's what I'm seeing:

Code: Select allWiFi connecting...
IP address: 0.0.0.0
Connect status:1
WiFi connecting...
IP address: 0.0.0.0
Connect status:2
WiFi connecting error, wrong password
IP address: 0.0.0.0
Connect status:2
WiFi connecting error, wrong password
IP address: 0.0.0.0
Connect status:2
WiFi connecting error, wrong password
IP address: 0.0.0.0


So, it always starts off in the "Connecting" state, then goes into the "Wrong password" state and after 5 minutes, it finally connects. However, this is rather inefficient for the development process, so I was wondering if anyone has found a workaround for this problem.
User avatar
By rith87
#10740 For everyone's convenience, here's the bit of code that is on the Electrodragon sample:

This bit of code sets the wifi SSID and password via wifi_station_set_config(), which calls wifi_station_connect() if it is called in user_init():

Code: Select all// If the card mode STA, then set the configuration, the name of AP, password, see User_config.h
// Optional read the MAC address of our card mode AP, see. Wifi_get_macaddr (SOFTAP_IF, macaddr)
// In the STA in charge will be a different MAC address as the client, but we have to address yourself to read that she had if she had acted as an access point
    if(wifi_get_opmode() == STATION_MODE)
    {
        wifi_station_get_config(&stationConfig);
        os_memset(stationConfig.ssid, 0, sizeof(stationConfig.ssid));
        os_memset(stationConfig.password, 0, sizeof(stationConfig.password));
        os_sprintf(stationConfig.ssid, "%s", WIFI_CLIENTSSID);
        os_sprintf(stationConfig.password, "%s", WIFI_CLIENTPASSWORD);
        wifi_station_set_config(&stationConfig);
        // wifi_get_macaddr(SOFTAP_IF, macaddr);
    }
    // For adjusting the output data in uart mode setup STA
    #ifdef PLATFORM_DEBUG
    if(wifi_get_opmode() == STATION_MODE)
    {
        wifi_station_get_config(&stationConfig);
        os_sprintf(info,"OPMODE: %u, SSID: %s, PASSWORD: %s\r\n",
            wifi_get_opmode(),
            stationConfig.ssid,
            stationConfig.password);
        uart0_sendStr(info);
    }
    #endif


And this bit calls wifi_station_get_connect_status() every second to check if the ESP8266 is successfully connected to the wifi network. The wifi_station_get_connect_status() is somehow returning an incorrect password error for an indeterminate number of minutes betore returning a STATION_GOT_IP code.

Code: Select all     // Start the timer test the connection to Wi-Fi, check the connection every 1 sec., If the connection is established, then run TCP-client and send a test string.
    os_timer_disarm(&WiFiLinker);
    os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
    os_timer_arm(&WiFiLinker, 1000, 0);


Is there no one else using this bit of code? Or is everyone else having no problems with this code? (A yes/no answer to this question will be helpful too...)
User avatar
By rith87
#10749 So, I don't believe that my wifi password is incorrect for 2 reasons:

1. I have triple checked the password and I use the exact same password to connect to the wifi network.
2. The wifi connection eventually succeeds after a few minutes of retries with the same password.

What SDK is everyone else using? 0.9.5?