beremiz

fdf1b7c3740e
Parents bcfc55f4847a
Children 7690ec04943a
MQTT: use PLC_ID as Client_ID when not given in configuration
--- a/mqtt/mqtt_client_gen.py Fri Apr 18 14:49:15 2025 +0200
+++ b/mqtt/mqtt_client_gen.py Fri Apr 18 14:50:50 2025 +0200
@@ -373,7 +373,6 @@
name = name,
locstr = locstr,
uri = config["URI"],
- clientID = config["clientID"],
decl = "",
topics = "",
cleanup = "",
@@ -386,6 +385,10 @@
)
+ clientID = config["clientID"]
+ formatdict["clientID"] = '"'+clientID+'"' if len(clientID) > 0 else "PLC_ID"
+
+
# Use Config's "MQTTVersion" to switch between protocol version at build time
if config["UseMQTT5"]:
formatdict["decl"] += """
--- a/mqtt/mqtt_template.c Fri Apr 18 14:49:15 2025 +0200
+++ b/mqtt/mqtt_template.c Fri Apr 18 14:50:50 2025 +0200
@@ -14,6 +14,8 @@
#include "POUS.h"
+extern char *PLC_ID;
+
#define _Log(level, ...) \
{{ \
char mstr[256]; \
@@ -509,7 +511,7 @@
int __init_{locstr}(int argc,char **argv)
{{
char *uri = "{uri}";
- char *clientID = "{clientID}";
+ char *clientID = {clientID};
int rc;
MQTTClient_createOptions createOpts = MQTTClient_createOptions_initializer;