diff --git a/pom.xml b/pom.xml
index d31465c..3696355 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.bwssystems.HABridge
ha-bridge
- 1.2.2
+ 1.2.2a
jar
HA Bridge
diff --git a/src/main/java/com/bwssystems/HABridge/api/hue/HueConfig.java b/src/main/java/com/bwssystems/HABridge/api/hue/HueConfig.java
index b80b3bc..1ec06e1 100644
--- a/src/main/java/com/bwssystems/HABridge/api/hue/HueConfig.java
+++ b/src/main/java/com/bwssystems/HABridge/api/hue/HueConfig.java
@@ -84,6 +84,10 @@ public class HueConfig
sb.append("00:00:88:00:bb:ee");
+ } catch (Exception e){
+
+ sb.append("00:00:88:00:bb:ee");
+
}
return sb.toString();
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index 42e494c..d918ff5 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -117,7 +117,7 @@ public class HueMulator {
String aDeviceType = null;
if(bridgeSettings.isTraceupnp())
- log.info("Traceupnp: hue api user create requested: " + request.body() + " from " + request.ip());
+ log.info("Traceupnp: hue api/ user create requested: " + request.body() + " from " + request.ip());
log.debug("hue api user create requested: " + request.body() + " from " + request.ip());
if(request.body() != null && !request.body().isEmpty()) {
@@ -155,7 +155,8 @@ public class HueMulator {
String newUser = null;
String aDeviceType = null;
- log.info("HH trace: hue api user create requested: " + request.body() + " from " + request.ip());
+ if(bridgeSettings.isTraceupnp())
+ log.info("Traceupnp: hue api/* user create requested: " + request.body() + " from " + request.ip());
if(request.body() != null && !request.body().isEmpty()) {
aNewUser = new Gson().fromJson(request.body(), UserCreateRequest.class);
@@ -177,22 +178,26 @@ public class HueMulator {
// http://ip_address:port/api/config returns json objects for the config when no user is given
get(HUE_CONTEXT + "/config", "application/json", (request, response) -> {
- String userId = request.params(":userid");
- log.debug("hue api config requested: " + userId + " from " + request.ip());
- HueApiResponse apiResponse = new HueApiResponse("Philips hue", request.ip(), "My App", userId);
+ if(bridgeSettings.isTraceupnp())
+ log.info("Traceupnp: hue api/config config requested: from " + request.ip());
+ log.debug("hue api config requested: from " + request.ip());
+ HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), "My App", "none");
response.type("application/json; charset=utf-8");
response.status(HttpStatus.SC_OK);
- String responseString = null;
- responseString = "[{\"swversion\":\"" + apiResponse.getConfig().getSwversion() + "\",\"apiversion\":\"" + apiResponse.getConfig().getApiversion() + "\",\"name\":\"" + apiResponse.getConfig().getName() + "\",\"mac\":\"" + apiResponse.getConfig().getMac() + "\"}]";
- return responseString;
- });
+// String responseString = null;
+// responseString = "[{\"swversion\":\"" + apiResponse.getConfig().getSwversion() + "\",\"apiversion\":\"" + apiResponse.getConfig().getApiversion() + "\",\"name\":\"" + apiResponse.getConfig().getName() + "\",\"mac\":\"" + apiResponse.getConfig().getMac() + "\"}]";
+// return responseString;
+ return apiResponse.getConfig();
+ }, new JsonTransformer());
// http://ip_address:port/api/{userId}/config returns json objects for the config
get(HUE_CONTEXT + "/:userid/config", "application/json", (request, response) -> {
String userId = request.params(":userid");
+ if(bridgeSettings.isTraceupnp())
+ log.info("Traceupnp: hue api/:userid/config config requested: " + userId + " from " + request.ip());
log.debug("hue api config requested: " + userId + " from " + request.ip());
- HueApiResponse apiResponse = new HueApiResponse("Philips hue", request.ip(), "My App", userId);
+ HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), "My App", userId);
response.type("application/json; charset=utf-8");
response.status(HttpStatus.SC_OK);
@@ -216,7 +221,7 @@ public class HueMulator {
deviceList.put(descriptor.getId(), deviceResponse);
}
);
- HueApiResponse apiResponse = new HueApiResponse("Philips hue", request.ip(), "My App", userId);
+ HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), "My App", userId);
apiResponse.setLights(deviceList);
response.type("application/json; charset=utf-8");
diff --git a/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java b/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java
index 70c1833..f13a456 100644
--- a/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java
+++ b/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java
@@ -96,30 +96,33 @@ public class UpnpListener {
//Only respond to discover request for strict upnp form
String packetString = new String(packet.getData());
if(packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1") && packetString.contains("\"ssdp:discover\"")){
- if(traceupnp) {
- log.info("Traceupnp: SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
- log.info("Traceupnp: isSSDPDiscovery found message to be an M-SEARCH message.");
- }
- else {
- log.debug("Got SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
- log.debug("Found message to be an M-SEARCH message.");
- }
+ log.debug("isSSDPDiscovery Found message to be an M-SEARCH message.");
+ log.debug("isSSDPDiscovery Got SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
if(strict && (packetString.contains("ST: urn:schemas-upnp-org:device:basic:1") || packetString.contains("ST: upnp:rootdevice") || packetString.contains("ST: ssdp:all")))
{
- if(traceupnp)
+ if(traceupnp) {
+ log.info("Traceupnp: isSSDPDiscovery found message to be an M-SEARCH message.");
log.info("Traceupnp: isSSDPDiscovery found message to be valid under strict rules - strict: " + strict);
+ log.info("Traceupnp: SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
+ }
+ log.debug("isSSDPDiscovery found message to be valid under strict rules - strict: " + strict);
return true;
}
else if (!strict)
{
- if(traceupnp)
+ if(traceupnp) {
+ log.info("Traceupnp: isSSDPDiscovery found message to be an M-SEARCH message.");
log.info("Traceupnp: isSSDPDiscovery found message to be valid under loose rules - strict: " + strict);
+ log.info("Traceupnp: SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
+ }
+ log.debug("isSSDPDiscovery found message to be valid under loose rules - strict: " + strict);
return true;
}
}
- if(traceupnp)
- log.info("Traceupnp: isSSDPDiscovery found message to not be valid - strict: " + strict);
+ log.debug("isSSDPDiscovery found message to be an M-SEARCH message.");
+ log.debug("isSSDPDiscovery found message to not be valid - strict: " + strict);
+ log.debug("SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + ", body: " + packetString);
return false;
}