Compartilhar via


DeviceClientConfig Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.device.DeviceClientConfig

public final class DeviceClientConfig

Configuration settings for an IoT Hub client. Validates all user-defined settings.

Field Summary

Modifier and Type Field and Description
static final int DEFAULT_AMQP_OPEN_AUTHENTICATION_SESSION_TIMEOUT_IN_SECONDS

Constructor Summary

Modifier Constructor Description
protected DeviceClientConfig()
DeviceClientConfig(IotHubConnectionString iotHubConnectionString)

Constructor

DeviceClientConfig(IotHubConnectionString iotHubConnectionString, ClientOptions clientOptions)
DeviceClientConfig(IotHubConnectionString iotHubConnectionString, String publicKeyCertificate, boolean isPathForPublic, String privateKey, boolean isPathForPrivate)

Constructor for device configs that use x509 authentication

DeviceClientConfig(IotHubConnectionString iotHubConnectionString, SSLContext sslContext)
DeviceClientConfig(IotHubAuthenticationProvider authenticationProvider)
DeviceClientConfig(String hostName, SasTokenProvider sasTokenProvider, ClientOptions clientOptions, String deviceId, String moduleId)

Method Summary

Modifier and Type Method and Description
IotHubAuthenticationProvider getAuthenticationProvider()
AuthType getAuthenticationType()

Getter for AuthenticationType

java.lang.String getDeviceId()

Getter for the device ID.

MessageCallback getDeviceMethodsMessageCallback()

Getter for the device twin message callback.

java.lang.Object getDeviceMethodsMessageContext()

Getter for the context to be passed in to the device twin message callback.

MessageCallback getDeviceTelemetryMessageCallback(String inputName)

Getter for the message callback.

java.lang.Object getDeviceTelemetryMessageContext(String inputName)

Getter for the context to be passed in to the message callback.

MessageCallback getDeviceTwinMessageCallback()

Getter for the device twin message callback.

java.lang.Object getDeviceTwinMessageContext()

Getter for the context to be passed in to the device twin message callback.

java.lang.String getGatewayHostname()

Getter for the Gateway host name.

java.lang.String getIotHubHostname()

Getter for the IoT Hub hostname.

java.lang.String getIotHubName()

Getter for the IoT Hub name.

int getMessageLockTimeoutSecs()

Getter for the timeout, in seconds, for the lock that the client has on a received message.

java.lang.String getModuleId()
long getOperationTimeout()

Getter for the device operation timeout

ProductInfo getProductInfo()
IotHubClientProtocol getProtocol()
ProxySettings getProxySettings()
RetryPolicy getRetryPolicy()

Getter for RetryPolicy

IotHubSasTokenAuthenticationProvider getSasTokenAuthentication()

Getter for SasTokenAuthentication

boolean isUseWebsocket()

Getter for Websocket

void setDeviceMethodsMessageCallback(MessageCallback callback, Object context)

Setter for the device method message callback.

void setDeviceTwinMessageCallback(MessageCallback callback, Object context)

Setter for the device twin message callback.

void setMessageCallback(MessageCallback callback, Object context)

Setter for the message callback.

void setMessageCallback(String inputName, MessageCallback callback, Object context)
void setProxy(ProxySettings proxySettings)
void setRetryPolicy(RetryPolicy retryPolicy)

Setter for RetryPolicy

void setUseWebsocket(boolean useWebsocket)

Setter for Websocket

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

DEFAULT_AMQP_OPEN_AUTHENTICATION_SESSION_TIMEOUT_IN_SECONDS

public static final int DEFAULT_AMQP_OPEN_AUTHENTICATION_SESSION_TIMEOUT_IN_SECONDS

Constructor Details

DeviceClientConfig

protected DeviceClientConfig()

DeviceClientConfig

public DeviceClientConfig(IotHubConnectionString iotHubConnectionString)

Constructor

Parameters:

iotHubConnectionString - is the string with the hostname, deviceId, and deviceKey or token, which identify the device in the Azure IotHub.

Throws:

java.lang.IllegalArgumentException - if the IoT Hub hostname does not contain a valid IoT Hub name as its prefix.

DeviceClientConfig

public DeviceClientConfig(IotHubConnectionString iotHubConnectionString, ClientOptions clientOptions)

Parameters:

iotHubConnectionString
clientOptions

DeviceClientConfig

public DeviceClientConfig(IotHubConnectionString iotHubConnectionString, String publicKeyCertificate, boolean isPathForPublic, String privateKey, boolean isPathForPrivate)

Constructor for device configs that use x509 authentication

Parameters:

iotHubConnectionString - The connection string for the device. (format: "HostName=...;deviceId=...;x509=true")
publicKeyCertificate - The PEM encoded public key certificate or the path to the PEM encoded public key certificate file
isPathForPublic - If the provided publicKeyCertificate is a path to the actual public key certificate
privateKey - The PEM encoded private key or the path to the PEM encoded private key file
isPathForPrivate - If the provided privateKey is a path to the actual private key

DeviceClientConfig

public DeviceClientConfig(IotHubConnectionString iotHubConnectionString, SSLContext sslContext)

Parameters:

iotHubConnectionString
sslContext

DeviceClientConfig

public DeviceClientConfig(IotHubAuthenticationProvider authenticationProvider)

Parameters:

authenticationProvider

Throws:

java.lang.IllegalArgumentException

DeviceClientConfig

public DeviceClientConfig(String hostName, SasTokenProvider sasTokenProvider, ClientOptions clientOptions, String deviceId, String moduleId)

Parameters:

hostName
sasTokenProvider
clientOptions
deviceId
moduleId

Method Details

getAuthenticationProvider

public IotHubAuthenticationProvider getAuthenticationProvider()

getAuthenticationType

public DeviceClientConfig.AuthType getAuthenticationType()

Getter for AuthenticationType

Returns:

The value of AuthenticationType

getDeviceId

public String getDeviceId()

Getter for the device ID.

Returns:

the device ID.

getDeviceMethodsMessageCallback

public MessageCallback getDeviceMethodsMessageCallback()

Getter for the device twin message callback.

Returns:

the device method message callback.

getDeviceMethodsMessageContext

public Object getDeviceMethodsMessageContext()

Getter for the context to be passed in to the device twin message callback.

Returns:

the device method message context.

getDeviceTelemetryMessageCallback

public MessageCallback getDeviceTelemetryMessageCallback(String inputName)

Getter for the message callback.

Parameters:

inputName - the inputName that the desired callback is tied to, or null for the default callback

Returns:

the message callback.

getDeviceTelemetryMessageContext

public Object getDeviceTelemetryMessageContext(String inputName)

Getter for the context to be passed in to the message callback.

Parameters:

inputName - the inputName that the desired callback context is tied to, or null for the default callback context

Returns:

the message context.

getDeviceTwinMessageCallback

public MessageCallback getDeviceTwinMessageCallback()

Getter for the device twin message callback.

Returns:

the device twin message callback.

getDeviceTwinMessageContext

public Object getDeviceTwinMessageContext()

Getter for the context to be passed in to the device twin message callback.

Returns:

the device twin message context.

getGatewayHostname

public String getGatewayHostname()

Getter for the Gateway host name.

Returns:

the name of the gateway host

getIotHubHostname

public String getIotHubHostname()

Getter for the IoT Hub hostname.

Returns:

the IoT Hub hostname.

getIotHubName

public String getIotHubName()

Getter for the IoT Hub name.

Returns:

the IoT Hub name.

getMessageLockTimeoutSecs

public int getMessageLockTimeoutSecs()

Getter for the timeout, in seconds, for the lock that the client has on a received message.

Returns:

the timeout, in seconds, for a received message lock.

getModuleId

public String getModuleId()

getOperationTimeout

public long getOperationTimeout()

Getter for the device operation timeout

Returns:

the amount of time, in milliseconds, before any device operation expires

getProductInfo

public ProductInfo getProductInfo()

getProtocol

public IotHubClientProtocol getProtocol()

getProxySettings

public ProxySettings getProxySettings()

getRetryPolicy

public RetryPolicy getRetryPolicy()

Getter for RetryPolicy

Returns:

The value of RetryPolicy

getSasTokenAuthentication

public IotHubSasTokenAuthenticationProvider getSasTokenAuthentication()

Getter for SasTokenAuthentication

Returns:

The value of SasTokenAuthentication, or null if this object isn't using sas token authentication

isUseWebsocket

public boolean isUseWebsocket()

Getter for Websocket

Returns:

true if set, false otherwise

setDeviceMethodsMessageCallback

public void setDeviceMethodsMessageCallback(MessageCallback callback, Object context)

Setter for the device method message callback.

Parameters:

callback - Callback for device method messages.
context - is the context for the callback.

setDeviceTwinMessageCallback

public void setDeviceTwinMessageCallback(MessageCallback callback, Object context)

Setter for the device twin message callback.

Parameters:

callback - callback to be invoked for device twin messages.
context - is the context for the callback.

setMessageCallback

public void setMessageCallback(MessageCallback callback, Object context)

Setter for the message callback. Can be null.

Parameters:

callback - the message callback. Can be null.
context - the context to be passed in to the callback.

setMessageCallback

public void setMessageCallback(String inputName, MessageCallback callback, Object context)

Parameters:

inputName
callback
context

setProxy

public void setProxy(ProxySettings proxySettings)

Parameters:

proxySettings

setRetryPolicy

public void setRetryPolicy(RetryPolicy retryPolicy)

Setter for RetryPolicy

Parameters:

retryPolicy - The types of retry policy to be used

Throws:

java.lang.IllegalArgumentException - if retry policy is null

setUseWebsocket

public void setUseWebsocket(boolean useWebsocket)

Setter for Websocket

Parameters:

useWebsocket - true if to be set, false otherwise

Applies to