Page 1 of 2

How to change channel for WiFi AP into ESP32

Posted: Tue Oct 25, 2016 1:16 pm
by Ritesh
Hi,

I have tried to change WiFi AP mode channel using following code but not found any effect as still WiFi AP mode is running on default channel 1. I am working on ESP32-idf RTOS SDK.

Code: Select all

wifi_config_t ap_config = {
        .ap = {
                     .channel = 14
                 }

ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &ap_config) );  
ESP_ERROR_CHECK( esp_wifi_start() );
ESP_ERROR_CHECK( esp_wifi_connect() );
Does anyone has any idea for this issue? is there any other API to set WiFi AP mode channel from 1 to 14?

Please let me know if any other configurations or settings required for that

Re: How to change channel for WiFi AP into ESP32

Posted: Wed Oct 26, 2016 3:25 am
by WiFive

Code: Select all

system_init();
    tcpip_adapter_init();
    ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
    ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
    ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) );
    wifi_config_t ap_config = {
        .ap = {
            .channel = 6
        }
    };
    ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &ap_config) );
    ESP_ERROR_CHECK( esp_wifi_start() );
works for me. is your country code correct?

it does seem like esp_wifi_get_channel is not working.

Re: How to change channel for WiFi AP into ESP32

Posted: Wed Oct 26, 2016 4:11 am
by Ritesh
Hi,

Thanks for Reply.

Yes. You are correct that with above code I can set different channels only in AP mode WiFi configurations. Actually, I have configured AP+STA mode in which my module is going to connect with configured Router with configurations which i have set.

So, in this STA+AP mode, I have set different channels into AP configuration settings but not able to set different settings and i was getting same channel which i was getting in STA mode after connecting with configured router.

It means in STA+AP mode, WiFi channel is going to be set as per channel configured in STA mode as per Router configurations.

Please correct me if i am wrong.

Re: How to change channel for WiFi AP into ESP32

Posted: Wed Oct 26, 2016 4:31 am
by WiFive
Yes for AP+STA the channel will be the same and STA channel has to match the AP the station is connecting to.

Re: How to change channel for WiFi AP into ESP32

Posted: Wed Oct 26, 2016 9:16 am
by Ritesh
Hi,

Ok. Got it. Thanks for Reply.

Re: How to change channel for WiFi AP into ESP32

Posted: Thu May 23, 2019 3:31 pm
by snahmad75
ok, just to clarify in AP+STA mode.

I cannot set channel using

esp_wifi_set_config(WIFI_IF_AP, )

I tried out. not working for me.

Re: How to change channel for WiFi AP into ESP32

Posted: Thu May 23, 2019 6:41 pm
by Ritesh
snahmad75 wrote:
Thu May 23, 2019 3:31 pm
ok, just to clarify in AP+STA mode.

I cannot set channel using

esp_wifi_set_config(WIFI_IF_AP, )

I tried out. not working for me.
Hi,

As mentioned earlier into thread that in AP+STA mkde, AP channel will be same as STA channel in which ESP32 device will be connected with configured router or hot spot.

So, Even if you set channel into AP mode configuration then it might be changed as per router's channel.

Re: How to change channel for WiFi AP into ESP32

Posted: Fri May 24, 2019 3:51 pm
by snahmad75
What is purpose of this API

esp_wifi_set_channel to change channel.

Re: How to change channel for WiFi AP into ESP32

Posted: Fri May 24, 2019 5:56 pm
by WiFive
You can use it with promiscuous mode and esp_wifi_80211_tx

Re: How to change channel for WiFi AP into ESP32

Posted: Mon May 27, 2019 11:04 am
by snahmad75
ok, any example?