ESP32 STA configuration

Adham Aboud
Posts: 48
Joined: Mon Apr 30, 2018 5:32 pm

ESP32 STA configuration

Postby Adham Aboud » Wed Aug 22, 2018 7:35 pm

I'm trying to make ESP32 connect to AP, I''ve two different codes, one is working and the other isn't

module connects to AP when i declare the following:
wifi_config_t wifi_config_sta= {
.sta = {
.ssid = CONFIG_DEAFULT_AP_SSID,//ESP_STA_SSID,
.password = CONFIG_DEFAULT_AP_WIFI_PASSWORD//ESP_STA_PASS
},
};

module didn't connect to AP when I initialize like:
strcpy ((char*)wifi_config_sta.sta.ssid, CONFIG_DEAFULT_AP_SSID);
strcpy ((char*)wifi_config_sta.sta.password, CONFIG_DEFAULT_AP_WIFI_PASSWORD);


can anyone tell me what is the differences between this declerations?


Thank you in advance,

username
Posts: 530
Joined: Thu May 03, 2018 1:18 pm

Re: ESP32 STA configuration

Postby username » Thu Aug 23, 2018 1:46 am

Not sure. Try printing the strlen of both examples and make sure they are the same length, is where I would start.

ESP_Sprite
Posts: 9724
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 STA configuration

Postby ESP_Sprite » Thu Aug 23, 2018 3:28 am

How do you declare your wifi_config_sta variable in the 2nd example?

Adham Aboud
Posts: 48
Joined: Mon Apr 30, 2018 5:32 pm

Re: ESP32 STA configuration

Postby Adham Aboud » Thu Aug 23, 2018 4:04 am

ESP_Sprite,


This is the declaration of the wifi_config_sta variable in the second example.

wifi_config_t wifi_config_sta;

strcpy ((char*)wifi_config_sta.sta.ssid, CONFIG_DEAFULT_AP_SSID);
strcpy ((char*)wifi_config_sta.sta.password, CONFIG_DEFAULT_AP_WIFI_PASSWORD);

Adham Aboud
Posts: 48
Joined: Mon Apr 30, 2018 5:32 pm

Re: ESP32 STA configuration

Postby Adham Aboud » Thu Aug 23, 2018 4:14 am

user_name,

This is what I did first and they are the same :?

Adham Aboud
Posts: 48
Joined: Mon Apr 30, 2018 5:32 pm

Re: ESP32 STA configuration

Postby Adham Aboud » Thu Aug 23, 2018 4:36 am

ESP_Sprite,
Thank you for the hint, seems that when I declare

wifi_config_t wifi_config_sta;

the memory bloack that wifi_config_sta variable use is not 0 !!!
When I wrote:

wifi_config_t wifi_config_sta = {0};

everything work fine.


Regards,

papaluna
Posts: 50
Joined: Tue Jan 30, 2018 11:27 am

Re: ESP32 STA configuration

Postby papaluna » Thu Aug 23, 2018 7:51 am

It is recommended to use this for init:

Code: Select all

wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
--
Paul.

Who is online

Users browsing this forum: No registered users and 90 guests