MQTT Client Class Pattern
The MQTT Client Class Pattern establishes a connection to a remote endpoint hosting an MQTT server (broker).
import MQTTClient from "embedded:network/mqtt/client";Constructor
Section titled “Constructor”MQTTClient(options)
Section titled “MQTTClient(options)”Creates a new MQTTClient object instance.
MQTTClient(options)Parameters
Section titled “Parameters”options
socket- ATCPclass constructor options object.
host- The remote hostname to connect to.
port(optional) - The remote port number to connect to.
Instance Methods
Section titled “Instance Methods”read()
Section titled “read()”Returns bytes from the current message.
write(data, options)
Section titled “write(data, options)”Sends message data.
close()
Section titled “close()”Initiates a disconnect from the MQTT broker.