I'm setting up a wifi connection between an ESP32 and a router. The ESP32 has a struct that holds all of the wifi config details, two of which are the SSID and password. I am having trouble setting these two if I try to use a variable.
It works if I define the strings I want using #define....sta is the struct that holds the configuration parameters, sta is unioned with another struct into the data type that is wifi_config_t....ssid and password are of type uint8_t
//These work
#define ESP_SSID "AccessPoint"
#define ESP_PASS "Pass"
//These don't work
char ESP_SSID[32] = "AccessPoint" //32 since that's max SSID length
char ESP_PASS[64] = "Pass" //64 since that's max pass length
//...later in code...
wifi_config_t wifi_config = {
.sta = {
.ssid = ESP_SSID,
.password = ESP_PASS
},
};
//...definition of .sta ...
typedef struct {
uint8_t ssid[32];
uint8_t password[64];
...
} wifi_sta_config_t;
But I am trying to make it so that I can change the SSID and Pass at run time, which is why I want to set up a variable. However, if I use the variable versions it causes these errors:
warning: initialization makes integer from pointer without a cast [-Wint-conversion]
.ssid = ESP_SSID,
^
warning: initialization makes integer from pointer without a cast [-Wint-conversion]
.password = ESP_PASS
^
error:missing braces around initializer [-Werror=missing-braces]
.sta = {
^
I am aware that this is a type miss match but I can't for the life of me figure out how to make the variable version have the same effect as the #define version!