<?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>MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/122814/mqtt-simple-example-code-api-based</link><description>Hi Team, 
 
 We are using nRF9160 MQTT sample code &amp;#39;mqtt_simple&amp;#39;. 
 1. What is the maximum payload we can send in one single PUBLISH? 
 2. I want to send 4KB of data in single PUBLISH, is this possible? if not, what is the way to send 4KB in single PUBLISH</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Oct 2025 06:53:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/122814/mqtt-simple-example-code-api-based" /><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/552320?ContentTypeID=1</link><pubDate>Fri, 24 Oct 2025 06:53:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f27465e-2754-496f-8b69-5ae0dadbefdb</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="dejans"]The modem is doing retransmissions on the TCP (not MQTT) level. I will check internally how many retries there could be and get back to you.[/quote]
&lt;p&gt;TCP has 10 retransmissions, and this is not configurable in the application.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/552278?ContentTypeID=1</link><pubDate>Thu, 23 Oct 2025 14:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06c426f5-dbdb-4e3e-8e3d-bc25eb6f6a88</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="sravan.rikka"]1. Assume we have chosen QoS as 1 and our device is publishing data but the broker is down then as per QoS1 theory, when there is no ACK from broker client(device) will retry until get the ACK, how many time nRF9160 modem will retry? Is this retry count is configurable? This retry is handled by stack/library files itself right?(I mean nothing to do in application level)[/quote]
&lt;p&gt;The modem is doing retransmissions on the TCP (not MQTT) level. I will check internally how many retries there could be and get back to you.&lt;/p&gt;
[quote user="sravan.rikka"]2. Want to keep nRF9160 in sleep mode and wakeup based on wakeup interrupt, is there any api function to keep in sleep mode? can you share sleep mode example code path in SDK 3.1.0.[/quote]
&lt;p&gt;Modem can be put in low power state by entering PSM or by being turned off. There is lte_lc API for doing this.&lt;/p&gt;
[quote user="sravan.rikka"]3. We have subscribe for a topic and got the&amp;nbsp;MQTT_EVT_PUBLISH event when received subscribe data, is this the correct event to check subscribe payload? I am searching for SUBSCIBE event but didn&amp;#39;t find it.[/quote]
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_mqtt_socket.html#ga0071fe013b9920711456ef51cc3e6d91"&gt;MQTT_EVT_PUBLISH&lt;/a&gt;&amp;nbsp;is publishing event which is received when message is published on a topic client has subscribed to. Payload can be read using&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-latest/page/group_mqtt_socket.html#ga3559cdd6093d75c6fe6792ec2a453172"&gt;mqtt_read_publish_payload()&lt;/a&gt;.&lt;/p&gt;
[quote user="sravan.rikka"]As a code flow first we have to publish payload and then wait for the subscribe data, is this correct? or wait for subscribe data and then publish payload?[/quote]
&lt;p&gt;If device wants to read published payload, it needs to be subscribed beforehand.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/552097?ContentTypeID=1</link><pubDate>Tue, 21 Oct 2025 16:54:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e0b49fb-e0ff-4cf3-8d03-f093aa302c4b</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Assume we have chosen QoS as 1 and our device is publishing data but the broker is down then as per QoS1 theory, when there is no ACK from broker client(device) will retry until get the ACK, how many time nRF9160 modem will retry? Is this retry count is configurable? This retry is handled by stack/library files itself right?(I mean nothing to do in application level)&lt;/p&gt;
&lt;p&gt;2. Want to keep nRF9160 in sleep mode and wakeup based on wakeup interrupt, is there any api function to keep in sleep mode? can you share sleep mode example code path in SDK 3.1.0.&lt;/p&gt;
&lt;p&gt;3. We have subscribe for a topic and got the&amp;nbsp;MQTT_EVT_PUBLISH event when received subscribe data, is this the correct event to check subscribe payload? I am searching for SUBSCIBE event but didn&amp;#39;t find it.&lt;/p&gt;
&lt;p&gt;As a code flow first we have to publish payload and then wait for the subscribe data, is this correct? or wait for subscribe data and then publish payload?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/545027?ContentTypeID=1</link><pubDate>Fri, 08 Aug 2025 08:33:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:533b60cf-2f51-41fb-8590-49c1b3ba1b73</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Have you seen the edit in my previous reply? Can you double-check if the link is turned off in described way?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="sravan.rikka"]Can you provide modem trace for further analysis? How to get this, please provide procedure.[/quote]
&lt;p&gt;Please have a look at following resources&lt;br /&gt;&lt;a href="https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/lessons/lesson-7-cellular-fundamentals/topic/lesson-7-modem-trace/"&gt;modem trace&lt;/a&gt;&lt;br /&gt;&lt;a href="https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/lessons/lesson-7-cellular-fundamentals/topic/lesson-7-exercise-1/"&gt;capturing modem trace&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/device_guides/nrf91/nrf91_snippet.html"&gt;snippets for nrf91 series&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/modem/nrf_modem_lib/nrf_modem_lib_trace.html"&gt;modem trace module&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrf-connect-cellularmonitor/page/index.html"&gt;cellular monitor&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrf-connect-cellularmonitor/page/capturing.html"&gt;capturing modem trace&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-trace/guides/tracing_9160_modem_trace.html#enabling-tracing-in-the-application"&gt;enable tracing in the application&lt;/a&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/nrfutil/page/nrfutil-trace/guides/tracing_9160_modem_trace.html#capturing-the-modem-trace"&gt;capturing modem trace using nrfutil&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/545020?ContentTypeID=1</link><pubDate>Fri, 08 Aug 2025 07:34:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0c8fb25-131b-4c7d-8310-b2c88a9a73d8</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, I am using &amp;quot;lte_lc library API&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you provide modem trace for further analysis? How to get this, please provide procedure.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544800?ContentTypeID=1</link><pubDate>Wed, 06 Aug 2025 13:50:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f8cb57d-21ce-4c58-b5a3-18e69092db56</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;Do you use&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/nrf-apis-latest/page/group_lte_lc.html"&gt;lte_lc library API&lt;/a&gt; in your application?&lt;br /&gt;&lt;br /&gt;Can you provide modem trace for further analysis?&lt;br /&gt;&lt;br /&gt;EDIT:&lt;br /&gt;You must use lte_lc_deinit to turn off the link if you also use lte_lc&amp;nbsp; to set CFUN=1.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544760?ContentTypeID=1</link><pubDate>Wed, 06 Aug 2025 11:02:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad9fe39e-bb16-4b32-8876-f36520ab5fd4</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not making two many calls in an hour, I am making call for every 30minutes, 1st call is successful but second call is not connecting to network. Please suggest how can I resolve this issue.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544220?ContentTypeID=1</link><pubDate>Thu, 31 Jul 2025 12:36:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a8baa21-de4f-40b3-8598-a747e550e845</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;There is a limitation on a number of connection requests. It could be that you are exceeding number of connection attempts per hour. You can get more information in this&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/99094/nrf9160-modem-stuck-in-searching-after-several-successful-lte-m-connections"&gt;discussion&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544163?ContentTypeID=1</link><pubDate>Thu, 31 Jul 2025 05:24:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72e19896-9122-45bf-83f7-3b8838faa13a</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8738.nrf_5F00_log.txt"&gt;devzone.nordicsemi.com/.../8738.nrf_5F00_log.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please check the attached log.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544114?ContentTypeID=1</link><pubDate>Wed, 30 Jul 2025 14:18:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0812e5e-7d0b-4a13-8ab3-5c98b98db9b5</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Can you share complete log that shows the error &amp;quot;&amp;quot;mqtt_simple: Failed to establish LTE connection: -120&amp;quot;.&amp;nbsp;(#define EALREADY 120&lt;span&gt; &lt;/span&gt;/* Socket already connected */).&amp;quot;?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/544084?ContentTypeID=1</link><pubDate>Wed, 30 Jul 2025 12:38:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7b0be48-1506-4dc4-a785-32de2ddd9b7e</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the support to resolving float value issue.&lt;/p&gt;
&lt;p&gt;I have added&amp;nbsp;CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y in the .prj as you suggested, now I can see the float values in the buffer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Queries:&lt;/p&gt;
&lt;p&gt;1. I am connecting to the network only at power ON and making continuous calls for every 30min to the MQTT broker successfully. Now I am implementing that&amp;nbsp;connect to the network and publish the data then disconnect from the network for every call. Hence, I have implemented socket close as below and got response as &amp;#39;ret=0&amp;#39; for &amp;quot;ret = zsock_close(socketfd);&amp;quot;&amp;nbsp; but when I connect to the network again for the second call getting error as &amp;quot;mqtt_simple: Failed to establish LTE connection: -120&amp;quot;.&amp;nbsp;(#define EALREADY 120&lt;span&gt; &lt;/span&gt;/* Socket already connected */).&lt;/p&gt;
&lt;p&gt;Can you suggest, how to resolve this issue.&lt;/p&gt;
&lt;p&gt;function()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;err = mqtt_disconnect(&amp;amp;client);&lt;br /&gt; k_sleep(K_MSEC(2000u));&lt;br /&gt; printk(&amp;quot;mqtt_disconnect:%d\n&amp;quot;, err);&lt;br /&gt; current_state = STATE_EXIT;&lt;/p&gt;
&lt;p&gt;k_sleep(K_MSEC(200u));&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;close_socket();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void close_socket(void)&lt;br /&gt;{&lt;br /&gt; int err;&lt;br /&gt; int socketfd = 0;&lt;/p&gt;
&lt;p&gt;int ret;&lt;/p&gt;
&lt;p&gt;socketfd = zsock_socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);&lt;br /&gt; &lt;span&gt;ret =&amp;nbsp;&lt;/span&gt;zsock_close(socketfd);&lt;/p&gt;
&lt;p&gt;printk(&amp;quot;zsock_close:%d\r\n&amp;quot;, ret);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;err = at_cmd_write(AT_CFUN_OFF_RADIO_CMD, NULL, 0, NULL);&lt;br /&gt; k_sleep(K_MSEC(20u));&lt;br /&gt; if(err &amp;lt; 0)&lt;br /&gt; printk(&amp;quot;Failed AT_CFUN_OFF_RADIO_CMD\r\n&amp;quot;);&lt;br /&gt; else&lt;br /&gt; printk(&amp;quot;Success AT_CFUN_OFF_RADIO_CMD\r\n&amp;quot;);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/543339?ContentTypeID=1</link><pubDate>Wed, 23 Jul 2025 11:48:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9b66c56-e69f-46e3-a566-5c533801b5cb</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;I have tested in NCS v3.0.2, not in NCS v1.7.0. I am sorry that I forgot to mention this. In your case, it should be correct to use&amp;nbsp;&lt;span&gt;#include &amp;lt;sys/printk.h&amp;gt;&amp;nbsp;&lt;/span&gt;instead of&amp;nbsp;&lt;br /&gt;#include &amp;lt;zephyr/sys/printk.h&amp;gt;.&lt;br /&gt;You could try to use&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/develop/languages/c/newlib.html"&gt;Newlib&lt;/a&gt;. You can look at&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/develop/languages/c/newlib.html#types_of_newlib"&gt;types of Newlib&lt;/a&gt;&amp;nbsp;and its&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/develop/languages/c/newlib.html#formatted_output"&gt;formatted output&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/543182?ContentTypeID=1</link><pubDate>Tue, 22 Jul 2025 12:37:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af9d8d95-2fe2-48c4-a121-3bab2411ccfa</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Dejan,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have added #include &amp;lt;zephyr/sys/printk.h&amp;gt; but got compilation error as &amp;quot;zephyr/sys/printk.h: No such file or directory&amp;quot;. then searched for printk.h and found that it was added like&amp;nbsp;#include &amp;lt;sys/printk.h&amp;gt; and added same and no compilation error but still not seeing float values in snprintf buffer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Tried adding&amp;nbsp;CONFIG_PICOLIBC=y and CONFIG_PICOLIBC_IO_FLOAT=y in .prj but code is not loading after adding these configuration, after removing able to load code. So, unable to add these to config, is there any other way to add it? please guide and help to resolve this issue.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542625?ContentTypeID=1</link><pubDate>Wed, 16 Jul 2025 10:11:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b35a1e96-fe6f-49d3-8609-4fe8e6889f44</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;You can try to add this header file&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/sys/printk.h&amp;gt;&lt;/pre&gt;&lt;br /&gt;and these Kconfig options&amp;nbsp;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PICOLIBC=y
CONFIG_PICOLIBC_IO_FLOAT=y
&lt;/pre&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542563?ContentTypeID=1</link><pubDate>Tue, 15 Jul 2025 16:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d1ead4-392f-4318-b927-e37deb2b1209</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Not yet, I will check broker side limitations.&lt;/p&gt;
&lt;p&gt;2. For me it is not working, I am using &amp;#39;mqtt simple&amp;#39; example code. Please suggest me how to resolve this. Below are the header files in the main file. Do we need to add any other header file?&lt;/p&gt;
&lt;p&gt;#include &amp;lt;zephyr.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;drivers/uart.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;lt;random/rand32.h&amp;gt;&lt;br /&gt;#include &amp;lt;net/mqtt.h&amp;gt;&lt;br /&gt;#include &amp;lt;net/socket.h&amp;gt;&lt;br /&gt;#include &amp;lt;modem/at_cmd.h&amp;gt;&lt;br /&gt;#include &amp;lt;modem/lte_lc.h&amp;gt;&lt;br /&gt;#include &amp;lt;logging/log.h&amp;gt;&lt;br /&gt;#if defined(CONFIG_MODEM_KEY_MGMT)&lt;br /&gt;#include &amp;lt;modem/modem_key_mgmt.h&amp;gt;&lt;br /&gt;#endif&lt;br /&gt;#if defined(CONFIG_LWM2M_CARRIER)&lt;br /&gt;#include &amp;lt;lwm2m_carrier.h&amp;gt;&lt;br /&gt;#endif&lt;br /&gt;#include &amp;lt;dk_buttons_and_leds.h&amp;gt;&lt;/p&gt;
&lt;p&gt;#include &amp;quot;certificates.h&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542485?ContentTypeID=1</link><pubDate>Tue, 15 Jul 2025 08:32:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41d4ae88-7c6c-4a81-ab72-a003aaf53cbd</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;/p&gt;
[quote user="sravan.rikka"]1. In our application we will store 5000 records and each record of size 1429, hence total bytes=&lt;span&gt;5000&amp;nbsp;*&amp;nbsp; &amp;nbsp; &amp;nbsp; 1429=7145000. Hence, we are planning to transfer 7.145MB in single MQTT publish. It is possible right?&lt;/span&gt;[/quote]
&lt;p&gt;Have you checked if there are any limitations on the broker side?&lt;/p&gt;
[quote user="sravan.rikka"]&lt;p&gt;&lt;span&gt;2. When I am copying float value into buf using sprintf I am not seeing any value in the buffer, why? whereas %d is working but %f is not working. Am I missing anything, please advice.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;float ambientTemperature = 24.5;&lt;br /&gt;len = snprintf(buf, sizeof(buf), &amp;quot;ambientTemperature=%f&amp;quot;, ambientTemperature);&lt;br /&gt;printk(buf);&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I have used the following sample which correctly displays ambientTemperature value from the buffer buf. &lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdio.h&amp;gt;

char buf[200];
int len;

int main(void)
{
    float ambientTemperature = 24.5;
    len = snprintf(buf, sizeof(buf), &amp;quot;ambientTemperature=%f&amp;quot;, ambientTemperature);
    printf(&amp;quot;buffer value is %s&amp;quot;, buf);
}&lt;/pre&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542377?ContentTypeID=1</link><pubDate>Mon, 14 Jul 2025 11:52:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef6da9b4-16f0-48ec-86d8-2da7aa7526d5</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please respond to below queries I am waiting for your responses. Thank you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. In our application we will store 5000 records and each record of size 1429, hence total bytes=&lt;span&gt;5000&amp;nbsp;*&amp;nbsp; &amp;nbsp; &amp;nbsp; 1429=7145000. Hence, we are planning to transfer 7.145MB in single MQTT publish. It is possible right?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. When I am copying float value into buf using sprintf I am not seeing any value in the buffer, why? whereas %d is working but %f is not working. Am I missing anything, please advice.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;float ambientTemperature = 24.5;&lt;br /&gt;len = snprintf(buf, sizeof(buf), &amp;quot;ambientTemperature=%f&amp;quot;, ambientTemperature);&lt;br /&gt;printk(buf);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1752232205971v1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sravan Rikka&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542349?ContentTypeID=1</link><pubDate>Mon, 14 Jul 2025 09:38:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4041994-386b-49a7-80c1-79787a5460d0</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am using tago.io broker.&lt;/p&gt;
&lt;p&gt;I am saying that snprintf itself not copying the float value into buffer when I use %f.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542341?ContentTypeID=1</link><pubDate>Mon, 14 Jul 2025 09:07:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72ffb1a1-eaab-439f-bda6-0420ea876361</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;Which MQTT broker do you use?&lt;br /&gt;&lt;br /&gt;If you use picolib, ensure that PICOLIB_IO_FLOAT is enabled.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542339?ContentTypeID=1</link><pubDate>Mon, 14 Jul 2025 08:59:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3508d135-e3b4-496d-b201-e9bc821813c3</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please respond to above queries.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542226?ContentTypeID=1</link><pubDate>Fri, 11 Jul 2025 11:11:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ccf7158-86f9-4ee8-a7d7-5231a0d71cb4</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. In our application we will store 5000 records and each record of size 1429, hence total bytes=&lt;span&gt;5000&amp;nbsp;*&amp;nbsp; &amp;nbsp; &amp;nbsp; 1429=7145000. Hence, we are planning to transfer 7.145MB in single MQTT publish. It is possible right?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. When I am copying float value into buf using sprintf I am not seeing any value in the buffer, why? whereas %d is working but %f is not working. Am I missing anything, please advice.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;float ambientTemperature = 24.5;&lt;br /&gt; len = snprintf(buf, sizeof(buf), &amp;quot;ambientTemperature=%f&amp;quot;, ambientTemperature);&lt;br /&gt; printk(buf);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1752232205971v1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542127?ContentTypeID=1</link><pubDate>Thu, 10 Jul 2025 13:56:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4df5b04d-4f4b-43db-8b35-5493ae3b8d28</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;The size of MQTT publish message is not limited by the modem. Can you provide details about your setup?&lt;br /&gt;&lt;br /&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/bootloaders_dfu/mcuboot_nsib/bootloader.html#immutable_bootloader"&gt;Immutable bootloader&lt;/a&gt;&amp;nbsp;cannot be altered or deleted without erasing whole device.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542113?ContentTypeID=1</link><pubDate>Thu, 10 Jul 2025 12:30:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff42cdb5-25ae-4bcb-a463-a03b07e7d49f</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I think MQTT specification says max publish size is 256MB. We can publish maximum 256MB in single publish, am I correct?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I want o send 100MB of data, can I increase below message buffer size to 100MB?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#define CONFIG_MQTT_MESSAGE_BUFFER_SIZE 100MB&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;is this &amp;quot;secure immutable bootloader&amp;quot; available for us to add some piece of code in it?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542109?ContentTypeID=1</link><pubDate>Thu, 10 Jul 2025 12:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06175734-b511-4ebb-ba92-1b48c78efe14</guid><dc:creator>dejans</dc:creator><description>&lt;p&gt;Hi Sravan,&lt;br /&gt;&lt;br /&gt;There is no PUBLISH MQTT message limitation in your case and any amount of data can be sent. You can try to increase message buffer size if needed.&lt;br /&gt;&lt;br /&gt;There is no boot ROM but there is&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-3.0.0/page/nrf/samples/bootloader/README.html"&gt;nRF Secure Immutable Bootloader&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Dejan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MQTT simple example code (api based)</title><link>https://devzone.nordicsemi.com/thread/542065?ContentTypeID=1</link><pubDate>Thu, 10 Jul 2025 09:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b2acbfc-710a-40bb-b26e-0f3d625a5d07</guid><dc:creator>sravan.rikka</dc:creator><description>&lt;p&gt;Hi Dejans,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For my 1 and 2 queries:&lt;/p&gt;
&lt;p&gt;I have looked at your suggested links and it is talking about TLS but I am not using TLS, I am using nonsecure MQTT.&lt;/p&gt;
&lt;p&gt;For non-secure MQTT also 2KB is the limit in single publish?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In MQTT simple code I can see&amp;nbsp;&lt;span&gt;tx_buffer and&amp;nbsp;rx_buffer size as 128 bytes, can I make it to 2048 bytes? This is the correct place to increase the MQTT publish buffer size or is there any other place need to change?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;#define CONFIG_MQTT_MESSAGE_BUFFER_SIZE 128&lt;br /&gt;#define CONFIG_MQTT_PAYLOAD_BUFFER_SIZE 128&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;/* Buffers for MQTT client. */&lt;br /&gt;static uint8_t rx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];&lt;br /&gt;static uint8_t tx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Sravan Rikka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>