Page 1 of 1

how to config my own ip address during accesspoint mode

Posted: Wed Apr 24, 2024 5:56 pm
by davidItaly
wifi_driver.set_configuration(&wifiConfiguration::AccessPoint(AccessPointConfiguration{
ssid: nome_wifi,//"mySSID".into(),
password: pass_wifi,//"myPASSWORD".into(),
auth_method: AuthMethod::WPA,
..Default::default()
})).unwrap();

my code works well but the ip address to access the wifi esp32 is the one chooses from board, i want to set my own
what i'm wondering is how to set my ip address 192.168.1.1 when i program my board esp32 i tyed with routerconfig bu not work.

Re: how to config my own ip address during accesspoint mode

Posted: Thu Apr 25, 2024 9:24 pm
by mikemoy
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());

// Configure a static IP for the AP interface
esp_netif_ip_info_t ip_info;
IP4_ADDR(&ip_info.ip, 192, 168, 1, 1); // IP address
IP4_ADDR(&ip_info.gw, 192, 168, 1, 1); // Gateway address
IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0); // Netmask
esp_netif_t* netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
ESP_ERROR_CHECK(esp_netif_dhcps_stop(netif)); // Stop DHCP server
ESP_ERROR_CHECK(esp_netif_set_ip_info(netif, &ip_info));
ESP_ERROR_CHECK(esp_netif_dhcps_start(netif)); // Start DHCP server

Re: how to config my own ip address during accesspoint mode

Posted: Fri Apr 26, 2024 11:43 am
by davidItaly
thanks mikemoy , your code put me on right way, i adapt your code on rist with unsafe and everything works well, a problem that i face was a loop when wifi connected, connect , leave, connect,leave and so on. I fix this with erase nvs partition.