<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Read MQTT topic at app start]]></title><description><![CDATA[<p dir="auto">Hi Qts!</p>
<p dir="auto">The tasks is this - when I start my program, at first I have to read a topic from some MQTT broker for some information. Before QT I made programs using Paho MQTT, and I used a synchronous reading mode, the functions like this:</p>
<pre><code>rc = MQTTClient_receive(mqtt_client, &amp;topic_received, &amp;topic_received_len, &amp;message_received, 1000);
</code></pre>
<p dir="auto">I use QMQTT now; as far I understand it has only asynchronous reading (with a callback). But I need to read an MQTT topic right on the app start.</p>
]]></description><link>https://forum.qt.io/topic/149452/read-mqtt-topic-at-app-start</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 01:08:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/149452.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Sep 2023 11:45:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Read MQTT topic at app start on Tue, 12 Sep 2023 12:25:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qalexko">@<bdi>qAlexKo</bdi></a> said in <a href="/post/772481">Read MQTT topic at app start</a>:</p>
<blockquote>
<p dir="auto">must be more clear and be in the app contructor</p>
</blockquote>
<p dir="auto">I disagree. If you use communication like MQTT you should not do everything in a constructor of a class. Assynchronous approach is the right one, especially when using assynchronous frameworks like Qt.</p>
]]></description><link>https://forum.qt.io/post/772482</link><guid isPermaLink="true">https://forum.qt.io/post/772482</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 12 Sep 2023 12:25:40 GMT</pubDate></item><item><title><![CDATA[Reply to Read MQTT topic at app start on Tue, 12 Sep 2023 12:18:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> said in <a href="/post/772477">Read MQTT topic at app start</a>:</p>
<blockquote>
<p dir="auto">You can also do that with assynchronous APIs. But from your description it is not clear what should NOT happen until you get the result from MQTT.</p>
</blockquote>
<p dir="auto">At the start of my app I create the main app structure in memory reading from a base file. After that this structure must be tuned according the information from the MQTT topic. In the end of the contructor I set ready_fl=true;<br />
In other words I must be sure that MQTT topic had been read before the structure tuning starts.</p>
<p dir="auto">Theoretically, I can create my main structure inside MQTT callback and set ready_fl also in the callback, but I somehow don't like it - the initialization sequence must be more clear and be in the app contructor.</p>
]]></description><link>https://forum.qt.io/post/772481</link><guid isPermaLink="true">https://forum.qt.io/post/772481</guid><dc:creator><![CDATA[qAlexKo]]></dc:creator><pubDate>Tue, 12 Sep 2023 12:18:57 GMT</pubDate></item><item><title><![CDATA[Reply to Read MQTT topic at app start on Tue, 12 Sep 2023 11:47:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qalexko">@<bdi>qAlexKo</bdi></a> said in <a href="/post/772476">Read MQTT topic at app start</a>:</p>
<blockquote>
<p dir="auto">But I need to read an MQTT topic right on the app start</p>
</blockquote>
<p dir="auto">You can also do that with assynchronous APIs. But from your description it is not clear what should NOT happen until you get the result from MQTT.</p>
]]></description><link>https://forum.qt.io/post/772477</link><guid isPermaLink="true">https://forum.qt.io/post/772477</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 12 Sep 2023 11:47:56 GMT</pubDate></item></channel></rss>