MQTT: link to SSL only when needed.
authorEdouard Tisserant <edouard@beremiz.fr>
Thu, 01 Aug 2024 12:09:28 +0200
changeset 4001 5e0660d394e3
parent 4000 87f11a874477
child 4002 6c2b80b4515d
MQTT: link to SSL only when needed.
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])