<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Getting mqtt topic from a message</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91132/getting-mqtt-topic-from-a-message</link><description>This might be a dumb question. I have a pretty simple modification of the mqtt_simple sample application on an nRF9160DK where I have subscribed to multiple topics. I see the inbound messages from those topics, but I can&amp;#39;t find anywhere on the mqtt_client</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Aug 2022 11:56:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91132/getting-mqtt-topic-from-a-message" /><item><title>RE: Getting mqtt topic from a message</title><link>https://devzone.nordicsemi.com/thread/382448?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2022 11:56:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d4c286e-e706-44eb-a7a7-d6c8f41de674</guid><dc:creator>SmallerPond</dc:creator><description>&lt;p&gt;Thanks! Perfect!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting mqtt topic from a message</title><link>https://devzone.nordicsemi.com/thread/382435?ContentTypeID=1</link><pubDate>Fri, 19 Aug 2022 11:00:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a9169f0-1cf9-4eb2-854c-76db5f7964db</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It is in a struct, just not trivial to follow it:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_evt_cb_t"&gt;mqtt event callback&lt;/a&gt; -&amp;gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_evt"&gt;mqtt_evt&lt;/a&gt; -&amp;gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_publish_param"&gt;mqtt_publish_param&lt;/a&gt; -&amp;gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_publish_message"&gt;mqtt_publish_message&lt;/a&gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_publish_param"&gt;&lt;/a&gt; -&amp;gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_topic"&gt;mqtt_topic&lt;/a&gt; -&amp;gt; &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/connectivity/networking/api/mqtt.html#c.mqtt_utf8"&gt;mqtt_utf8&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So try to add this to &amp;quot;case MQTT_EVT_PUBLISH&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;printk(&amp;quot;Topic: %s\n&amp;quot;, evt-&amp;gt;param.publish.message.topic.topic.utf8);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>