Page 1 of 1
channel number for STA WiFi
Posted: Tue Dec 11, 2018 7:47 pm
by snahmad75
Hi,
I am not getting channel number
wifi_config_t sta_config;
esp_err_t esp_err = ::esp_wifi_get_config(WIFI_IF_STA, &sta_config);
if (esp_err == ESP_OK) {
sta_config.sta.channel; // 0
sta_config.sta.ssid // this work.
I am not getting channel number for joined WiFi. I do get AP chanenl number.
I try calling below method as well.
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
Re: channel number for STA WiFi
Posted: Tue Dec 11, 2018 8:14 pm
by snahmad75
I do get info when I connect to Wifi
I (4187) wifi: ap channel adjust o:1,0 n:6,0
I (4188) wifi: n:6 0, o:1 0, ap:6 0, sta:6 0, prof:1
I (4878) wifi: state: init -> auth (b0)
I (4888) wifi: state: auth -> assoc (0)
I (4899) wifi: state: assoc -> run (10)
I (4914) wifi: connected with Actiguest, channel 6
I (4915) wifi: pm start, type: 1
The correct channel. How to get channel number later.
Re: channel number for STA WiFi
Posted: Tue Dec 11, 2018 8:28 pm
by snahmad75
Also I am set my Access point channel. but it some time change to channel=6
wifi_config_t ap_config;
ap_config.ap.ssid_len = 0;
ap_config.ap.channel = 4;
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));
ESP_ERROR_CHECK(esp_wifi_start());
Re: channel number for STA WiFi
Posted: Tue Dec 11, 2018 10:58 pm
by WiFive
Ap channel has to be the same as sta channel if sta is connected. That channel is set by external ap you are connected to.
Re: channel number for STA WiFi
Posted: Tue Dec 11, 2018 11:48 pm
by snahmad75
Q# 1
wifi_config_t config;
esp_err_t esp_err = ::esp_wifi_get_config(WIFI_IF_AP, &config);
if (esp_err == ESP_OK) {
config.sta.channel; // This will give me channel number wether I am connect to STA or not. After connect to STA. channel will be STA channel.
Q #2
I can only set or change ap channel if you are not connect to any sta. Is this correct?