public class Device
extends java.lang.Object
Constructor and Description |
---|
Device(ConnectOptions options)
Create a Device with connection information related to the Google Cloud IoT Core services.
|
Modifier and Type | Method and Description |
---|---|
void |
clearConfigListener()
Stop processing config events.
|
void |
connect()
Connect the Device to the Google Cloud IoT Core services.
|
void |
disconnect()
Disconnect the Device from the Google Cloud IoT Core services.
|
char[] |
getJwt()
Gets the JSON Web Token once connected.
|
boolean |
isConnected()
Check if the device is connected.
|
void |
setConfigListener(googlecloud.iotcore.ConfigListener listener)
Add a configuration listener notified when the config of the device changes and at first connection.
|
void |
setEvent(byte[] data)
Set events.
|
void |
setJwt(char[] jwt)
Sets the JSON Web Token to be used for connection.
|
void |
setState(byte[] data)
Set the state of Device.
|
void |
setSubEvent(java.lang.String subEvent,
byte[] data)
Set sub-events.
|
public Device(ConnectOptions options)
options
- the options of connection to the brokerpublic char[] getJwt()
public void setJwt(char[] jwt)
jwt
- the jwt to used for connection.public void setState(byte[] data) throws IotCoreException
data
- application-dependent state dataIotCoreException
- on connection issues and errors of communicationpublic void setEvent(byte[] data) throws IotCoreException
data
- application-dependent event dataIotCoreException
- on connection issues and errors of communicationpublic void setSubEvent(java.lang.String subEvent, byte[] data) throws IotCoreException
subEvent
- the wanted sub-folder of eventsdata
- application-dependent sub-event dataIotCoreException
- on connection issues and errors of communicationpublic void setConfigListener(googlecloud.iotcore.ConfigListener listener) throws IotCoreException
listener
- the right ConfigListener that will get notifiedIotCoreException
- on subscription error to the config topicpublic void clearConfigListener()
public void connect() throws IotCoreException
IotCoreException
- when connectedpublic void disconnect() throws IotCoreException
IotCoreException
- when not connectedpublic boolean isConnected()