public class ThermostatAWS extends PeriodicPublisherCloud implements TopicListener
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AWS_BROKER_PORT
Property to get the path to the aws port.
|
static java.lang.String |
AWS_BROKER_URL
Property to get the path to the aws broker.
|
static java.lang.String |
AWS_DEVICE_ID
Property to get the path to the things id.
|
TOPIC_IP, TOPIC_SET, TOPIC_TARGET, TOPIC_TEMPERATURE
Constructor and Description |
---|
ThermostatAWS()
Instantiates a
ThermostatAWS using the System properties and loading the certificates from the
application resources. |
ThermostatAWS(Properties properties,
CertificateLoader certificateLoader)
Instantiates a
ThermostatAWS using the properties and certificate loader provided in parameter. |
ThermostatAWS(Properties properties,
javax.net.ssl.SSLContext sslContext)
Instantiates a
ThermostatAWS using the properties and SSLContext provided in parameter. |
Modifier and Type | Method and Description |
---|---|
protected void |
doConnect()
Connects to the cloud.
|
protected void |
doDisconnect()
Disconnects from the cloud.
|
protected void |
doPublish(java.lang.String topic,
java.lang.String value)
Publishes to a topic.
|
java.lang.String |
getName()
Gets the listener name, can be
null . |
boolean |
isConnected()
Checks whether the listener is connected.
|
void |
onDataReceived(java.lang.String topic,
byte[] dataReceived)
Called whenever a message arrives in the broker
|
protected void |
subscribe(java.lang.String topic)
Subscribes to a topic.
|
disconnect, isReady, onTargetChange, onTemperatureChange, publishIP, receive, setIsConnected, setThermostat, start, stop
isError
public static final java.lang.String AWS_BROKER_URL
public static final java.lang.String AWS_BROKER_PORT
public static final java.lang.String AWS_DEVICE_ID
public ThermostatAWS() throws java.io.IOException
ThermostatAWS
using the System properties and loading the certificates from the
application resources.
It will require this properties:java.io.IOException
- if a property is not set.public ThermostatAWS(Properties properties, CertificateLoader certificateLoader) throws java.io.IOException
ThermostatAWS
using the properties and certificate loader provided in parameter.
It will require this properties:properties
- the properties to use.certificateLoader
- the certificate loader to use.java.io.IOException
- if a property is not set.public ThermostatAWS(Properties properties, javax.net.ssl.SSLContext sslContext) throws java.io.IOException
ThermostatAWS
using the properties and SSLContext provided in parameter.
It will require this properties:properties
- the properties to use.sslContext
- the ssl context to use.java.io.IOException
- if a property is not set.protected void doDisconnect()
PeriodicPublisherCloud
doDisconnect
in class PeriodicPublisherCloud
protected void doConnect() throws java.io.IOException
PeriodicPublisherCloud
doConnect
in class PeriodicPublisherCloud
java.io.IOException
- when the connect failed.public java.lang.String getName()
CloudConnector
null
.getName
in class CloudConnector
null
.public boolean isConnected()
CloudConnector
isConnected
in class PeriodicPublisherCloud
true
if the connector is connected.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 onDataReceived(java.lang.String topic, byte[] dataReceived)
TopicListener
onDataReceived
in interface TopicListener
topic
- the topic where is the message is receiveddataReceived
- the array of bytes of the message (encoding assumed to be ASCII)protected void doPublish(java.lang.String topic, java.lang.String value) throws java.io.IOException
PeriodicPublisherCloud
doPublish
in class PeriodicPublisherCloud
topic
- the topic to subscribe to.value
- the message to publish.java.io.IOException
- if an IOException
occurred.