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
  • Hi,

    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?

    There is a data communication limit in modem due to max size of TLS buffer of 2 KB. You can read about the limit  in the documentation. Furthermore, you can look at MQTT sample overview and this discussion. For sending larger messages, you can split your big MQTT message into smaller ones.

    3. Is the nRF9160 supports secure boot?

    Yes, you can look at features and nRF91 security features.

    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?

    I will check this internally.

    Best regards,
    Deja

  • Hi Dejans,

    For my 1 and 2 queries:

    I have looked at your suggested links and it is talking about TLS but I am not using TLS, I am using nonsecure MQTT.

    For non-secure MQTT also 2KB is the limit in single publish?

    In MQTT simple code I can see tx_buffer and 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?

    #define CONFIG_MQTT_MESSAGE_BUFFER_SIZE 128
    #define CONFIG_MQTT_PAYLOAD_BUFFER_SIZE 128

    /* Buffers for MQTT client. */
    static uint8_t rx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];
    static uint8_t tx_buffer[CONFIG_MQTT_MESSAGE_BUFFER_SIZE];

    Regards,

    Sravan Rikka

  • Hi Dejan,

    Yes, I am using "lte_lc library API".

    Can you provide modem trace for further analysis? How to get this, please provide procedure.

    Regards,

    Sravan Rikka

  • Hi,

    Have you seen the edit in my previous reply? Can you double-check if the link is turned off in described way?

    sravan.rikka said:
    Can you provide modem trace for further analysis? How to get this, please provide procedure.

    Please have a look at following resources
    modem trace
    capturing modem trace
    snippets for nrf91 series
    modem trace module
    cellular monitor
    capturing modem trace
    enable tracing in the application
    capturing modem trace using nrfutil

    Best regards,
    Dejan

  • Hi Dejan,

    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)

    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.

    3. We have subscribe for a topic and got the 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't find it.

    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?

    Regards,

    Sravan Rikka

  • Hi,

    sravan.rikka said:
    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)

    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.

    sravan.rikka said:
    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.

    Modem can be put in low power state by entering PSM or by being turned off. There is lte_lc API for doing this.

    sravan.rikka said:
    3. We have subscribe for a topic and got the 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't find it.

    MQTT_EVT_PUBLISH is publishing event which is received when message is published on a topic client has subscribed to. Payload can be read using mqtt_read_publish_payload().

    sravan.rikka said:
    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?

    If device wants to read published payload, it needs to be subscribed beforehand.

    Best regards,
    Dejan

  • Hi,

    dejans said:
    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.

    TCP has 10 retransmissions, and this is not configurable in the application.

    Best regards,
    Dejan

Reply Children
No Data
Related