Can't dynamically choose SSID, "missing braces"
Posted: Sun Dec 29, 2019 12:39 am
Morning!
I have some problems setting up the SSID config for my WiFi.
It works flawlessly with the STA/AP example by using #define, e.g.:
but when I have some dynamically generated string and try to use it like
I get some error about missing brackets:
Can someone explain what went wrong? I tried to replace with and it compiled, but the WiFi seemed to have a faulty SSID (being shown by '?' squares).
PS: Just to avoid confusion, I've shown the STA part of my code and the error, the AP part is the same and is the reason for the faulty WiFi.
Thanks in advance!
I have some problems setting up the SSID config for my WiFi.
It works flawlessly with the STA/AP example by using #define, e.g.:
Code: Select all
wifi_config_t wifi_config = {
.sta = {
.ssid = EXAMPLE_ESP_WIFI_SSID,
.password = EXAMPLE_ESP_WIFI_PASS
},
};
Code: Select all
wifi_config_t wifi_config = {
.sta = {
.ssid = generated_string,
.password = EXAMPLE_ESP_WIFI_PASS
},
};
Code: Select all
../main/wifi_client.c:750:53: warning: initialization of 'unsigned char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
wifi_config_t wifi_config = {.sta = {.ssid = partner_ssid, .password =WIFI_PASS},};
^~~~~~~~~~~~
../main/wifi_client.c:750:53: note: (near initialization for 'wifi_config.sta.ssid[0]')
../main/wifi_client.c:750:36: error: missing braces around initializer [-Werror=missing-braces]
wifi_config_t wifi_config = {.sta = {.ssid = partner_ssid, .password =WIFI_PASS},};
^
{ }
../main/wifi_client.c:750:36: error: missing braces around initializer [-Werror=missing-braces]
wifi_config_t wifi_config = {.sta = {.ssid = partner_ssid, .password =WIFI_PASS},};
^
{ }
cc1.exe: some warnings being treated as errors
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
Code: Select all
.ssid = generated_string
Code: Select all
.ssid = {generated_string}
PS: Just to avoid confusion, I've shown the STA part of my code and the error, the AP part is the same and is the reason for the faulty WiFi.
Thanks in advance!