use of io.enmasse.iot.transport.AmqpClient in project enmasse-workshop by EnMasseProject.
the class HeatingDevice method init.
@SuppressWarnings("unchecked")
@Override
public void init(Properties config) {
this.config = config;
log.info("Init with config {}", config);
// initializing sensors and actuators
Properties configDht22 = new Properties();
configDht22.setProperty("min", this.config.getProperty(DeviceConfig.DHT22_TEMPERATURE_MIN));
configDht22.setProperty("max", this.config.getProperty(DeviceConfig.DHT22_TEMPERATURE_MAX));
this.dht22.init(configDht22);
this.valve.init(null);
// getting hostname and port for client connection
String hostname = this.config.getProperty(DeviceConfig.HOSTNAME);
int port = Integer.valueOf(this.config.getProperty(DeviceConfig.PORT));
String serverCert = this.config.getProperty(DeviceConfig.TRANSPORT_SSL_SERVER_CERT);
try {
// getting and creating the transport class to use
Class transportClass = Class.forName(this.config.getProperty(DeviceConfig.TRANSPORT_CLASS));
Constructor constructor = transportClass.getConstructor(String.class, int.class, String.class, Vertx.class);
this.client = (Client) constructor.newInstance(hostname, port, serverCert, this.vertx);
log.info("Using {} as transport", transportClass);
} catch (Exception e) {
log.error("Transport class instantiation error ...", e);
this.client = new AmqpClient(hostname, port, serverCert, this.vertx);
log.info("Using default {} as transport", AmqpClient.class);
}
}
Aggregations