Correct order of API calls to become an access point ...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Correct order of API calls to become an access point ...

Postby kolban » Tue Nov 01, 2016 9:53 pm

When looking at the API to become an access point, I see that there are three APIs of interest:
  • esp_wifi_start()
  • esp_wifi_set_config(WIFI_IF_AP, ...)
  • esp_wifi_set_mode(WIFI_MODE_AP)
My question is ... What is the correct semantic sequence for calling these functions? Is there a "state diagram" for the WiFi engine that we should be using?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Correct order of API calls to become an access point ...

Postby kolban » Wed Dec 28, 2016 1:49 am

*bump*
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

arao23
Posts: 30
Joined: Tue Dec 13, 2016 4:44 pm

Re: Correct order of API calls to become an access point ...

Postby arao23 » Fri Dec 30, 2016 10:38 pm

Set mode -> Set config -> Start works fine for me. After starting, I can switch between modes using just esp_wifi_set_mode without needing to touch anything else.

Code: Select all

	ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_AP) );

	wifi_config_t apConfig = {
			.ap = {
					.ssid="SomeSSIDHere",
					.password = "SomePasswordMoreThan8Chars",
					.ssid_len = 0,
					.channel = 0,
					.authmode = WIFI_AUTH_WPA2_PSK,
					.ssid_hidden = 0,
					.max_connection = 4, // how many clients to allow?
					.beacon_interval = 100 // default value
			}
	};

	ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &apConfig) );
	ESP_ERROR_CHECK( esp_wifi_start() );
As for a state diagram, I'm not sure, but it would be quite helpful to have one that encompasses everything from start to finish, including when the various events are raised.

Who is online

Users browsing this forum: No registered users and 297 guests