Hi everyone, i have been coding multiple proyects with 3 friends in multiple locations. a regular issue was changing wifi credentials every time someone wants to connect the esp32 to his local network.
As a solution i am trying to create a wifi header that contains a different wifi connection function for every given situation. a different header stores the wifi credentials, both header would then be used in all the projects we work together.
my idea was to create a structure structured to store the wifi variables required as shown below, then only pass the correct structure depending where you are. for each place we would have variables already hardcoded. this header only stores the wifi credentials, is intended to be changed is necessary.
More in details, the whole concept here is when we call the wifi initialization function, is already prepared to receive a struct containing everything, as all the struct have the same format, the function will then substract the ssid, password, ip etc and call the wifi.config and wifi.begin functions and start the wifi connection with the credentials desired. this avoids us to change multiple code lines and just change the struct sent as a parameter. i have yet not programmed this as i encountered this issue in the process.
#include "WiFi.h"
void credentials_settings();
struct wifiCredentialsFixedIP {
char *ssid;
char *password;
IPAddress local_IP();
IPAddress gateway();
IPAddress subnetMask();
IPAddress primaryDNS();
IPAddress secondaryDNS();
};
wifiCredentialsFixedIP wifiCredentialsWIP_Oficina;
void credentials_settings(){
wifiCredentialsWIP_Oficina.ssid = "";
wifiCredentialsWIP_Oficina.password = "";
//-----------problem here----------
wifiCredentialsWIP_Oficina.local_IP (192,168,0,99);
wifiCredentialsWIP_Oficina.gateway (192,168,0,1);
wifiCredentialsWIP_Oficina.subnetMask (255,255,255,0);
wifiCredentialsWIP_Oficina.primaryDNS (8,8,8,8);
wifiCredentialsWIP_Oficina.secondaryDNS (8,8,4,4);
//-----------problem here----------
}
the problem is in all the IPAdress type functions from the WiFi.h library. when i try to set the functions intellisense tells me that there is "too many arguments in function call". im not sure if the problem is on how i declared the struct or on how i am passing the parameters to the IPAddress type functions. maybe i am taking the wrong aproach on how to solve this issue and this functions are not intended to be stored or something.