RaspberrPi project source code
Guo Wenxue
2025-01-11 8d8ac376754738b12cfa8bb02994b0ecca805163
Update iotd to add enable switch for publish

Signed-off-by: Guo Wenxue <guowenxue@gmail.com>
2 files modified
15 ■■■■ changed files
project/iotd/etc/iotd.conf 2 ●●●●● patch | view | raw | blame | history
project/iotd/src/conf.c 13 ●●●●● patch | view | raw | blame | history
project/iotd/etc/iotd.conf
@@ -72,6 +72,8 @@
[publisher]
enable=0
pubTopic="$Sys/Studio/Uplink/"
pubQos=0
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 )
    {
        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);
        mqtt_ctx->pub_enable = 1;
        log_info("Parser publisher topic \"%s\" with Qos[%d]\n", mqtt_ctx->pubTopic, mqtt_ctx->pubQos);
    }
    return 0;
}