Platformio issue
-
- Posts: 14
- Joined: Sun Feb 19, 2017 8:04 pm
Platformio issue
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?
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?
Re: Platformio issue
I've seen that error
You can't initialize a struct in c++ like this:
It should generate an error.
Are you not getting any build errors(try to build verbose?)? Are you using cpp or c sources?
When I try to compile the c code in a cpp file.C99 designator 'ssid' outside aggregate initializer at line ...
You can't initialize a struct in c++ like this:
Code: Select all
wifi_config_t wifi_config = {
.sta = {
.ssid = EXAMPLE_WIFI_SSID,
},
};
Are you not getting any build errors(try to build verbose?)? Are you using cpp or c sources?
Re: Platformio issue
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?f.h-f.s. wrote:I've seen that errorWhen I try to compile the c code in a cpp file.C99 designator 'ssid' outside aggregate initializer at line ...
You can't initialize a struct in c++ like this:It should generate an error.Code: Select all
wifi_config_t wifi_config = { .sta = { .ssid = EXAMPLE_WIFI_SSID, }, };
Are you not getting any build errors(try to build verbose?)? Are you using cpp or c sources?
Re: Platformio issue
Im getting the same error when configuring wifi for SOFTAP. Any clue whats going on or a work around. c source. Thanks.
Re: Platformio issue
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
https://esp32.com/viewtopic.php?f=13&t= ... izer#p5942
Angus
Re: Platformio issue
Just small magic in C++:
Code: Select all
wifi_config_t wifi_config = {
.sta = {
{.ssid = EXAMPLE_WIFI_SSID},
{.password = EXAMPLE_WIFI_PASS}
},
};
Re: Platformio issue
Unfortunately, magic is not working:DimaRU wrote: ↑Thu Nov 29, 2018 8:59 amJust small magic in C++:Code: Select all
wifi_config_t wifi_config = { .sta = { {.ssid = EXAMPLE_WIFI_SSID}, {.password = EXAMPLE_WIFI_PASS} }, };
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
-
- Posts: 6
- Joined: Sun Jan 31, 2021 10:11 am
Re: Platformio issue
Only wrap the `char[]` fields in curly brackets.azz-zza wrote: ↑Thu Sep 19, 2019 2:47 amUnfortunately, 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} }, };
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 */ {}
}};
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: Google [Bot] and 248 guests