Configuring Wifi Station mode for ESP32

Anjusha
Posts: 12
Joined: Tue Oct 30, 2018 7:25 am

Configuring Wifi Station mode for ESP32

Postby Anjusha » Sat Nov 03, 2018 11:21 am

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


Scheams
Posts: 1
Joined: Sat Sep 08, 2018 12:41 pm

Re: Configuring Wifi Station mode for ESP32

Postby Scheams » Sat Nov 03, 2018 5:33 pm

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.

Who is online

Users browsing this forum: No registered users and 147 guests