MQTT::insert

Description

This command inserts an MQTT message.

Syntax

MQTT::insert <before | after> type CONNECT client_id <client_id>
    [keep_alive <time-in-seconds>]
    [clean_session <0 | 1>]
    [protocol_name <name-string>]
    [protocol_version <level-number>]
    [username <name-string>]
    [password <password-string>]
    [will_topic <topic-string>]
    [will_message <message-string>]
    [will_qos <0 | 1 | 2>]
    [will_retain <0 | 1>]
MQTT::insert <before | after> type CONNACK return_code <0-5> [session_present <session-present-flag>]
MQTT::insert <before | after> type PUBLISH topic <topic-name> payload <content>
    [<qos 0> | <qos 1 | 2> packet_id <packet-id-number>]
    [dup <0 | 1>]
    [retain <0 | 1>]
MQTT::insert <before | after> type <PUBACK | PUBREC | PUBREL | PUBCOMP | UNSUBACK> packet_id <packet-id-number>
MQTT::insert <before | after> type SUBSCRIBE packet_id <packet-id-number> topic_list {<topic-name> <qos>}+
MQTT::insert <before | after> type SUBACK packet_id <packet-id-number> return_code_list {<return-code>}+
MQTT::insert <before | after> type UNSUBSCRIBE packet_id <packet-id-number> topic_list {<topic-name> <qos>}+
MQTT::insert <before | after> type <PINGREQ | PINGRESP | DISCONNECT>

MQTT::insert type CONNECT client_id
  • [keep_alive <time-in-seconds>] [clean_session <0 | 1>]
  • [protocol_name <name-string>] [protocol_version <level-number>]
  • [username <name-string>] [password <password-string>]
  • [will_topic <topic-string>] [will_message <message-string>]
  • [will_qos <0 | 1 |2>] [will_retain <0 | 1>]

The client_id is required parameter, keep_alive must be smaller than 65536. Default values for optional parameters are:
  • keep_alive -: 60 seconds.
  • clean_session -: 1
  • protocol_name -: MQTT
  • protocol_version -: 4
  • username -: “”
  • password -: “”
  • will_topic -: “”
  • will_message -: “”
  • will_qos -: 0
  • will_retain -: 0

MQTT::insert type CONNACK return_code
  • [ session_present <session-present-flag> ]

The values must be set to one of the following:.
  • 0 - Connection Accepted.
  • 1 - Connection Refused, unacceptable protocol version.
  • 2 - Connection Refused, identifier rejected.
  • 3 - Connection Refused, Server unavailable.
  • 4 - Connection Refused, bad username or password.
  • 5 - Connection Refused, not authorized. The <session-present-flag> can be set to 0 or 1. The default value is 0.

MQTT::insert type PUBLISH topic payload
  • [{qos 0} | {qos <1 | 2> packet_id <packet-id-number>} ]
  • [dup <0 | 1>]
  • [retain <0 | 1>]

For PUBLISH, the topic and payload are required parameters. If qos is 1 or 2, then packet_id must also be specified. must be smaller than 65536. Default values for optional parameters are:
  • qos -: 0
  • dup -: 0
  • retain -: 0

MQTT::insert type PUBACK packet_id
MQTT::insert type PUBREC packet_id
MQTT::insert type PUBREL packet_id
MQTT::insert type PUBCOMP packet_id
For PUBACK, PUBREC, PUBREL, and PUBCOMP, packet_id is a required parameter. No other parameter should be specified. must be smaller than 65536.
MQTT::insert type SUBSCRIBE packet_id topic_list { }+
For SUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be specified. must be smaller than 65536. can only be 0,1, or 2.
MQTT::insert type SUBACK packet_id return_code_list {}+
For SUBACK, packet_id and return_code_list are required parameters. No other parameter should be specified. must be smaller than 65536.
MQTT::insert type UNSUBSCRIBE packet_id topic_list { }+
For UNSUBSCRIBE, packet_id and topic_list are required parameters. No other parameter should be specified. Please note that values will be ignored. It is required to make format of topic_list same between SUBSCRIBE and UNSUBSCRIBE. UNSUBSCRIBE does not need the qos.
MQTT::insert type UNSUBACK packet_id
For UNSUBACK, packet_id is required parameter.
MQTT::insert type PINGREQ
For PINGREQ should be used with no parameter.
MQTT::insert type PINGRESP
For PINGRESP should be used with no parameter.
MQTT::insert type DISCONNECT
For DISCONNECT should be used with no parameter.

Examples