Platformio issue

Async_Awayt
Posts: 14
Joined: Sun Feb 19, 2017 8:04 pm

Platformio issue

Postby Async_Awayt » Sun Feb 19, 2017 8:17 pm

Not being really happy with Eclipse programming the ESP32 I gave Platformio a shot (on a mac running Sierra).
I really like that autocomplete works on platformio making programming much easier (never got that working on eclipse even though I tried it on Windows, Ubuntu as well as on the mac.)

Anyway, the first app worked well (blinking the builtin LED on a DOIT board). However, when trying the esp-idf-template wifi example I ran out of luck.
Firstly, I get a couple of errors during the build:
- C99 designator 'ssid' outside aggregate initializer at line ...
- C99 designator 'password' outside aggregate initializer at line ...
It seemed to compile nicely in spite of that.
Second odd thing happened when trying to upload the app...it seemed to hang up for a moment at:
-Compressed 487056 bytes to 248151...
Eventually the upload would get successfully uploaded though.
Problem is that it seems to stop at the line:
- ESP_ERROR_CHECK( esp_wifi_init(&cfg) );

Not a lot of support on ESP32 programming with Platformio out there...any of you guys know how to fix the issue?

f.h-f.s.
Posts: 215
Joined: Thu Dec 08, 2016 2:53 pm

Re: Platformio issue

Postby f.h-f.s. » Fri Mar 24, 2017 12:37 pm

I've seen that error
C99 designator 'ssid' outside aggregate initializer at line ...
When I try to compile the c code in a cpp file.

You can't initialize a struct in c++ like this:

Code: Select all

    wifi_config_t wifi_config = {
        .sta = {
            .ssid = EXAMPLE_WIFI_SSID,
        },
};
It should generate an error.

Are you not getting any build errors(try to build verbose?)? Are you using cpp or c sources?

CTRL_CAIN
Posts: 2
Joined: Tue Mar 21, 2017 2:42 am

Re: Platformio issue

Postby CTRL_CAIN » Sat Mar 25, 2017 11:22 pm

f.h-f.s. wrote:I've seen that error
C99 designator 'ssid' outside aggregate initializer at line ...
When I try to compile the c code in a cpp file.

You can't initialize a struct in c++ like this:

Code: Select all

    wifi_config_t wifi_config = {
        .sta = {
            .ssid = EXAMPLE_WIFI_SSID,
        },
};
It should generate an error.

Are you not getting any build errors(try to build verbose?)? Are you using cpp or c sources?
Im also using platform IO and getting the same error when trying to configure a SOFTAP. Any clue whats going on with this or any work around?

CTRL_CAIN
Posts: 2
Joined: Tue Mar 21, 2017 2:42 am

Re: Platformio issue

Postby CTRL_CAIN » Sat Mar 25, 2017 11:24 pm

Im getting the same error when configuring wifi for SOFTAP. Any clue whats going on or a work around. c source. Thanks.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Platformio issue

Postby ESP_Angus » Mon Mar 27, 2017 12:58 am

Please see this post about rewriting struct "designated initializers" of this kind, for use from C++ code:
https://esp32.com/viewtopic.php?f=13&t= ... izer#p5942

Angus

DimaRU
Posts: 1
Joined: Sat Dec 26, 2015 7:12 pm

Re: Platformio issue

Postby DimaRU » Thu Nov 29, 2018 8:59 am

Just small magic in C++:

Code: Select all

    wifi_config_t wifi_config = {
        .sta = {
            {.ssid = EXAMPLE_WIFI_SSID},
            {.password = EXAMPLE_WIFI_PASS}
        },
    };

azz-zza
Posts: 45
Joined: Tue Sep 17, 2019 2:58 am

Re: Platformio issue

Postby azz-zza » Thu Sep 19, 2019 2:47 am

DimaRU wrote:
Thu Nov 29, 2018 8:59 am
Just small magic in C++:

Code: Select all

    wifi_config_t wifi_config = {
        .sta = {
            {.ssid = EXAMPLE_WIFI_SSID},
            {.password = EXAMPLE_WIFI_PASS}
        },
    };
Unfortunately, magic is not working:

Code: Select all

   wifi_config_t wifi_config = {
        .ap = {
            {.ssid = EXAMPLE_ESP_WIFI_SSID},
            {.ssid_len = 6 },
            // {.ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID)},
            {.password = EXAMPLE_ESP_WIFI_PASS},
            {.max_connection = EXAMPLE_MAX_STA_CONN},
            {.authmode = WIFI_AUTH_WPA_WPA2_PSK}
        },
    };

Compiling .pio/build/esp32doit-devkit-v1/src/main.o
src/main.cpp: In function 'void wifi_init_softap()':
src/main.cpp:75:5: error: name 'ssid_len' used in a GNU-style designated initializer for an array
     };
     ^
src/main.cpp:75:5: error: braces around scalar initializer for type 'uint8_t {aka unsigned char}'
Compiling .pio/build/esp32doit-devkit-v1/bootloader/bootloader_support/src/bootloader_sha.o
Compiling .pio/build/esp32doit-devkit-v1/bootloader/bootloader_support/src/bootloader_utility.o
*** [.pio/build/esp32doit-devkit-v1/src/main.o] Error 1
Compiling .pio/build/esp32doit-devkit-v1/bootloader/bootloader_support/src/efuse.o


mark.jeronimus
Posts: 6
Joined: Sun Jan 31, 2021 10:11 am

Re: Platformio issue

Postby mark.jeronimus » Wed Nov 03, 2021 10:09 am

azz-zza wrote:
Thu Sep 19, 2019 2:47 am
Unfortunately, magic is not working:

Code: Select all

   wifi_config_t wifi_config = {
        .ap = {
            {.ssid = EXAMPLE_ESP_WIFI_SSID},
            {.ssid_len = 6 },
            // {.ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID)},
            {.password = EXAMPLE_ESP_WIFI_PASS},
            {.max_connection = EXAMPLE_MAX_STA_CONN},
            {.authmode = WIFI_AUTH_WPA_WPA2_PSK}
        },
    };
Only wrap the `char[]` fields in curly brackets.

When it compiles, you still get a bunch of warnings about uninitialized members.

My suggestion below, is to turn everything into proper initializer lists rather than sticking to aggregate initializers. (This is for stations instead of access points, as that's what I happen to be working on, but the idea should be clear)

Code: Select all

 
    wifi_config_t wifi_config = { .sta =  {
        /* ssid            */ EXAMPLE_ESP_WIFI_SSID,
        /* password        */ EXAMPLE_ESP_WIFI_PASS,
        /* scan_method     */ {},
        /* bssid_set       */ {},
        /* bssid           */ {},
        /* channel         */ {},
        /* listen_interval */ {},
        /* sort_method     */ {},
        /* threshold       */ {
            /* rssi            */ {},
            /* authmode        */ WIFI_AUTH_WPA2_PSK},
        /* pmf_cfg         */ {
            /* capable         */ true,
            /* required        */ false},
        /* rm_enabled      */ {},
        /* btm_enabled     */ {},
//      /* mbo_enabled     */ {}, // For IDF 4.4 and higher
        /* reserved        */ {}
    }};
Of course, as expected, this becomes very sensitive to changes to the underlying struct, as seen by the difference between IDF 4.3 and 4.4.

Once C++20 becomes mainstream, which supports brings back C99 designators, these issues will all become naught, as the original C example will work out of the box.

Who is online

Users browsing this forum: Ask Jeeves [Bot], Bing [Bot], Majestic-12 [Bot] and 218 guests