How to change channel for WiFi AP into ESP32

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

How to change channel for WiFi AP into ESP32

Postby Ritesh » Tue Oct 25, 2016 1:16 pm

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
Regards,
Ritesh Prajapati

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

Re: How to change channel for WiFi AP into ESP32

Postby WiFive » Wed Oct 26, 2016 3:25 am

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.
Last edited by WiFive on Wed Oct 26, 2016 4:30 am, edited 1 time in total.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: How to change channel for WiFi AP into ESP32

Postby Ritesh » Wed Oct 26, 2016 4:11 am

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.
Regards,
Ritesh Prajapati

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

Re: How to change channel for WiFi AP into ESP32

Postby WiFive » Wed Oct 26, 2016 4:31 am

Yes for AP+STA the channel will be the same and STA channel has to match the AP the station is connecting to.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: How to change channel for WiFi AP into ESP32

Postby Ritesh » Wed Oct 26, 2016 9:16 am

Hi,

Ok. Got it. Thanks for Reply.
Regards,
Ritesh Prajapati

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

Re: How to change channel for WiFi AP into ESP32

Postby snahmad75 » 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.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: How to change channel for WiFi AP into ESP32

Postby Ritesh » Thu May 23, 2019 6:41 pm

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.
Regards,
Ritesh Prajapati

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

Re: How to change channel for WiFi AP into ESP32

Postby snahmad75 » Fri May 24, 2019 3:51 pm

What is purpose of this API

esp_wifi_set_channel to change channel.

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

Re: How to change channel for WiFi AP into ESP32

Postby WiFive » Fri May 24, 2019 5:56 pm

You can use it with promiscuous mode and esp_wifi_80211_tx

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

Re: How to change channel for WiFi AP into ESP32

Postby snahmad75 » Mon May 27, 2019 11:04 am

ok, any example?

Who is online

Users browsing this forum: No registered users and 66 guests