Device Class

public class Device
extends BaseDevice

The Device class extends the BaseDevice class implementing constructors and serialization functionality.

Field Summary

Modifier and Type Field and Description
protected DeviceCapabilities capabilities
protected java.util.List<java.lang.String> parentScopes
protected java.lang.String scope
protected DeviceStatus status
protected java.lang.String statusReason

A 128 char long string storing the reason of suspension (all UTF-8 chars allowed).

protected java.lang.String statusUpdatedTime

Constructor Summary

Modifier Constructor Description
protected Device(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Create an Device instance using the given device name.

Method Summary

Modifier and Type Method and Description
static Device createDevice(String deviceId, AuthenticationType authenticationType)

Static create function.

static Device createFromId(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Static create function.

DeviceCapabilities getCapabilities()

Getter for capabilities.

java.util.List<java.lang.String> getParentScopes()

Gets the scopes of the upper level edge devices, if applicable.

java.lang.String getScope()

Gets the scope of the device.

DeviceStatus getStatus()

Getter for DeviceStatus object.

java.lang.String getStatusReason()

Getter for status reason.

java.lang.String getStatusUpdatedTime()

Getter for status updated on string.

void setCapabilities(DeviceCapabilities capabilities)

Setter for DeviceCapabilities object.

void setScope(String scope)

Sets the scope of the device.

void setStatus(DeviceStatus status)

Setter for DeviceStatus object.

Methods inherited from BaseDevice

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

capabilities

protected DeviceCapabilities capabilities

parentScopes

protected List parentScopes

scope

protected String scope

status

protected DeviceStatus status

statusReason

protected String statusReason

A 128 char long string storing the reason of suspension (all UTF-8 chars allowed).

statusUpdatedTime

protected String statusUpdatedTime

Constructor Details

Device

protected Device(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Create an Device instance using the given device name.

Parameters:

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.

Throws:

java.lang.IllegalArgumentException - This exception is thrown if the encryption method is not supported by the key generator.

Method Details

createDevice

public 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. If input device status is null then it will be auto-generated.

Parameters:

deviceId - String containing the device name.
authenticationType - The type of authentication used by this device.

Returns:

Device object.

createFromId

public static Device createFromId(String deviceId, DeviceStatus status, SymmetricKey symmetricKey)

Static create function. Creates device object using the given name. If input device status and symmetric key are null then they will be auto generated.

Parameters:

deviceId - String containing the device name.
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.

Returns:

Device object

Throws:

java.lang.IllegalArgumentException - This exception is thrown if deviceId is null or empty.

getCapabilities

public DeviceCapabilities getCapabilities()

Getter for capabilities.

Returns:

The DeviceCapabilities containing capabilities that are enabled on the device.

getParentScopes

public List getParentScopes()

Gets the scopes of the upper level edge devices, if applicable.

For edge devices, the value to set a parent edge device can be retrieved from the calling parent edge device's getScope() method.

For leaf devices, this could be set to the same value as getScope() or left for the service to copy over.

For now, this list can only have 1 element in the collection.

For more information, see this document.

Returns:

The parent scopes for this device.

getScope

public String getScope()

Gets the scope of the device.

Returns:

The scope for this device.

getStatus

public DeviceStatus getStatus()

Getter for DeviceStatus object. Values: "Enabled", "Disabled". If "Enabled", this device is authorized to connect. If "Disabled" this device cannot receive or send messages, and statusReason must be set.

Returns:

The deviceStatus object.

getStatusReason

public String getStatusReason()

Getter for status reason.

Returns:

The statusReason string.

getStatusUpdatedTime

public String getStatusUpdatedTime()

Getter for status updated on string.

Returns:

The string containing the time when the statusUpdatedTime object was updated.

setCapabilities

public void setCapabilities(DeviceCapabilities capabilities)

Setter for DeviceCapabilities object.

Parameters:

capabilities - Capabilities to be set.

setScope

public void setScope(String scope)

Sets the scope of the device.

For edge devices, this is auto-generated and immutable.

For leaf devices, set this to create child/parent relationship. The value to set a parent edge device can be retrieved from calling the parent edge device's getScope() method.

For more information, see this document.

Parameters:

scope - The device scope to set.

setStatus

public void setStatus(DeviceStatus status)

Setter for DeviceStatus object. Values: "Enabled", "Disabled". If "Enabled", this device is authorized to connect. If "Disabled" this device cannot receive or send messages, and statusReason must be set.

Parameters:

status - status to be set.

Applies to