add ap channel config
parent
7c27a6dd16
commit
d967506b19
|
@ -31,6 +31,12 @@ config ESP_WIFI_AP_PASSWORD
|
|||
help
|
||||
AP password for WPA2 or empty for Open.
|
||||
|
||||
config ESP_WIFI_AP_CHANNEL
|
||||
string "WiFi AP Channel"
|
||||
default ""
|
||||
help
|
||||
AP channel for better connection performance.
|
||||
|
||||
config SERVER_IP
|
||||
string "WiFi AP IP Address"
|
||||
default "192.168.4.1"
|
||||
|
|
|
@ -45,7 +45,9 @@
|
|||
#define EXAMPLE_ESP_MAXIMUM_RETRY CONFIG_ESP_MAXIMUM_RETRY
|
||||
#define EXAMPLE_ESP_WIFI_AP_SSID CONFIG_ESP_WIFI_AP_SSID
|
||||
#define EXAMPLE_ESP_WIFI_AP_PASS CONFIG_ESP_WIFI_AP_PASSWORD
|
||||
#define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN
|
||||
#define EXAMPLE_IP_ADDR CONFIG_SERVER_IP
|
||||
#define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
|
||||
|
||||
static const char *TAG = "camera wifi";
|
||||
|
||||
|
@ -108,11 +110,16 @@ void wifi_init_softap()
|
|||
snprintf((char*)wifi_config.ap.ssid, 32, "%s", EXAMPLE_ESP_WIFI_AP_SSID);
|
||||
wifi_config.ap.ssid_len = strlen((char*)wifi_config.ap.ssid);
|
||||
snprintf((char*)wifi_config.ap.password, 64, "%s", EXAMPLE_ESP_WIFI_AP_PASS);
|
||||
wifi_config.ap.max_connection = 1;
|
||||
wifi_config.ap.max_connection = EXAMPLE_MAX_STA_CONN;
|
||||
wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;
|
||||
if (strlen(EXAMPLE_ESP_WIFI_AP_PASS) == 0) {
|
||||
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||
}
|
||||
if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) {
|
||||
int channel;
|
||||
sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel);
|
||||
wifi_config.ap.channel = channel;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
|
||||
|
||||
|
|
|
@ -18,6 +18,12 @@ config MAX_STA_CONN
|
|||
help
|
||||
Max number of the STA connects to AP.
|
||||
|
||||
config ESP_WIFI_AP_CHANNEL
|
||||
string "WiFi AP Channel"
|
||||
default ""
|
||||
help
|
||||
AP channel for better connection performance.
|
||||
|
||||
config SERVER_IP
|
||||
string "IP address of server"
|
||||
default "192.168.4.1"
|
||||
|
|
|
@ -41,6 +41,7 @@ static const char *TAG = "app_wifi";
|
|||
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
|
||||
#define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN
|
||||
#define EXAMPLE_IP_ADDR CONFIG_SERVER_IP
|
||||
#define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
|
||||
|
||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||
{/*{{{*/
|
||||
|
@ -112,6 +113,11 @@ static void wifi_init_softap()
|
|||
wifi_config.ap.ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID);
|
||||
wifi_config.ap.max_connection = EXAMPLE_MAX_STA_CONN;
|
||||
wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK;
|
||||
if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) {
|
||||
int channel;
|
||||
sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel);
|
||||
wifi_config.ap.channel = channel;
|
||||
}
|
||||
if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
|
||||
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,12 @@ config MAX_STA_CONN
|
|||
help
|
||||
Max number of the STA connects to AP.
|
||||
|
||||
config ESP_WIFI_AP_CHANNEL
|
||||
string "WiFi AP Channel"
|
||||
default ""
|
||||
help
|
||||
AP channel for better connection performance.
|
||||
|
||||
config SERVER_IP
|
||||
string "IP address of server"
|
||||
default "192.168.4.1"
|
||||
|
|
|
@ -41,6 +41,7 @@ static const char *TAG = "app_wifi";
|
|||
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
|
||||
#define EXAMPLE_MAX_STA_CONN CONFIG_MAX_STA_CONN
|
||||
#define EXAMPLE_IP_ADDR CONFIG_SERVER_IP
|
||||
#define EXAMPLE_ESP_WIFI_AP_CHANNEL CONFIG_ESP_WIFI_AP_CHANNEL
|
||||
|
||||
static esp_err_t event_handler(void *ctx, system_event_t *event)
|
||||
{/*{{{*/
|
||||
|
@ -115,6 +116,11 @@ static void wifi_init_softap()
|
|||
if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
|
||||
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||
}
|
||||
if (strlen(EXAMPLE_ESP_WIFI_AP_CHANNEL)) {
|
||||
int channel;
|
||||
sscanf(EXAMPLE_ESP_WIFI_AP_CHANNEL, "%d", &channel);
|
||||
wifi_config.ap.channel = channel;
|
||||
}
|
||||
|
||||
esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
|
|
Loading…
Reference in New Issue