# HG changeset patch
# User Edouard Tisserant <edouard@beremiz.fr>
# Date 1722506968 -7200
# Node ID 5e0660d394e3de4d93f3dabc4385fdb3c9b2e9bd
# Parent  87f11a8744775091ae4380654ac899181128a21f
MQTT: link to SSL only when needed.

diff -r 87f11a874477 -r 5e0660d394e3 mqtt/client.py
--- a/mqtt/client.py	Wed Jul 24 15:14:02 2024 +0200
+++ b/mqtt/client.py	Thu Aug 01 12:09:28 2024 +0200
@@ -122,12 +122,20 @@
 #include "iec_types_all.h"
 #include "beremiz.h"
 """
+        config = self.GetConfig()
         c_code += self.modeldata.GenerateC(c_path, locstr, self.GetConfig())
 
         with open(c_path, 'w') as c_file:
             c_file.write(c_code)
 
-        LDFLAGS = [' "' + os.path.join(PahoMqttCLibraryPath, "libpaho-mqtt3cs.a") + '"', '-lssl', '-lcrypto']
+        if config["AuthType"] == "x509":
+            static_lib = "libpaho-mqtt3cs.a"
+            libs = ['-lssl', '-lcrypto']
+        else:
+            static_lib = "libpaho-mqtt3c.a"
+            libs = []
+
+        LDFLAGS = [' "' + os.path.join(PahoMqttCLibraryPath, static_lib) + '"'] + libs
 
         CFLAGS = ' '.join(['-I"' + path + '"' for path in PahoMqttCIncludePaths])