changing wifi password

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

changing wifi password

Postby Jimis1 » Thu Feb 29, 2024 3:00 pm

Hi,

I have set up the https_ota_example. The password is set up through menuconfig but is there a way to change the password from inside the code calling a function or something. I couldn't find anything on the documentation

MicroController
Posts: 1704
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: changing wifi password

Postby MicroController » Thu Feb 29, 2024 3:47 pm

Documentation: https://docs.espressif.com/projects/esp ... i_config_t

The relevant code from the examples is here/here.

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: changing wifi password

Postby Jimis1 » Fri Mar 01, 2024 7:16 am

Like I said I didn't find how to change the password in the documentation. I don't see the library providing a function for that. Changing the library is not very wise since other updates might change it back

ves011
Posts: 20
Joined: Fri Oct 07, 2022 2:31 pm

Re: changing wifi password

Postby ves011 » Fri Mar 01, 2024 6:27 pm

You don't need to change anything. @MicroController pointed you to the right places.
Here is a small example

Code: Select all

bool wifi_join(const char *ssid, const char *pass, int timeout_ms)
	{
	int bits = 0;
	if(isConnected())
	    wifi_disconnect(1, NULL);
    	wifi_config_t wifi_config = { 0 };
    	strlcpy((char *) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid));
    	if (pass)
        	strlcpy((char *) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password));
    	ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
	
	esp_wifi_connect();
    	bits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
                                   pdFALSE, pdTRUE, timeout_ms / portTICK_PERIOD_MS);
    		
    	return (bits & CONNECTED_BIT) != 0;
	}

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: changing wifi password

Postby Jimis1 » Sat Mar 02, 2024 6:50 am

Thanks a lot ! That's what I was looking for!

I searched for that function and found it here :
esp-idf\examples\system\console\advanced\components\cmd_wifi\cmd_wifi.c


I will test it

Who is online

Users browsing this forum: No registered users and 95 guests