Commit 96dbe3d5 authored by Eric Duminil's avatar Eric Duminil
Browse files

One pointer, two possible objects

parent 24ae465c
Pipeline #5809 passed with stage
in 2 minutes and 47 seconds
......@@ -24,9 +24,7 @@ namespace config {
# include <WiFiClientSecure.h>
#endif
//TODO: Find better way. Only one of both will be used
WiFiClientSecure secureClient;
WiFiClient espClient;
WiFiClient *espClient;
PubSubClient mqttClient;
......@@ -46,11 +44,13 @@ namespace mqtt {
if (config::mqtt_encryption) {
// The sensor doesn't check the fingerprint of the MQTT broker, because otherwise this fingerprint should be updated
// on the sensor every 3 months. The connection can still be encrypted, though:
secureClient.setInsecure(); // If not available for ESP32, please update Arduino IDE / PlatformIO
mqttClient.setClient(secureClient);
WiFiClientSecure *secureClient = new WiFiClientSecure();
secureClient->setInsecure();
espClient = secureClient;
} else {
mqttClient.setClient(espClient);
espClient = new WiFiClient();
}
mqttClient.setClient(*espClient);
mqttClient.setServer(config::mqtt_server, config::mqtt_port);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment