Search in sources :

Example 11 with Device

use of com.microsoft.azure.sdk.iot.service.Device in project azure-iot-sdk-java by Azure.

the class DeviceManagerSample method GetDevice.

private static void GetDevice() throws Exception {
    RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString);
    Device returnDevice = null;
    try {
        returnDevice = registryManager.getDevice(SampleUtils.deviceId);
        System.out.println("Device: " + returnDevice.getDeviceId());
        System.out.println("Device primary key: " + returnDevice.getPrimaryKey());
        System.out.println("Device secondary key: " + returnDevice.getSecondaryKey());
        System.out.println("Device eTag: " + returnDevice.geteTag());
    } catch (IotHubException iote) {
        iote.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Device(com.microsoft.azure.sdk.iot.service.Device) RegistryManager(com.microsoft.azure.sdk.iot.service.RegistryManager) IOException(java.io.IOException) IotHubException(com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)

Aggregations

Device (com.microsoft.azure.sdk.iot.service.Device)11 Test (org.junit.Test)8 RegistryManager (com.microsoft.azure.sdk.iot.service.RegistryManager)3 IotHubException (com.microsoft.azure.sdk.iot.service.exceptions.IotHubException)3 IOException (java.io.IOException)3 SymmetricKey (com.microsoft.azure.sdk.iot.service.auth.SymmetricKey)2 NonStrictExpectations (mockit.NonStrictExpectations)2 DeviceStatus (com.microsoft.azure.sdk.iot.service.DeviceStatus)1 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Expectations (mockit.Expectations)1