MQTT simple example code (api based)

Hi Team,

We are using nRF9160 MQTT sample code 'mqtt_simple'. 

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?

3. Is the nRF9160 supports secure boot?

4. Is the nRF9160 has boot ROM? If yes, is this boot ROM available for us to add some piece of code in the boot ROM?

Regards,

Sravan Rikka

Parents Reply Children
  • Hi Sravan,

    Which MQTT broker do you use?

    If you use picolib, ensure that PICOLIB_IO_FLOAT is enabled.

    Best regards,
    Dejan

  • Hi Dejan,

    I am using tago.io broker.

    I am saying that snprintf itself not copying the float value into buffer when I use %f.

    Regards,

    Sravan Rikka

  • Hi Dejan,

    Please respond to below queries I am waiting for your responses. Thank you.

    1. In our application we will store 5000 records and each record of size 1429, hence total bytes=5000 *      1429=7145000. Hence, we are planning to transfer 7.145MB in single MQTT publish. It is possible right?

    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.

    float ambientTemperature = 24.5;
    len = snprintf(buf, sizeof(buf), "ambientTemperature=%f", ambientTemperature);
    printk(buf);

    Regards,

    Sravan Rikka

  • Hi Sravan,

    sravan.rikka said:
    1. In our application we will store 5000 records and each record of size 1429, hence total bytes=5000 *      1429=7145000. Hence, we are planning to transfer 7.145MB in single MQTT publish. It is possible right?

    Have you checked if there are any limitations on the broker side?

    sravan.rikka said:

    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.

    float ambientTemperature = 24.5;
    len = snprintf(buf, sizeof(buf), "ambientTemperature=%f", ambientTemperature);
    printk(buf);

    I have used the following sample which correctly displays ambientTemperature value from the buffer buf.

    #include <stdio.h>
    
    char buf[200];
    int len;
    
    int main(void)
    {
        float ambientTemperature = 24.5;
        len = snprintf(buf, sizeof(buf), "ambientTemperature=%f", ambientTemperature);
        printf("buffer value is %s", buf);
    }

    Best regards,
    Dejan

  • Hi Dejan,

    1. Not yet, I will check broker side limitations.

    2. For me it is not working, I am using 'mqtt simple' 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?

    #include <zephyr.h>
    #include <stdio.h>
    #include <drivers/uart.h>
    #include <string.h>
    #include <random/rand32.h>
    #include <net/mqtt.h>
    #include <net/socket.h>
    #include <modem/at_cmd.h>
    #include <modem/lte_lc.h>
    #include <logging/log.h>
    #if defined(CONFIG_MODEM_KEY_MGMT)
    #include <modem/modem_key_mgmt.h>
    #endif
    #if defined(CONFIG_LWM2M_CARRIER)
    #include <lwm2m_carrier.h>
    #endif
    #include <dk_buttons_and_leds.h>

    #include "certificates.h"

    Regards,

    Sravan Rikka

Related