From 8d8ac376754738b12cfa8bb02994b0ecca805163 Mon Sep 17 00:00:00 2001
From: Guo Wenxue <guowenxue@gmail.com>
Date: Sat, 11 Jan 2025 15:10:02 +0800
Subject: [PATCH] Update iotd to add enable switch for publish
---
project/iotd/src/conf.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/project/iotd/src/conf.c b/project/iotd/src/conf.c
index 3e7f296..da13d01 100644
--- a/project/iotd/src/conf.c
+++ b/project/iotd/src/conf.c
@@ -287,17 +287,22 @@
if( !(str=iniparser_getstring(ini, "publisher:pubTopic", NULL)) )
{
log_warn("WARNNING: Parser MQTT publisher topic failure\n");
+ return 0;
}
- else
+
+
+ mqtt_ctx->pub_enable = iniparser_getint(ini, "publisher:enable", 0);
+ if( !mqtt_ctx->pub_enable )
{
- strncpy(mqtt_ctx->pubTopic, str, sizeof(mqtt_ctx->pubTopic) );
- mqtt_ctx->pubQos = iniparser_getint(ini, "publisher:pubQos", 0);
- mqtt_ctx->interval = iniparser_getint(ini, "publisher:interval", 60);
- mqtt_ctx->pub_enable = 1;
-
- log_info("Parser publisher topic \"%s\" with Qos[%d]\n", mqtt_ctx->pubTopic, mqtt_ctx->pubQos);
+ log_warn("WARNNING: Parser MQTT publisher disabled\n");
+ return 0;
}
+ strncpy(mqtt_ctx->pubTopic, str, sizeof(mqtt_ctx->pubTopic) );
+ mqtt_ctx->pubQos = iniparser_getint(ini, "publisher:pubQos", 0);
+ mqtt_ctx->interval = iniparser_getint(ini, "publisher:interval", 60);
+
+ log_info("Parser publisher topic \"%s\" with Qos[%d]\n", mqtt_ctx->pubTopic, mqtt_ctx->pubQos);
return 0;
}
--
Gitblit v1.9.1