361 if config["UseMQTT5"]: |
361 if config["UseMQTT5"]: |
362 formatdict["decl"] += """ |
362 formatdict["decl"] += """ |
363 #define USE_MQTT_5""".format(**config) |
363 #define USE_MQTT_5""".format(**config) |
364 |
364 |
365 AuthType = config["AuthType"] |
365 AuthType = config["AuthType"] |
366 print(config) |
|
367 if AuthType == "x509": |
366 if AuthType == "x509": |
368 for k in ["KeyStore","TrustStore"]: |
367 for k in ["KeyStore","TrustStore"]: |
369 config[k] = '"'+config[k]+'"' if config[k] else "NULL" |
368 config[k] = '"'+config[k]+'"' if config[k] else "NULL" |
370 formatdict["init"] += """ |
369 formatdict["init"] += """ |
371 INIT_x509({Verify:d}, {KeyStore}, {TrustStore})""".format(**config) |
370 INIT_x509({Verify:d}, {KeyStore}, {TrustStore})""".format(**config) |
380 INIT_NoAuth()""" |
379 INIT_NoAuth()""" |
381 |
380 |
382 for row in self["output"]: |
381 for row in self["output"]: |
383 Topic, QoS, _Retained, iec_type, iec_number = row |
382 Topic, QoS, _Retained, iec_type, iec_number = row |
384 Retained = 1 if _Retained=="True" else 0 |
383 Retained = 1 if _Retained=="True" else 0 |
385 C_type, iec_size_prefix = MQTT_IEC_types[iec_type] |
384 if iec_type in MQTT_IEC_types: |
386 c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number) |
385 C_type, iec_size_prefix = MQTT_IEC_types[iec_type] |
|
386 c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number) |
|
387 else: |
|
388 C_type = iec_type.upper(); |
|
389 c_loc_name = "__Q" + locstr + "_" + str(iec_number) |
|
390 |
387 |
391 |
388 formatdict["decl"] += """ |
392 formatdict["decl"] += """ |
389 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) |
393 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) |
390 formatdict["init_pubsub"] += """ |
394 formatdict["init_pubsub"] += """ |
391 INIT_PUBLICATION({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals()) |
395 INIT_PUBLICATION({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals()) |
395 PUBLISH_CHANGE({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals()) |
399 PUBLISH_CHANGE({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals()) |
396 |
400 |
397 # inputs need to be sorted for bisection search |
401 # inputs need to be sorted for bisection search |
398 for row in sorted(self["input"]): |
402 for row in sorted(self["input"]): |
399 Topic, QoS, iec_type, iec_number = row |
403 Topic, QoS, iec_type, iec_number = row |
400 C_type, iec_size_prefix = MQTT_IEC_types[iec_type] |
404 if iec_type in MQTT_IEC_types: |
401 c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number) |
405 C_type, iec_size_prefix = MQTT_IEC_types[iec_type] |
|
406 c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number) |
|
407 else: |
|
408 C_type = iec_type.upper(); |
|
409 c_loc_name = "__I" + locstr + "_" + str(iec_number) |
|
410 |
402 formatdict["decl"] += """ |
411 formatdict["decl"] += """ |
403 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) |
412 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals()) |
404 formatdict["topics"] += """ |
413 formatdict["topics"] += """ |
405 INIT_TOPIC({Topic}, {iec_type}, {c_loc_name})""".format(**locals()) |
414 INIT_TOPIC({Topic}, {iec_type}, {c_loc_name})""".format(**locals()) |
406 formatdict["init_pubsub"] += """ |
415 formatdict["init_pubsub"] += """ |