diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonHandlerFactory.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonHandlerFactory.java index d130910550893..4103443c0a937 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonHandlerFactory.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonHandlerFactory.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.discovery.InsteonDiscoveryService; import org.openhab.binding.insteon.internal.discovery.InsteonLegacyDiscoveryService; import org.openhab.binding.insteon.internal.handler.InsteonBridgeHandler; @@ -29,6 +30,7 @@ import org.openhab.binding.insteon.internal.handler.InsteonSceneHandler; import org.openhab.binding.insteon.internal.handler.X10DeviceHandler; import org.openhab.core.config.discovery.DiscoveryService; +import org.openhab.core.io.net.http.HttpClientFactory; import org.openhab.core.io.transport.serial.SerialPortManager; import org.openhab.core.storage.StorageService; import org.openhab.core.thing.Bridge; @@ -56,6 +58,7 @@ @Component(configurationPid = "binding.insteon", service = ThingHandlerFactory.class) public class InsteonHandlerFactory extends BaseThingHandlerFactory { + private final HttpClient httpClient; private final SerialPortManager serialPortManager; private final InsteonStateDescriptionProvider stateDescriptionProvider; private final StorageService storageService; @@ -64,10 +67,12 @@ public class InsteonHandlerFactory extends BaseThingHandlerFactory { private final Map> discoveryServiceRegs = new HashMap<>(); @Activate - public InsteonHandlerFactory(final @Reference SerialPortManager serialPortManager, + public InsteonHandlerFactory(final @Reference HttpClientFactory httpClientFactory, + final @Reference SerialPortManager serialPortManager, final @Reference InsteonStateDescriptionProvider stateDescriptionProvider, final @Reference StorageService storageService, final @Reference ThingManager thingManager, final @Reference ThingRegistry thingRegistry) { + this.httpClient = httpClientFactory.getCommonHttpClient(); this.serialPortManager = serialPortManager; this.stateDescriptionProvider = stateDescriptionProvider; this.storageService = storageService; @@ -86,14 +91,14 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { if (THING_TYPE_HUB1.equals(thingTypeUID) || THING_TYPE_HUB2.equals(thingTypeUID) || THING_TYPE_PLM.equals(thingTypeUID)) { - InsteonBridgeHandler handler = new InsteonBridgeHandler((Bridge) thing, serialPortManager, storageService, - thingRegistry); + InsteonBridgeHandler handler = new InsteonBridgeHandler((Bridge) thing, httpClient, serialPortManager, + storageService, thingRegistry); InsteonDiscoveryService service = new InsteonDiscoveryService(handler); registerDiscoveryService(handler, service); return handler; } else if (THING_TYPE_LEGACY_NETWORK.equals(thingTypeUID)) { - InsteonLegacyNetworkHandler handler = new InsteonLegacyNetworkHandler((Bridge) thing, serialPortManager, - thingManager, thingRegistry); + InsteonLegacyNetworkHandler handler = new InsteonLegacyNetworkHandler((Bridge) thing, httpClient, + serialPortManager, thingManager, thingRegistry); InsteonLegacyDiscoveryService service = new InsteonLegacyDiscoveryService(handler); registerDiscoveryService(handler, service); return handler; diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonLegacyBinding.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonLegacyBinding.java index 94e240b418132..5fe2316a46cb1 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonLegacyBinding.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/InsteonLegacyBinding.java @@ -27,6 +27,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.config.InsteonLegacyChannelConfiguration; import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration; import org.openhab.binding.insteon.internal.device.DeviceAddress; @@ -119,13 +120,13 @@ public class InsteonLegacyBinding implements LegacyDriverListener, LegacyPortLis private InsteonLegacyNetworkHandler handler; public InsteonLegacyBinding(InsteonLegacyNetworkHandler handler, InsteonLegacyNetworkConfiguration config, - SerialPortManager serialPortManager, ScheduledExecutorService scheduler) { + HttpClient httpClient, ScheduledExecutorService scheduler, SerialPortManager serialPortManager) { this.handler = handler; String port = config.getRedactedPort(); logger.debug("port = '{}'", port); - driver = new LegacyDriver(config, this, serialPortManager, scheduler); + driver = new LegacyDriver(config, this, httpClient, scheduler, serialPortManager); driver.addPortListener(this); Integer devicePollIntervalSeconds = config.getDevicePollIntervalSeconds(); diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/InsteonModem.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/InsteonModem.java index d3328d8cd8e74..9c22c24c83167 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/InsteonModem.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/device/InsteonModem.java @@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.config.InsteonBridgeConfiguration; import org.openhab.binding.insteon.internal.device.database.DatabaseManager; import org.openhab.binding.insteon.internal.device.database.ModemDB; @@ -53,10 +54,10 @@ public class InsteonModem extends BaseDevice reconnectJob; private @Nullable ScheduledFuture resetJob; private @Nullable ScheduledFuture statisticsJob; + private HttpClient httpClient; private SerialPortManager serialPortManager; private Storage storage; private ThingRegistry thingRegistry; - public InsteonBridgeHandler(Bridge bridge, SerialPortManager serialPortManager, StorageService storageService, - ThingRegistry thingRegistry) { + public InsteonBridgeHandler(Bridge bridge, HttpClient httpClient, SerialPortManager serialPortManager, + StorageService storageService, ThingRegistry thingRegistry) { super(bridge); + this.httpClient = httpClient; this.serialPortManager = serialPortManager; this.storage = storageService.getStorage(bridge.getUID().toString(), DeviceCache.class.getClassLoader()); this.thingRegistry = thingRegistry; @@ -164,7 +167,7 @@ public void initialize() { legacyHandler.disable(); } - InsteonModem modem = InsteonModem.makeModem(this, config, scheduler, serialPortManager); + InsteonModem modem = InsteonModem.makeModem(this, config, httpClient, scheduler, serialPortManager); this.modem = modem; if (isInitialized()) { diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonLegacyNetworkHandler.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonLegacyNetworkHandler.java index f04c693738e08..53471200dd378 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonLegacyNetworkHandler.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/handler/InsteonLegacyNetworkHandler.java @@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.InsteonLegacyBinding; import org.openhab.binding.insteon.internal.config.InsteonBridgeConfiguration; import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration; @@ -67,6 +68,7 @@ public class InsteonLegacyNetworkHandler extends BaseBridgeHandler { private @Nullable ScheduledFuture reconnectJob = null; private @Nullable ScheduledFuture settleJob = null; private long lastInsteonDeviceCreatedTimestamp = 0; + private HttpClient httpClient; private SerialPortManager serialPortManager; private ThingManager thingManager; private ThingRegistry thingRegistry; @@ -74,9 +76,10 @@ public class InsteonLegacyNetworkHandler extends BaseBridgeHandler { private Map channelInfo = new ConcurrentHashMap<>(); private Map channelConfigs = new ConcurrentHashMap<>(); - public InsteonLegacyNetworkHandler(Bridge bridge, SerialPortManager serialPortManager, ThingManager thingManager, - ThingRegistry thingRegistry) { + public InsteonLegacyNetworkHandler(Bridge bridge, HttpClient httpClient, SerialPortManager serialPortManager, + ThingManager thingManager, ThingRegistry thingRegistry) { super(bridge); + this.httpClient = httpClient; this.serialPortManager = serialPortManager; this.thingManager = thingManager; this.thingRegistry = thingRegistry; @@ -105,7 +108,7 @@ public void initialize() { return; } - insteonBinding = new InsteonLegacyBinding(this, config, serialPortManager, scheduler); + insteonBinding = new InsteonLegacyBinding(this, config, httpClient, scheduler, serialPortManager); updateStatus(ThingStatus.UNKNOWN); // hold off on starting to poll until devices that already are defined as things are added. @@ -136,7 +139,7 @@ public void initialize() { this.driverInitializedJob = null; } } else { - logger.debug("driver is not initialized yet"); + logger.trace("driver is not initialized yet"); } }, 0, DRIVER_INITIALIZED_TIME_IN_SECONDS, TimeUnit.SECONDS); } else { diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/HubIOStream.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/HubIOStream.java index a7fb1c2375afe..14eff4bccbd96 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/HubIOStream.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/HubIOStream.java @@ -12,23 +12,27 @@ */ package org.openhab.binding.insteon.internal.transport; -import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Objects; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.http.HttpHeader; +import org.eclipse.jetty.http.HttpStatus; import org.openhab.binding.insteon.internal.utils.HexUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,6 +56,7 @@ public class HubIOStream extends IOStream { private int port; private String auth; private int pollInterval; + private HttpClient httpClient; private ScheduledExecutorService scheduler; private @Nullable ScheduledFuture job; // index of the last byte we have read in the buffer @@ -65,14 +70,16 @@ public class HubIOStream extends IOStream { * @param username hub user name * @param password hub password * @param pollInterval hub poll interval (in milliseconds) + * @param httpClient the http client * @param scheduler the scheduler */ - public HubIOStream(String host, int port, String username, String password, int pollInterval, + public HubIOStream(String host, int port, String username, String password, int pollInterval, HttpClient httpClient, ScheduledExecutorService scheduler) { this.host = host; this.port = port; this.auth = Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)); this.pollInterval = pollInterval; + this.httpClient = httpClient; this.scheduler = scheduler; } @@ -265,54 +272,30 @@ private boolean isClearedBuffer(String data) { /** * Helper method to fetch url from http server * - * @param resource the url + * @param path the url path * @return contents returned by http server * @throws IOException */ - private String getURL(String resource) throws IOException { - String url = "http://" + host + ":" + port + resource; + private String getURL(String path) throws IOException { + Request request = httpClient.newRequest(host, port).path(path).header(HttpHeader.AUTHORIZATION, "Basic " + auth) + .timeout(30, TimeUnit.SECONDS); + logger.trace("getting {}", request.getURI()); - HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); try { - connection.setConnectTimeout(30000); - connection.setReadTimeout(10000); - connection.setUseCaches(false); - connection.setDoInput(true); - connection.setDoOutput(false); - connection.setRequestProperty("Authorization", "Basic " + auth); - - logger.trace("getting {}", url); - - int responseCode = connection.getResponseCode(); - if (responseCode != 200) { - if (responseCode == 401) { + ContentResponse response = request.send(); + + int statusCode = response.getStatus(); + switch (statusCode) { + case HttpStatus.OK_200: + return response.getContentAsString(); + case HttpStatus.UNAUTHORIZED_401: throw new IOException( "Bad username or password. See the label on the bottom of the hub for the correct login information."); - } else { - throw new IOException(url + " failed with the response code: " + responseCode); - } - } - - return getData(connection.getInputStream()); - } finally { - connection.disconnect(); - } - } - - private String getData(InputStream is) throws IOException { - BufferedInputStream bis = new BufferedInputStream(is); - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int length = 0; - while ((length = bis.read(buffer)) != -1) { - baos.write(buffer, 0, length); + default: + throw new IOException("GET " + request.getURI() + " failed with status code: " + statusCode); } - - String s = baos.toString(); - return s; - } finally { - bis.close(); + } catch (InterruptedException | TimeoutException | ExecutionException e) { + throw new IOException("GET " + request.getURI() + " failed with error: " + e.getMessage()); } } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/IOStream.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/IOStream.java index 3005f6a619f8b..1e2cb90646db5 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/IOStream.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/IOStream.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.config.InsteonBridgeConfiguration; import org.openhab.binding.insteon.internal.config.InsteonHub1Configuration; import org.openhab.binding.insteon.internal.config.InsteonHub2Configuration; @@ -113,16 +114,17 @@ public void write(byte @Nullable [] b) throws InterruptedException, IOException * Creates an IOStream from an insteon bridge config object * * @param config + * @param httpClient * @param scheduler * @param serialPortManager * @return reference to IOStream */ - public static IOStream create(InsteonBridgeConfiguration config, ScheduledExecutorService scheduler, - SerialPortManager serialPortManager) { + public static IOStream create(InsteonBridgeConfiguration config, HttpClient httpClient, + ScheduledExecutorService scheduler, SerialPortManager serialPortManager) { if (config instanceof InsteonHub1Configuration hub1Config) { return makeTcpIOStream(hub1Config); } else if (config instanceof InsteonHub2Configuration hub2Config) { - return makeHubIOStream(hub2Config, scheduler); + return makeHubIOStream(hub2Config, httpClient, scheduler); } else if (config instanceof InsteonPLMConfiguration plmConfig) { return makeSerialIOStream(plmConfig, serialPortManager); } else { @@ -130,13 +132,14 @@ public static IOStream create(InsteonBridgeConfiguration config, ScheduledExecut } } - private static HubIOStream makeHubIOStream(InsteonHub2Configuration config, ScheduledExecutorService scheduler) { + private static HubIOStream makeHubIOStream(InsteonHub2Configuration config, HttpClient httpClient, + ScheduledExecutorService scheduler) { String host = config.getHostname(); int port = config.getPort(); String user = config.getUsername(); String pass = config.getPassword(); int pollInterval = config.getHubPollInterval(); - return new HubIOStream(host, port, user, pass, pollInterval, scheduler); + return new HubIOStream(host, port, user, pass, pollInterval, httpClient, scheduler); } private static SerialIOStream makeSerialIOStream(InsteonPLMConfiguration config, diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyDriver.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyDriver.java index 84b159616d8d2..0f47105d8aeea 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyDriver.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyDriver.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration; import org.openhab.binding.insteon.internal.device.InsteonAddress; import org.openhab.binding.insteon.internal.device.LegacyPollManager; @@ -44,11 +45,11 @@ public class LegacyDriver { private Map modemDBEntries = new HashMap<>(); private ReentrantLock modemDBEntriesLock = new ReentrantLock(); - public LegacyDriver(InsteonLegacyNetworkConfiguration config, LegacyDriverListener listener, - SerialPortManager serialPortManager, ScheduledExecutorService scheduler) { + public LegacyDriver(InsteonLegacyNetworkConfiguration config, LegacyDriverListener listener, HttpClient httpClient, + ScheduledExecutorService scheduler, SerialPortManager serialPortManager) { this.listener = listener; - this.port = new LegacyPort(config, this, serialPortManager, scheduler); + this.port = new LegacyPort(config, this, httpClient, scheduler, serialPortManager); this.poller = new LegacyPollManager(scheduler); this.requester = new LegacyRequestManager(scheduler); } diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyPort.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyPort.java index bc948ad275faa..6d8ba6166db5c 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyPort.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/LegacyPort.java @@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.InsteonLegacyBindingConstants; import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration; import org.openhab.binding.insteon.internal.device.InsteonAddress; @@ -74,10 +75,10 @@ enum ReplyType { private IOStream ioStream; private String name; - private Modem modem; + private Modem modem = new Modem(); private ScheduledExecutorService scheduler; - private IOStreamReader reader; - private IOStreamWriter writer; + private IOStreamReader reader = new IOStreamReader(); + private IOStreamWriter writer = new IOStreamWriter(); private @Nullable ScheduledFuture readJob; private @Nullable ScheduledFuture writeJob; private boolean running = false; @@ -94,19 +95,16 @@ enum ReplyType { * * @param config the network bridge config * @param driver the driver that manages this port - * @param serialPortManager the serial port manager + * @param httpClient the http client * @param scheduler the scheduler + * @param serialPortManager the serial port manager */ - public LegacyPort(InsteonLegacyNetworkConfiguration config, LegacyDriver driver, - SerialPortManager serialPortManager, ScheduledExecutorService scheduler) { + public LegacyPort(InsteonLegacyNetworkConfiguration config, LegacyDriver driver, HttpClient httpClient, + ScheduledExecutorService scheduler, SerialPortManager serialPortManager) { this.name = config.getRedactedPort(); this.driver = driver; this.scheduler = scheduler; - this.modem = new Modem(); - addListener(modem); - this.ioStream = IOStream.create(config.parse(), scheduler, serialPortManager); - this.reader = new IOStreamReader(); - this.writer = new IOStreamWriter(); + this.ioStream = IOStream.create(config.parse(), httpClient, scheduler, serialPortManager); this.mdbb = new LegacyModemDBBuilder(this, scheduler); } @@ -115,7 +113,7 @@ public boolean isModem(InsteonAddress a) { } public synchronized boolean isModemDBComplete() { - return (modemDBComplete); + return modemDBComplete; } public boolean isRunning() { @@ -496,6 +494,7 @@ private void initDevice(InsteonAddress a, @Nullable LegacyDevice device) { public void initialize() { try { Msg msg = Msg.makeMessage("GetIMInfo"); + addListener(this); writeMessage(msg); } catch (IOException e) { logger.warn("modem init failed!", e); diff --git a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/Port.java b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/Port.java index 242262a9031f8..f57d15da7c953 100644 --- a/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/Port.java +++ b/bundles/org.openhab.binding.insteon/src/main/java/org/openhab/binding/insteon/internal/transport/Port.java @@ -23,6 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.insteon.internal.config.InsteonBridgeConfiguration; import org.openhab.binding.insteon.internal.transport.message.Msg; import org.openhab.binding.insteon.internal.transport.message.MsgFactory; @@ -64,8 +65,8 @@ private static enum ReplyType { private String name; private ScheduledExecutorService scheduler; private IOStream ioStream; - private IOStreamReader reader; - private IOStreamWriter writer; + private IOStreamReader reader = new IOStreamReader(); + private IOStreamWriter writer = new IOStreamWriter(); private @Nullable ScheduledFuture readJob; private @Nullable ScheduledFuture writeJob; private MsgFactory msgFactory = new MsgFactory(); @@ -73,13 +74,11 @@ private static enum ReplyType { private LinkedBlockingQueue writeQueue = new LinkedBlockingQueue<>(); private AtomicBoolean connected = new AtomicBoolean(false); - public Port(InsteonBridgeConfiguration config, ScheduledExecutorService scheduler, + public Port(InsteonBridgeConfiguration config, HttpClient httpClient, ScheduledExecutorService scheduler, SerialPortManager serialPortManager) { this.name = config.getId(); this.scheduler = scheduler; - this.ioStream = IOStream.create(config, scheduler, serialPortManager); - this.reader = new IOStreamReader(); - this.writer = new IOStreamWriter(); + this.ioStream = IOStream.create(config, httpClient, scheduler, serialPortManager); } public String getName() {