Want to change softAP IP block

brewmstr
Posts: 2
Joined: Sun Jan 19, 2020 5:09 pm

Want to change softAP IP block

Postby brewmstr » Wed Sep 22, 2021 7:41 pm

How can I change the IP block used dhcps in softAP mode? The default 192.168.4.x is the same subnet used by the Amazon EERO router and is playing havoc with networking when both AP and STA modes are active.

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

Re: Want to change softAP IP block

Postby ESP_cermak » Fri Sep 24, 2021 4:03 pm

Hi brewmstr

Instead of creating the default wifi interface, you can create a custom one using `esp_netif_create_wifi()`

Code: Select all

const esp_netif_ip_info_t my_subnet_ip = {
        .ip = { .addr = ESP_IP4TOADDR( 192, 168, xxx, 1) },
        .gw = { .addr = ESP_IP4TOADDR( 192, 168, xxx, 1) },
        .netmask = { .addr = ESP_IP4TOADDR( 255, 255, 255, 0) },
};
esp_netif_inherent_config_t cfg = ESP_NETIF_INHERENT_DEFAULT_WIFI_AP();
cfg.ip_info = & my_subnet_ip;
esp_netif_create_wifi(WIFI_IF_AP, &cfg);
esp_wifi_set_default_wifi_ap_handlers();
You can find some examples of usage in the below links to the test/sample codes of IDF:
https://github.com/espressif/esp-idf/bl ... tif.c#L249
https://github.com/espressif/esp-idf/bl ... .c#L41-L45

Who is online

Users browsing this forum: HighVoltage and 153 guests