public class DeviceMethod extends Object
| Constructor and Description |
|---|
DeviceMethod() |
| Modifier and Type | Method and Description |
|---|---|
static DeviceMethod |
createFromConnectionString(String connectionString)
Create a DeviceMethod instance from the information in the connection string.
|
MethodResult |
invoke(String deviceId,
String methodName,
Long responseTimeoutInSeconds,
Long connectTimeoutInSeconds,
Object payload)
Directly invokes a method on the device and return its result.
|
Job |
scheduleDeviceMethod(String queryCondition,
String methodName,
Long responseTimeoutInSeconds,
Long connectTimeoutInSeconds,
Object payload,
Date startTimeUtc,
long maxExecutionTimeInSeconds)
Creates a new Job to invoke method on one or multiple devices
|
public static DeviceMethod createFromConnectionString(String connectionString) throws IOException
connectionString - is the IoTHub connection string.IOException - This exception is thrown if the object creation failedpublic MethodResult invoke(String deviceId, String methodName, Long responseTimeoutInSeconds, Long connectTimeoutInSeconds, Object payload) throws IotHubException, IOException
deviceId - is the device identification.methodName - is the name of the method that shall be invoked on the device.responseTimeoutInSeconds - is the maximum waiting time for a response from the device in seconds.connectTimeoutInSeconds - is the maximum waiting time for a response from the connection in seconds.payload - is the the method parameterIotHubException - This exception is thrown if the response verification failedIOException - This exception is thrown if the IO operation failedpublic Job scheduleDeviceMethod(String queryCondition, String methodName, Long responseTimeoutInSeconds, Long connectTimeoutInSeconds, Object payload, Date startTimeUtc, long maxExecutionTimeInSeconds) throws IOException, IotHubException
queryCondition - Query condition to evaluate which devices to run the job on. It can be null or emptymethodName - Method name to be invokedresponseTimeoutInSeconds - Maximum interval of time, in seconds, that the Direct Method will wait for answer. It can be null.connectTimeoutInSeconds - Maximum interval of time, in seconds, that the Direct Method will wait for the connection. It can be null.payload - Object that contains the payload defined by the user. It can be null.startTimeUtc - Date time in Utc to start the jobmaxExecutionTimeInSeconds - Max execution time in seconds, i.e., ttl duration the job can runIOException - if the function contains invalid parametersIotHubException - if the http request failedCopyright © 2017. All rights reserved.