Page 1 of 1

Want to change softAP IP block

Posted: Wed Sep 22, 2021 7:41 pm
by brewmstr
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.

Re: Want to change softAP IP block

Posted: Fri Sep 24, 2021 4:03 pm
by ESP_cermak
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