channel number for STA WiFi

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

channel number for STA WiFi

Postby snahmad75 » Tue Dec 11, 2018 7:47 pm

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));

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: channel number for STA WiFi

Postby snahmad75 » Tue Dec 11, 2018 8:14 pm

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.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: channel number for STA WiFi

Postby snahmad75 » Tue Dec 11, 2018 8:28 pm

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());

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: channel number for STA WiFi

Postby WiFive » Tue Dec 11, 2018 10:58 pm

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.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: channel number for STA WiFi

Postby snahmad75 » Tue Dec 11, 2018 11:48 pm

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?

Who is online

Users browsing this forum: Google [Bot] and 122 guests