MQTT::payload

Description

This command manipulates the payload of an MQTT PUBLISH message.

Syntax

MQTT::payload
MQTT::payload length
MQTT::payload replace <content>
MQTT::payload prepend <content>
MQTT::payload append <content

MQTT::payload

  • Returns the collected payload obtained as a result of a prior call to MQTT::collect. This command should be called without an argument only from MQTT_CLIENT_DATA or MQTT_SERVER_DATA events.

MQTT::payload length

  • Returns the length of payload of MQTT PUBLISH message. Make sure to call this method and call MQTT::collect only when payload length is not zero.

MQTT::payload replace <content>

  • Replace the entire payload of the MQTT PUBLISH message with specified content.

MQTT::payload prepend <content>

  • Add the specified content to the beginning of the payload of MQTT PUBLISH message.

MQTT::payload append <content>

  • Add the specified content to the end of the collected payload of MQTT PUBLISH message. For this command to work, MQTT::collect must be called prior to calling this. This command should be called only from MQTT_CLIENT_DATA or MQTT_SERVER_DATA events.

    Please note that in order to append the content at the end of payload, the MQTT::collect must collect entire payload. If collect is partial, this command will append content to the end of the data collected at the time this command is invoked. This can happen when MQTT::collect is called with a length smaller than the payload length as the argument.


Examples