About wifi STA - AP mode
Posted: Tue Mar 19, 2024 2:06 am
hi,
I am beginner of ESP.
I was trying to use STA-AP mode.
I've understood how to use each mode seperately but I wanna know how to use STA-AP mode
here's a general code I found on internet.
set mode as APSTA and configure STA and AP each and start wifi.
but I tested
set mode APSTA and configure only one, STA or AP, and start wifi.
it works. but I don't know how and why.
it supposed to be configured STA and AP, but I don't know how it works STA or AP.
and it works exactly I expected.
( i try to make a function that working as AP for opening http server and connecting with wifi as STA )
if I only configured STA or AP, I believe it works only for STA or AP not both.
if there's something I am missing please tell me.
thank you so much.
I am beginner of ESP.
I was trying to use STA-AP mode.
I've understood how to use each mode seperately but I wanna know how to use STA-AP mode
here's a general code I found on internet.
Code: Select all
// set APSTA mode
ESP_ERROR_CHECK (esp_wifi_set_mode (WIFI_MODE_APSTA));
// configure AP_config and STA_config
wifi_config_t wifi_ap_config = {
.ap = {
.ssid = SOFTAP_ESP_SSID,
.ssid_len = strlen (SOFTAP_ESP_SSID),
.channel = 1,.password = SOFTAP_ESP_PWD,
.max_connection = 4,
.authmode = WIFI_AUTH_WPA2_PSK,
.pmf_cfg = {
.required = true,
}
}
};
ESP_ERROR_CHECK (esp_wifi_set_config (WIFI_IF_AP, &wifi_ap_config));
wifi_config_t wifi_sta_config = {
};
strcpy ((char *) wifi_sta_config.sta.ssid, __SSID);
strcpy ((char *) wifi_sta_config.sta.password, __PWD);
ESP_ERROR_CHECK (esp_wifi_set_config (ESP_IF_WIFI_STA, &wifi_sta_config));
// wifi start
ESP_ERROR_CHECK (esp_wifi_start ());
but I tested
set mode APSTA and configure only one, STA or AP, and start wifi.
it works. but I don't know how and why.
it supposed to be configured STA and AP, but I don't know how it works STA or AP.
and it works exactly I expected.
( i try to make a function that working as AP for opening http server and connecting with wifi as STA )
if I only configured STA or AP, I believe it works only for STA or AP not both.
if there's something I am missing please tell me.
thank you so much.