public class Device extends Object
| Modifier and Type | Field and Description |
|---|---|
protected long |
cloudToDeviceMessageCount
Number of messages received by the device
|
protected DeviceConnectionState |
connectionState
Status of the device:
{"connected" | "disconnected"}
|
protected String |
connectionStateUpdatedTime
Datetime of last time the connection state was updated.
|
protected String |
deviceId
Device name
A case-sensitive string (up to 128 char long)
of ASCII 7-bit alphanumeric chars
+ {'-', ':', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}.
|
protected String |
eTag
A string representing a weak ETAG version
of this JSON description.
|
protected String |
generationId
Device generation Id
|
protected String |
lastActivityTime
Datetime of last time the device authenticated, received, or sent a message.
|
protected String |
OFFSET_TIME_DEFAULT |
protected DeviceStatus |
status
"Enabled", "Disabled".
|
protected String |
statusReason
A 128 char long string storing the reason of suspension.
|
protected String |
statusUpdatedTime
Datetime of last time the state was updated.
|
protected String |
UTC_TIME_DEFAULT |
| Modifier | Constructor and Description |
|---|---|
protected |
Device(String deviceId,
DeviceStatus status,
SymmetricKey symmetricKey)
Create an Device instance using the given device name
|
| Modifier and Type | Method and Description |
|---|---|
static Device |
createDevice(String deviceId,
AuthenticationType authenticationType)
Static create function
Creates device object using the given name that will use a Certificate Authority signed certificate for authentication.
|
static Device |
createFromId(String deviceId,
DeviceStatus status,
SymmetricKey symmetricKey)
Static create function
Creates device object using the given name.
|
AuthenticationType |
getAuthenticationType()
Getter for the authentication type of this device
|
long |
getCloudToDeviceMessageCount()
Getter for cloud to device message count
|
DeviceConnectionState |
getConnectionState()
Getter for connection state
|
String |
getConnectionStateUpdatedTime()
Getter for connection state updated time
|
String |
getDeviceId()
Getter for device name
|
String |
geteTag()
Getter for eTag
|
String |
getGenerationId()
Getter for GenerationId
|
String |
getLastActivityTime()
Getter for last activity time
|
String |
getPrimaryKey()
Getter for PrimaryKey part of the SymmetricKey
|
String |
getPrimaryThumbprint()
Getter for primary thumbprint part of the whole thumbprint
|
String |
getSecondaryKey()
Getter for SecondaryKey part of the SymmetricKey
|
String |
getSecondaryThumbprint()
Getter for secondary thumbprint part of the whole thumbprint
|
DeviceStatus |
getStatus()
Getter for DeviceStatus object
|
String |
getStatusReason()
Getter for status reason
|
String |
getStatusUpdatedTime()
Getter for status updated time string
|
SymmetricKey |
getSymmetricKey()
Getter for SymmetricKey object
|
void |
setForceUpdate(Boolean forceUpdate)
Setter for force update boolean
|
void |
setStatus(DeviceStatus status)
Setter for DeviceStatus object
|
void |
setSymmetricKey(SymmetricKey symmetricKey)
Setter for SymmetricKey object
|
void |
setThumbprint(String primaryThumbprint,
String secondaryThumbprint)
Setter for X509 thumbprint
|
protected final String UTC_TIME_DEFAULT
protected final String OFFSET_TIME_DEFAULT
protected String deviceId
protected String generationId
protected String eTag
protected DeviceStatus status
protected String statusReason
protected String statusUpdatedTime
protected DeviceConnectionState connectionState
protected String connectionStateUpdatedTime
protected String lastActivityTime
protected long cloudToDeviceMessageCount
protected Device(String deviceId, DeviceStatus status, SymmetricKey symmetricKey) throws NoSuchAlgorithmException, IllegalArgumentException
deviceId - Name of the device (used as device id)status - - Device status. If parameter is null, then the status will be set to Enabled.symmetricKey - - Device key. If parameter is null, then the key will be auto generated.NoSuchAlgorithmException - This exception is thrown if the encryption method is not supported by the keyGeneratorIllegalArgumentExceptionpublic static Device createFromId(String deviceId, DeviceStatus status, SymmetricKey symmetricKey) throws IllegalArgumentException, NoSuchAlgorithmException
deviceId - - String containing the device namestatus - - Device status. If parameter is null, then the status will be set to Enabled.symmetricKey - - Device key. If parameter is null, then the key will be auto generated.IllegalArgumentException - This exception is thrown if deviceId is null or empty.NoSuchAlgorithmException - This exception is thrown if the encryption method is not supported by the keyGeneratorpublic static Device createDevice(String deviceId, AuthenticationType authenticationType)
deviceId - - String containing the device nameauthenticationType - - The type of authentication used by this device.IllegalArgumentException - This exception is thrown if deviceId is null or empty.public String getDeviceId()
public String getGenerationId()
public SymmetricKey getSymmetricKey()
public void setSymmetricKey(SymmetricKey symmetricKey) throws IllegalArgumentException
symmetricKey - symmetricKey to be setIllegalArgumentException - if the provided symmetric key is nullpublic String getPrimaryKey()
public String getSecondaryKey()
public void setThumbprint(String primaryThumbprint, String secondaryThumbprint)
primaryThumbprint - the primary thumbprint to setsecondaryThumbprint - the secondary thumbprint to setIllegalArgumentException - if primaryThumbprint or secondaryThumbprint is null or emptypublic String getPrimaryThumbprint()
public String getSecondaryThumbprint()
public String geteTag()
public DeviceStatus getStatus()
public void setStatus(DeviceStatus status)
status - status to be setpublic String getStatusReason()
public String getStatusUpdatedTime()
public DeviceConnectionState getConnectionState()
public String getConnectionStateUpdatedTime()
public String getLastActivityTime()
public long getCloudToDeviceMessageCount()
public void setForceUpdate(Boolean forceUpdate) throws IllegalArgumentException
forceUpdate - - Boolean controlling if the update should be forced or notIllegalArgumentException - if the provided argument is nullpublic AuthenticationType getAuthenticationType()
Copyright © 2017. All rights reserved.