Page 1 of 1

Configuring Wifi Station mode for ESP32

Posted: Sat Nov 03, 2018 11:21 am
by Anjusha
Hi,
I am getting an error during configuration of Wifi station mode , it is not getting connected to the given ssid and passwrd. .Please refer the below code

The ssid and passwrd has the valid data.

wifi_config_t sta_config ;
for(i=0;i<30;i++)
{
sta_config.sta.ssid = ssid;
sta_config.sta.password=passwrd;
}

but if I replace the above with hardcoded ssid and passwrd as given below it connects to the router immediately.

wifi_config_t sta_config = {
.sta = {
.ssid = "excellence",
.password = "vk123456"
},
};


Cant understand what is the issue ,I monitored the sta_config.sta.password & sta_config.sta.ssid strings both gives same value.But the first code snippet doesnt work. Pleaes help

Re: Configuring Wifi Station mode for ESP32

Posted: Sat Nov 03, 2018 1:03 pm
by WiFive

Re: Configuring Wifi Station mode for ESP32

Posted: Sat Nov 03, 2018 5:33 pm
by Scheams
If you are using that structure as local variables, it will be uninitialized. Maybe this is your problem, because values inside this structure contain garbage values.

Code: Select all

wifi_config_t sta_config = {0};

for (int i = 0; i < 30; i++) {
    sta_config.sta.ssid[i] = ssid[i];
    sta_config.sta.password[i] = password[i];
}
Maybe try it with an initialization like shown in the code above.