public class ThermostatMQTT extends PeriodicPublisherCloud implements org.eclipse.paho.client.mqttv3.MqttCallback
TOPIC_IP, TOPIC_SET, TOPIC_TARGET, TOPIC_TEMPERATURE
Constructor and Description |
---|
ThermostatMQTT(java.lang.String clientID,
java.lang.String uri)
Instantiates a Thermostat Cloud connector over tcp MQTT.
|
Modifier and Type | Method and Description |
---|---|
void |
connectionLost(java.lang.Throwable cause) |
void |
deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token) |
protected void |
doConnect()
Connects to the cloud.
|
protected void |
doDisconnect()
Disconnects from the cloud.
|
protected void |
doPublish(java.lang.String topic,
java.lang.String ip)
Publishes to a topic.
|
java.lang.String |
getName()
Gets the listener name, can be
null . |
boolean |
isConnected()
Checks whether the listener is connected.
|
void |
messageArrived(java.lang.String topic,
org.eclipse.paho.client.mqttv3.MqttMessage message) |
protected void |
subscribe(java.lang.String topic)
Subscribes to a topic.
|
disconnect, isReady, onTargetChange, onTemperatureChange, publishIP, receive, setIsConnected, setThermostat, start, stop
isError
public ThermostatMQTT(java.lang.String clientID, java.lang.String uri)
clientID
- The client ID.uri
- The broker URI.public java.lang.String getName()
CloudConnector
null
.getName
in class CloudConnector
null
.protected void subscribe(java.lang.String topic) throws java.io.IOException
PeriodicPublisherCloud
subscribe
in class PeriodicPublisherCloud
topic
- the topic to subscribe to, cannot be null
.java.io.IOException
- if an IOException
occurred.public void messageArrived(java.lang.String topic, org.eclipse.paho.client.mqttv3.MqttMessage message) throws java.lang.Exception
messageArrived
in interface org.eclipse.paho.client.mqttv3.MqttCallback
java.lang.Exception
public void connectionLost(java.lang.Throwable cause)
connectionLost
in interface org.eclipse.paho.client.mqttv3.MqttCallback
public void deliveryComplete(org.eclipse.paho.client.mqttv3.IMqttDeliveryToken token)
deliveryComplete
in interface org.eclipse.paho.client.mqttv3.MqttCallback
protected void doPublish(java.lang.String topic, java.lang.String ip) throws java.io.IOException
PeriodicPublisherCloud
doPublish
in class PeriodicPublisherCloud
topic
- the topic to subscribe to.ip
- the message to publish.java.io.IOException
- if an IOException
occurred.protected void doConnect() throws java.io.IOException
PeriodicPublisherCloud
doConnect
in class PeriodicPublisherCloud
java.io.IOException
- when the connect failed.protected void doDisconnect()
PeriodicPublisherCloud
doDisconnect
in class PeriodicPublisherCloud
public boolean isConnected()
CloudConnector
isConnected
in class PeriodicPublisherCloud
true
if the connector is connected.