mqtt/client.py
changeset 4012 6337c9c2c379
parent 4010 3779356cca8f
child 4014 da52eabd0e6d
--- a/mqtt/client.py	Thu Sep 05 15:55:46 2024 +0200
+++ b/mqtt/client.py	Fri Sep 13 14:26:55 2024 +0200
@@ -16,9 +16,12 @@
 # and cmake build was invoked from this directory
 PahoMqttCLibraryPath = paths.ThirdPartyPath("paho.mqtt.c", "build", "src")
 
-PahoMqttCIncludePaths = [
+frozen_path = paths.ThirdPartyPath("frozen")
+
+MqttCIncludePaths = [
     paths.ThirdPartyPath("paho.mqtt.c", "build"),  # VersionInfo.h
-    paths.ThirdPartyPath("paho.mqtt.c", "src")
+    paths.ThirdPartyPath("paho.mqtt.c", "src"),
+    frozen_path
 ]
 
 class MQTTClientEditor(ConfTreeNodeEditor):
@@ -94,6 +97,10 @@
         datatype_candidates = self.GetCTRoot().GetDataTypes()
         return datatype_candidates
 
+    def GetDataTypeInfos(self, typename):
+        tagname = "D::"+typename
+        return self.GetCTRoot().GetDataTypeInfos(tagname)
+
     def GetConfig(self):
         def cfg(path): 
             try:
@@ -150,7 +157,7 @@
 #include "beremiz.h"
 """
         config = self.GetConfig()
-        c_code += self.modeldata.GenerateC(c_path, locstr, config)
+        c_code += self.modeldata.GenerateC(c_path, locstr, config, self.GetDataTypeInfos)
 
         with open(c_path, 'w') as c_file:
             c_file.write(c_code)
@@ -164,9 +171,12 @@
 
         LDFLAGS = [' "' + os.path.join(PahoMqttCLibraryPath, static_lib) + '"'] + libs
 
-        CFLAGS = ' '.join(['-I"' + path + '"' for path in PahoMqttCIncludePaths])
-
-        return [(c_path, CFLAGS)], LDFLAGS, True
+        CFLAGS = ' '.join(['-I"' + path + '"' for path in MqttCIncludePaths])
+
+        # TODO: add frozen only if using JSON
+        frozen_c_path = os.path.join(frozen_path, "frozen.c")
+
+        return [(c_path, CFLAGS), (frozen_c_path, CFLAGS)], LDFLAGS, True
 
     def GetVariableLocationTree(self):
         current_location = self.GetCurrentLocation()