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 { ...@@ -24,9 +24,7 @@ namespace config {
# include <WiFiClientSecure.h> # include <WiFiClientSecure.h>
#endif #endif
//TODO: Find better way. Only one of both will be used WiFiClient *espClient;
WiFiClientSecure secureClient;
WiFiClient espClient;
PubSubClient mqttClient; PubSubClient mqttClient;
...@@ -46,11 +44,13 @@ namespace mqtt { ...@@ -46,11 +44,13 @@ namespace mqtt {
if (config::mqtt_encryption) { if (config::mqtt_encryption) {
// The sensor doesn't check the fingerprint of the MQTT broker, because otherwise this fingerprint should be updated // 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: // 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 WiFiClientSecure *secureClient = new WiFiClientSecure();
mqttClient.setClient(secureClient); secureClient->setInsecure();
espClient = secureClient;
} else { } else {
mqttClient.setClient(espClient); espClient = new WiFiClient();
} }
mqttClient.setClient(*espClient);
mqttClient.setServer(config::mqtt_server, config::mqtt_port); 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