Error Compiling

l1519066
Posts: 4
Joined: Thu Jun 28, 2018 10:35 pm

Error Compiling

Postby l1519066 » Fri Jul 06, 2018 3:28 pm

Hi,

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();
}
I understand that I don't have error checking in this. It's just a very simple version to get me going on how this stuff works. The errors are as follows

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')
I'm using Ubuntu and no IDE - just Atom text editor and terminal. I used make clean and make flash to build it.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Error Compiling

Postby WiFive » Sun Jul 08, 2018 5:26 pm

ssid_len

Who is online

Users browsing this forum: No registered users and 67 guests