examples/iot-nirvana/client/src/main/java/com/google/cloud/demo/iot/nirvana/client/IotDeviceMgr.java
/**
   * Create a new IoT device and register it in a Cloud IoT Core registry.
   *
   * @param rsaCertificateFilePath Path to the file containing the device certificate
   * @param privateKey Path to the file containing the device private key
   * @param cityIndex Index of the city for which to generate temperatures
   * @return device, instance of {@link IotDevice}
   * @throws ClientException
   */
Create a new IoT device and register it in a Cloud IoT Core registry.
Create a new IoT device and register it in a Cloud IoT Core registry .
public IotDevice newRegisteredDevice(
      String rsaCertificateFilePath, String privateKey, String cityIndex) throws ClientException {
    String deviceId = generateDeviceId();
    String iotCoreRegistryPath = generateRegistryPath();
    IotDevice device =
        IotDevice.newBuilder()
            .setDeviceId(deviceId)
            .setDevicePath(generateDevicePath(deviceId, iotCoreRegistryPath))
            .setCityIndex(cityIndex)
            .setPrivateKey(privateKey)
            .setGcpProjectId(getGcpProjectId())
            .build();
    registerDevice(device, iotCoreRegistryPath, rsaCertificateFilePath);
    return device;
  }
public IotDevice newRegisteredDevice ( String rsaCertificateFilePath , String privateKey , String cityIndex ) throws ClientException { String deviceId = generateDeviceId ( ) ; String iotCoreRegistryPath = generateRegistryPath ( ) ; IotDevice device = IotDevice . newBuilder ( ) . setDeviceId ( deviceId ) . setDevicePath ( generateDevicePath ( deviceId , iotCoreRegistryPath ) ) . setCityIndex ( cityIndex ) . setPrivateKey ( privateKey ) . setGcpProjectId ( getGcpProjectId ( ) ) . build ( ) ; registerDevice ( device , iotCoreRegistryPath , rsaCertificateFilePath ) ; return device ; }
Create a new IoT device and register it in a Cloud IoT Core registry.
Create a new IoT device and register it in a Cloud IoT Core registry .