WIFI_MODE_APSTA Sample
-
- Posts: 2
- Joined: Mon Nov 21, 2016 3:34 am
WIFI_MODE_APSTA Sample
Will there be a sample using WIFI_MODE_APSTA?
Re: WIFI_MODE_APSTA Sample
Howdy,
What would you like to see as a sample? If you loosely thing of the ESP32 as having two distinct network interfaces ... one for connecting to an access point (the ESP32 being a station) and the other for being an access point, then you pretty much have it. What are you hoping to see in a sample that has an ESP32 being both a station and an access point?
By knowing what you'd like to see, that would give the community some guidance on what a sample should actually "do".
What would you like to see as a sample? If you loosely thing of the ESP32 as having two distinct network interfaces ... one for connecting to an access point (the ESP32 being a station) and the other for being an access point, then you pretty much have it. What are you hoping to see in a sample that has an ESP32 being both a station and an access point?
By knowing what you'd like to see, that would give the community some guidance on what a sample should actually "do".
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 2
- Joined: Mon Nov 21, 2016 3:34 am
Re: WIFI_MODE_APSTA Sample
Sorry, got distracted with another project. So I am guessing that when esp_wifi_set_mode(WIFI_MODE_APSTA) has been selected, then esp_wifi_set_config() is used separately on each interface, once with WIFI_IF_STA and once with WIFI_IF_AP.
Why would one not just always select WIFI_MODE_APSTA and subsequently configure whichever interface(s) is actually used? Does it consume additional resources or cause other limitations?
Why would one not just always select WIFI_MODE_APSTA and subsequently configure whichever interface(s) is actually used? Does it consume additional resources or cause other limitations?
Re: WIFI_MODE_APSTA Sample
Its possible that during execution, one wants to dynamically start and stop being either an access point, a station or both. I would presume that setting the mode will dynamically switch off/on any of the other modes of operation not included.
So for example, I might initially want to be an access point to get configuration information and then, once configured become a station to the access point that was dynamically selected. At that time I might want to stop being an access point.
So for example, I might initially want to be an access point to get configuration information and then, once configured become a station to the access point that was dynamically selected. At that time I might want to stop being an access point.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: WIFI_MODE_APSTA Sample
Enabling AP when not actually using it may be a bad idea for the following reasons:
1. When AP is enabled, modem sleep mode can not be used, causing higher power consumption,
2. When AP mode is enabled, extra memory is allocated for the AP control block.
1. When AP is enabled, modem sleep mode can not be used, causing higher power consumption,
2. When AP mode is enabled, extra memory is allocated for the AP control block.
Re: WIFI_MODE_APSTA Sample
Hi All,
I have been trying to setup APSTA mode without success , can anyone spot a problem. I am bit confused by this API - what should I set
esp_wifi_set_config(WIFI_IF_AP, &wifi_config) to in this case as there is no option for APSTA mode.
#define AP_EXAMPLE_WIFI_SSID "IMTIAZ\0"
#define AP_EXAMPLE_WIFI_PASS "12345678"
#define STA_EXAMPLE_WIFI_SSID "Syrp_Wireless"
#define STA_EXAMPLE_WIFI_PASS "87654321"
static void initialise_wifi(void)
{
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
wifi_config_t wifi_config = {
.sta ={
.ssid = STA_EXAMPLE_WIFI_SSID,
.password = STA_EXAMPLE_WIFI_PASS,
},
.ap = {
.ssid = AP_EXAMPLE_WIFI_SSID,
.ssid_len = 0,
.password = AP_EXAMPLE_WIFI_PASS,
.channel = 1,
.authmode = WIFI_AUTH_WPA2_PSK,
.beacon_interval = 400,
.max_connection = 16,
}
};
ESP_LOGI(TAG, "Setting WiFi AP: SSID %s", wifi_config.ap.ssid);
ESP_LOGI(TAG, " Pass %s", wifi_config.ap.password);
ESP_LOGI(TAG, "Setting WiFi STA: SSID %s", wifi_config.sta.ssid);
ESP_LOGI(TAG, " Pass %s", wifi_config.sta.password);
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_APSTA) );
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &wifi_config) );
//ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start());
}
I have been trying to setup APSTA mode without success , can anyone spot a problem. I am bit confused by this API - what should I set
esp_wifi_set_config(WIFI_IF_AP, &wifi_config) to in this case as there is no option for APSTA mode.
Code: Select all
#define AP_EXAMPLE_WIFI_PASS "12345678"
#define STA_EXAMPLE_WIFI_SSID "Syrp_Wireless"
#define STA_EXAMPLE_WIFI_PASS "87654321"
static void initialise_wifi(void)
{
tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
wifi_config_t wifi_config = {
.sta ={
.ssid = STA_EXAMPLE_WIFI_SSID,
.password = STA_EXAMPLE_WIFI_PASS,
},
.ap = {
.ssid = AP_EXAMPLE_WIFI_SSID,
.ssid_len = 0,
.password = AP_EXAMPLE_WIFI_PASS,
.channel = 1,
.authmode = WIFI_AUTH_WPA2_PSK,
.beacon_interval = 400,
.max_connection = 16,
}
};
ESP_LOGI(TAG, "Setting WiFi AP: SSID %s", wifi_config.ap.ssid);
ESP_LOGI(TAG, " Pass %s", wifi_config.ap.password);
ESP_LOGI(TAG, "Setting WiFi STA: SSID %s", wifi_config.sta.ssid);
ESP_LOGI(TAG, " Pass %s", wifi_config.sta.password);
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_APSTA) );
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_AP, &wifi_config) );
//ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start());
}
Code: Select all
Re: WIFI_MODE_APSTA Sample
Call esp_wifi_set_config() twice. Once for the settings for the station interface and a second time with the settings for the access point interface.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: WIFI_MODE_APSTA Sample
Oh - you've got be kidding me, this is union:
typedef union {
wifi_ap_config_t ap; /**< configuration of AP */
wifi_sta_config_t sta; /**< configuration of STA */
} wifi_config_t;
I dont get why its done like this - super confusing. I didnt notice this - I assumed its a struct.. I'll try again.
Thanks
typedef union {
wifi_ap_config_t ap; /**< configuration of AP */
wifi_sta_config_t sta; /**< configuration of STA */
} wifi_config_t;
I dont get why its done like this - super confusing. I didnt notice this - I assumed its a struct.. I'll try again.
Thanks
Re: WIFI_MODE_APSTA Sample
My opinion ... its a design choice ... the designers said to themselves (I guess) ... we need to provide an API to configure WiFi ... oh wait ... there are TWO WiFi interfaces on an ESP32 ... one for the station interface and one for the access point interface. Both interfaces need distinct parameters ... so ... we either provide two interfaces ... eg. esp_config_wifi_ap() and esp_config_wifi_sta() or we provide one interface esp_config_wifi() which takes as a parameter which interface to configure ... oh ... but now we need to pass in one of two distinct data type structure ... I know ... we'll union them.
I'm not sure that there is a correct answer to design choices. If one goes with the choice of a single API with two distinct parameter sets then the union structure seems to make sense.
I'm not sure that there is a correct answer to design choices. If one goes with the choice of a single API with two distinct parameter sets then the union structure seems to make sense.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: WIFI_MODE_APSTA Sample
Yeah I understand the reasoning - however the API should have better documentation so you dont have to figure these things out the hard way or by trial and error.
On a positive note I've got it to work in APSTA mode - finally
On a positive note I've got it to work in APSTA mode - finally