public class ThermostatAWS extends PeriodicPublisherCloud implements TopicListener
Modifier and Type | Field and Description |
---|---|
static String |
AWS_BROKER_PORT
Property to get the path to the aws port.
|
static String |
AWS_BROKER_URL
Property to get the path to the aws broker.
|
static 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,
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(String topic,
String value)
Publishes to a topic.
|
String |
getName()
Gets the listener name, can be
null . |
boolean |
isConnected()
Checks whether the listener is connected.
|
void |
onDataReceived(String topic,
byte[] dataReceived)
Called whenever a message arrives in the broker
|
protected void |
subscribe(String topic)
Subscribes to a topic.
|
disconnect, isReady, onTargetChange, onTemperatureChange, publishIP, receive, setIsConnected, setThermostat, start, stop
isError
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
public static final String AWS_BROKER_PORT
public static final String AWS_BROKER_URL
public static final String AWS_DEVICE_ID
public ThermostatAWS() throws IOException
ThermostatAWS
using the System properties and loading the certificates from the
application resources.
It will require this properties:IOException
- if a property is not set.public ThermostatAWS(Properties properties, CertificateLoader certificateLoader) throws 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.IOException
- if a property is not set.public ThermostatAWS(Properties properties, SSLContext sslContext) throws 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.IOException
- if a property is not set.protected void doConnect() throws IOException
PeriodicPublisherCloud
doConnect
in class PeriodicPublisherCloud
IOException
- when the connect failed.protected void doDisconnect()
PeriodicPublisherCloud
doDisconnect
in class PeriodicPublisherCloud
protected void doPublish(String topic, String value) throws IOException
PeriodicPublisherCloud
doPublish
in class PeriodicPublisherCloud
topic
- the topic to subscribe to.value
- the message to publish.IOException
- if an IOException
occurred.public String getName()
CloudConnector
null
.getName
in class CloudConnector
null
.public boolean isConnected()
CloudConnector
isConnected
in class PeriodicPublisherCloud
true
if the connector is connected.public void onDataReceived(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 subscribe(String topic) throws IOException
PeriodicPublisherCloud
subscribe
in class PeriodicPublisherCloud
topic
- the topic to subscribe to, cannot be null
.IOException
- if an IOException
occurred.