Search in sources :

Example 1 with ClientOptions

use of com.microsoft.azure.sdk.iot.device.ClientOptions in project azure-iot-sdk-java by Azure.

the class TokenCredentialTests method createDeviceClient.

private DeviceClient createDeviceClient(IotHubClientProtocol protocol, RegistryManager registryManager) throws IOException, IotHubException, URISyntaxException {
    ClientOptions options = new ClientOptions();
    options.setModelId(THERMOSTAT_MODEL_ID);
    String deviceId = "some-device-" + UUID.randomUUID();
    Device device = Device.createDevice(deviceId, AuthenticationType.SAS);
    Device registeredDevice = registryManager.addDevice(device);
    String deviceConnectionString = registryManager.getDeviceConnectionString(registeredDevice);
    return new DeviceClient(deviceConnectionString, protocol, options);
}
Also used : ClientOptions(com.microsoft.azure.sdk.iot.device.ClientOptions) DigitalTwinClientOptions(com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClientOptions) DeviceTwinClientOptions(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinClientOptions) DeviceMethodClientOptions(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceMethodClientOptions) Device(com.microsoft.azure.sdk.iot.service.Device) DeviceTwinDevice(com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice) DeviceClient(com.microsoft.azure.sdk.iot.device.DeviceClient) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString)

Example 2 with ClientOptions

use of com.microsoft.azure.sdk.iot.device.ClientOptions in project azure-iot-sdk-java by Azure.

the class DigitalTwinClientTests method createDeviceClient.

private DeviceClient createDeviceClient(IotHubClientProtocol protocol, String modelId) throws IOException, IotHubException, URISyntaxException {
    ClientOptions options = new ClientOptions();
    options.setModelId(modelId);
    this.deviceId = DEVICE_ID_PREFIX.concat(UUID.randomUUID().toString());
    Device device = Device.createDevice(deviceId, AuthenticationType.SAS);
    Device registeredDevice = registryManager.addDevice(device);
    String deviceConnectionString = registryManager.getDeviceConnectionString(registeredDevice);
    return new DeviceClient(deviceConnectionString, protocol, options);
}
Also used : ClientOptions(com.microsoft.azure.sdk.iot.device.ClientOptions) DigitalTwinClientOptions(com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClientOptions) Device(com.microsoft.azure.sdk.iot.service.Device) DeviceClient(com.microsoft.azure.sdk.iot.device.DeviceClient) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString)

Aggregations

ClientOptions (com.microsoft.azure.sdk.iot.device.ClientOptions)2 DeviceClient (com.microsoft.azure.sdk.iot.device.DeviceClient)2 Device (com.microsoft.azure.sdk.iot.service.Device)2 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)2 DigitalTwinClientOptions (com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClientOptions)2 DeviceMethodClientOptions (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceMethodClientOptions)1 DeviceTwinClientOptions (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinClientOptions)1 DeviceTwinDevice (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice)1