So I managed to get the simple-wifi example working fine. However, my own main C code isn't compiling and I can't figure out why.
Code: Select all
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#define DEFAULT_ESP_AP_SSID "wifi"
#define DEFAULT_ESP_AP_PASS "test123"
#define MAX_STA_CONN 1
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
wifi_config_t wifi_config = {
.ap = {
.ssid = DEFAULT_ESP_AP_SSID,
.ssid.len = strlen(DEFAULT_ESP_AP_SSID),
.password = DEFAULT_ESP_AP_PASS,
.max_connection = MAX_STA_CONN,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
void app_main(){
// Initializing WiFi
esp_wifi_init(&cfg);
esp_wifi_set_mode(WIFI_MODE_AP);
esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config);
esp_wifi_start();
}
Code: Select all
In file included from /home/Jim/esp/Sample/main/SampleHome_main.c:17:0:
/home/Jim/esp/esp-idf/components/esp32/include/esp_wifi.h:182:25: error: initializer element is not constant
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
^
/home/Jim/esp/Sample/main/SampleHome_main.c:29:26: note: in expansion of macro 'WIFI_INIT_CONFIG_DEFAULT'
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
^
/home/Jim/esp/esp-idf/components/esp32/include/esp_wifi.h:182:25: note: (near initialization for 'cfg.wpa_crypto_funcs')
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
^
/home/Jim/esp/Sample/main/SampleHome_main.c:29:26: note: in expansion of macro 'WIFI_INIT_CONFIG_DEFAULT'
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
^
/home/Jim/esp/Sample/main/SampleHome_main.c:33:7: error: field name not in record or union initializer
.ssid.len = strlen(DEFAULT_ESP_AP_SSID),
^
/home/Jim/esp/Sample/main/SampleHome_main.c:33:7: note: (near initialization for 'wifi_config.ap')
/home/Jim/esp/Sample/main/SampleHome_main.c:33:19: warning: initialized field overwritten [-Woverride-init]
.ssid.len = strlen(DEFAULT_ESP_AP_SSID),
^
/home/Jim/esp/Sample/main/SampleHome_main.c:33:19: note: (near initialization for 'wifi_config.ap.ssid[0]')
/home/Jim/esp/Sample/main/SampleHome_main.c:31:9: error: missing braces around initializer [-Werror=missing-braces]
.ap = {
^
/home/Jim/esp/Sample/main/SampleHome_main.c:31:9: note: (near initialization for 'wifi_config.ap')
/home/Jim/esp/Sample/main/SampleHome_main.c:30:29: error: missing braces around initializer [-Werror=missing-braces]
wifi_config_t wifi_config = {
^
/home/Jim/esp/Sample/main/SampleHome_main.c:30:29: note: (near initialization for 'wifi_config')