Update MQTT reconnect, and import statements and color convert test

case.
This commit is contained in:
Admin
2017-10-19 15:56:15 -05:00
parent 5231eac4b0
commit b147f6606e
5 changed files with 20 additions and 19 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>5.0.0rc1</version>
<version>5.0.0rc2</version>
<packaging>jar</packaging>
<name>HA Bridge</name>

View File

@@ -12,8 +12,6 @@ import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
@@ -25,8 +23,6 @@ import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.protocol.HttpRequestExecutor;
import org.apache.http.util.EntityUtils;

View File

@@ -1,15 +1,8 @@
package com.bwssystems.HABridge.plugins.hue;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@@ -5,6 +5,7 @@ import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttSecurityException;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,6 +52,17 @@ public class MQTTHandler {
message.setRetained(Optional.ofNullable(retain).orElse(false));
try {
if(!myClient.isConnected()) {
try {
myClient.connect();
} catch (MqttSecurityException e1) {
log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage());
return;
} catch (MqttException e1) {
log.error("Could not retry connect to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e1.getMessage());
return;
}
}
myClient.publish(topic, message);
} catch (MqttException e) {
log.error("Could not publish to MQTT client for name: " + myConfig.getName() + " and ip: " + myConfig.getIp() + " with message: " + e.getMessage());

View File

@@ -13,14 +13,14 @@ public class ConvertCIEColorTestCase {
@Test
public void testColorConversion() {
//ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(new Double(0.671254), new Double(0.303273)));
ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(new Double(0.671254), new Double(0.303273)));
//List<Double> colorDecode = ColorDecode.convertCIEtoRGB(xy, 254);
//List<Double> assertDecode = new ArrayList<Double>();
//assertDecode.add(0, 255.0);
//assertDecode.add(1, 47.0);
//assertDecode.add(2, 43.0);
//Assert.assertEquals(colorDecode, assertDecode);
List<Integer> colorDecode = ColorDecode.convertCIEtoRGB(xy, 254);
List<Integer> assertDecode = new ArrayList<Integer>();
assertDecode.add(0, 255);
assertDecode.add(1, 47);
assertDecode.add(2, 43);
Assert.assertEquals(colorDecode, assertDecode);
}
}