Now when I am wanting to POST the data, I am currently using WiFiClient ... but I want to now check the scheme (http vs. https) and then use the appropriate client.
My goal is that somehow at the beginning of my function I can chose the "client" to use by doing something like this:
// http or https?
if(!strcmp(endpointScheme, "http")) {
// Use WiFiClient class to create TCP connections
WiFiClient client;
#ifdef DEBUG
Serial.println(F("Using HTTP://"));
#endif
} else {
// Use WiFiClientSecure class to create TCP connections
WiFiClientSecure client;
#ifdef DEBUG
Serial.println(F("Using HTTPS://"));
#endif
}
If I could do this then I can simply use the "client" reference in the rest of my code, independent of it being a secure or non-secure connection. But this doesn't work.
How can I do this?
Is there a way that I can define both in advance and then assign "client" to the one that I want? If so ... then what data type is "client"?
Or can I do this?
// http or https?
WiFiClient httpClient;
WiFiClientSecure httpsClient;
if(!strcmp(endpointScheme, "http")) {
// Use WiFiClient class to create TCP connections
client = httpClient;
#ifdef DEBUG
Serial.println(F("Using HTTP://"));
#endif
} else {
// Use WiFiClientSecure class to create TCP connections
client = httpsClient;
#ifdef DEBUG
Serial.println(F("Using HTTPS://"));
#endif
}
Is there some way to do this?