Skip to main content

trustedge mqtt

Usage

trustedge mqtt [options]

Description

Uses MQTT to subscribe to topics and publish messages.

Overview

TrustEdge MQTT provides functionality for managing MQTT communications. TrustEdge MQTT supports both MQTT 3.1.1 and MQTT 5.0 protocols for publishing messages to an MQTT broker and subscribing to MQTT topics.

Examples

TrustEdge MQTT help (--help)

To view usage details and available options for TrustEdge MQTT, use the --help option:

trustedge mqtt --help

Tip

You can add --help to the end of any TrustEdge CLI command to view help information.

Publish a message to a topic (--mqtt_pub_topic)

To publish a message to an MQTT topic, use the following command:

 trustedge mqtt --mqtt_servername broker.hivemq.com --mqtt_pub_topic house/bulb1 --mqtt_pub_message "test message" --mqtt_port 1883
  • --mqtt_servername <servername> Specifies the MQTT broker to connect to. In this case, the broker is broker.hivemq.com.

  • --mqtt_pub_topic <topic> Defines the topic to which the message will be published. In this example, the topic is house/bulb1.

  • --mqtt_pub_message <message> The message that will be published to the topic specified by --mqtt_pub_topic. In this case, the message is "test message".

  • --mqtt_port <port> Specifies the network port used to connect to the MQTT broker. The port being used in this example is 1883, which is the default for MQTT over TCP.

Subscribe to a topic (--mqtt_sub_topic)

To subscribe to an MQTT topic, use the following command:

 trustedge mqtt --mqtt_servername broker.hivemq.com --mqtt_sub_topic house/bulb1 --mqtt_port 1883

After running the above command, trustedge enters a "listening" state and waits for messages to arrive on that topic.

  • --mqtt_servername <servername> Specifies the MQTT broker to connect to. In this case, the broker is broker.hivemq.com.

  • --mqtt_sub_topic <topic> Subscribes to the specified topic. In this example, the client will subscribe to the topic house/bulb1.

  • --mqtt_port <port> Specifies the network port used to connect to the MQTT broker. The port being used in this example is 1883, which is the default for MQTT over TCP.