- Artificial Intelligence
- Infrared Distance
- Admin Toolbox
- Advanced Twitter Recognition
- Display Popup
- Ez430-Chronos Wrist Watch
- EZMQTT Broker
- EZMQTT Client
- Floor Map
- IFTTT Sender
- Kinect Body Control
- Miscellaneous Utility Plugin
- MP3 Trigger
- Myo Gesture Armband
- Neopixel Blaster
- Neopixel Ring
- Remote Mouse
- Roll Pitch Yaw
- Sensor Stream Server
- Serial Toolbox
- SMTP Client
- Twitter Recognition
- Video Player
- Virtual Robot
- Wii Remote
- Third Party Robots
- Touch Tablet
- Ultrasonic Distance
- Virtual Reality
This is an MQTT Client Control that connects to an MQTT broker and subscribes to topics. When messages are published to matching topics, the incoming data will be assigned to a variable and an associated EZ-Script will launch.
MQTT (MQ Telemetry Transport) is a publish-subscribe-based "lightweight" messaging protocol for use on top of the TCP/IP protocol (port 1883). The publish-subscribe messaging pattern requires a message broker. The broker is responsible for distributing messages to interested clients based on the topic of a message.
MQTT defines methods (sometimes referred to as verbs) to indicate the desired action to be performed on the identified resource. What this resource represents, whether pre-existing data or data that is generated dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the output of an executable residing on the server.
Connects to the hostname of the specified MQTT broker. Either the CONNECT button on the control can be pressed, or a ControlCommand() can be passed. If no parameter is specified in the ControlCommand(), the default value from the config is used. Both examples of specifying a hostname and not are provided below.
# If not connected, connect to local MQTT broker
ControlCommand("EZMQTT Client", Connect, "127.0.0.1")
# Connect to default hostname specified in config
ControlCommand("EZMQTT Client", Connect)
Waits for the MQTT client to finish any work it must do, and for the TCP/IP session to disconnect. This may be executed by pressing the DISCONNECT button on the control, or using the ControlCommand().
ControlCommand("EZMQTT Client", Disconnect)
Subscription to topics are specified in the Config menu of the control. The variable name and script to execute must also be provided. If the data from the published messages are expected to be Binary, then check the Binary box. This will assign the data to an Array of the specified variable. If the Binary checkbox is not checked, the expected data is alphanumeric string.
Publish specified data to the specified topic. The following commands are...
# Publish a string to the 'asdf' topic
ControlCommand("EZMQTT Client", PublishString, "asdf", "Hello World")
# Publish binary array to the 'asdf' topic
$array = 1
$array = 2
$array = 3
$array = 4
$array = 5
ControlCommand("EZMQTT Client", PublishBinary, "asdf", "$array")
# Publish a comma separated list of numeric values, variables and strings to the 'asdf' topic
$x = "Hello"
ControlCommand("EZMQTT Client", PublishBytes, "asdf", $x, 32, "World")
Here is a sample EZ-Builder project that demonstrates the MQTT Client connecting to a local MQTT Broker: testmqttclient.EZB