From 6c99358f95b60eea00bbd9c0ba4a9a5a129cd3dd Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 31 Aug 2015 16:44:38 -0500 Subject: [PATCH] Updated upnp response listener code. Updated hue api. Updated input areas for urls to be textareas to handle long strings. Added sorting to all lists. --- pom.xml | 2 +- .../bwssystems/HABridge/hue/HueMulator.java | 2 +- .../HABridge/upnp/UpnpListener.java | 11 ++--- src/main/resources/public/index.html | 2 +- src/main/resources/public/scripts/app.js | 14 +++++- .../resources/public/views/configuration.html | 23 ++++++++-- .../resources/public/views/editdevice.html | 14 ++++-- src/main/resources/public/views/editor.html | 22 +++++++--- .../resources/public/views/veradevice.html | 44 +++++++++++++++---- .../resources/public/views/verascene.html | 39 ++++++++++++---- 10 files changed, 130 insertions(+), 43 deletions(-) diff --git a/pom.xml b/pom.xml index 5049512..a0f6388 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 0.3.5 + 0.4.0 jar HA Bridge diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java index 555c017..5bf6da6 100644 --- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java +++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java @@ -44,7 +44,7 @@ public class HueMulator { public HueMulator(DeviceRepository aDeviceRepository){ - httpClient = HttpClients.createMinimal(); + httpClient = HttpClients.createDefault(); mapper = new ObjectMapper(); //armzilla: work around Echo incorrect content type and breaking mapping. Map manually mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); repository = aDeviceRepository; diff --git a/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java b/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java index 09454c3..e54fbf5 100644 --- a/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java +++ b/src/main/java/com/bwssystems/HABridge/upnp/UpnpListener.java @@ -63,14 +63,8 @@ public class UpnpListener { DatagramPacket packet = new DatagramPacket(buf, buf.length); upnpMulticastSocket.receive(packet); String packetString = new String(packet.getData()); + log.debug("Got SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + " body : " + packetString); if(isSSDPDiscovery(packetString)){ - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - log.error("could not sleep"); - } - log.debug("Got SSDP Discovery packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort()); sendUpnpResponse(responseSocket, packet.getAddress(), packet.getPort()); } } @@ -91,7 +85,8 @@ public class UpnpListener { protected boolean isSSDPDiscovery(String body){ // log.debug("Check if this is a MAN ssdp-discover packet for a upnp basic device: " + body); //Only respond to discover request for upnp basic device from echo, the others are for the wemo - if(body != null && body.startsWith("M-SEARCH * HTTP/1.1") && body.contains("MAN: \"ssdp:discover\"")&& body.contains("ST: urn:schemas-upnp-org:device:basic:1")){ + // other check: && body.contains("ST: urn:schemas-upnp-org:device:basic:1") + if(body != null && body.startsWith("M-SEARCH * HTTP/1.1") && body.contains("MAN: \"ssdp:discover\"")){ return true; } return false; diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html index b4dae70..6c8caf3 100644 --- a/src/main/resources/public/index.html +++ b/src/main/resources/public/index.html @@ -41,7 +41,7 @@ diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index 2f5bb0f..f99d155 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -207,6 +207,12 @@ app.controller('ViewingController', function ($scope, $location, bridgeService, $scope.BridgeSettings = bridgeService.BridgeSettings; bridgeService.viewDevices(); $scope.bridge = bridgeService.state; + $scope.predicate = 'name'; + $scope.reverse = true; + $scope.order = function(predicate) { + $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false; + $scope.predicate = predicate; + }; $scope.deleteDevice = function (device) { bridgeService.deleteDevice(device.id); }; @@ -233,7 +239,13 @@ app.controller('AddingController', function ($scope, bridgeService, BridgeSettin bridgeService.viewVeraScenes(); $scope.bridge = bridgeService.state; $scope.device = bridgeService.state.device; - + $scope.predicate = 'name'; + $scope.reverse = true; + $scope.order = function(predicate) { + $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false; + $scope.predicate = predicate; + }; + $scope.buildUrlsUsingDevice = function () { if ($scope.vera.base.indexOf("http") < 0) { $scope.vera.base = "http://" + $scope.vera.base; diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html index b4f799a..c1e90cb 100644 --- a/src/main/resources/public/views/configuration.html +++ b/src/main/resources/public/views/configuration.html @@ -71,6 +71,15 @@ + +

Current devices

@@ -78,13 +87,19 @@ - - - + + + - + diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html index 1bcf49f..e5202a9 100644 --- a/src/main/resources/public/views/editdevice.html +++ b/src/main/resources/public/views/editdevice.html @@ -25,26 +25,32 @@ Update Device
+
- +
+
+
+
- +
+
+
diff --git a/src/main/resources/public/views/editor.html b/src/main/resources/public/views/editor.html index 357d696..53d4c6d 100644 --- a/src/main/resources/public/views/editor.html +++ b/src/main/resources/public/views/editor.html @@ -42,11 +42,13 @@ + +
@@ -61,6 +63,7 @@
  • +
    @@ -70,28 +73,35 @@
    +
    +
    - +
    +
    +
    +
    - +
    +
    +
  • diff --git a/src/main/resources/public/views/veradevice.html b/src/main/resources/public/views/veradevice.html index edda376..6b11438 100644 --- a/src/main/resources/public/views/veradevice.html +++ b/src/main/resources/public/views/veradevice.html @@ -9,6 +9,14 @@

    Vera Device List

    +
    • You can select a Vera device and generate @@ -17,14 +25,26 @@

    IDNameType + ID + + Name + + Type + Actions
    {{device.id}} {{device.name}} {{device.deviceType}}
    - - - - + + + + - + @@ -58,26 +78,32 @@ Add Device
    +
    - +
    +
    +
    +
    - +
    +
    +
    diff --git a/src/main/resources/public/views/verascene.html b/src/main/resources/public/views/verascene.html index 7d9210f..23e1f20 100644 --- a/src/main/resources/public/views/verascene.html +++ b/src/main/resources/public/views/verascene.html @@ -9,6 +9,14 @@

    Vera Scene List

    +
    • You can select a Vera scene and generate @@ -17,13 +25,22 @@

    NameIdCategoryRoom + Name + + + Id + + + Category + + + Room + + Actions
    {{veradevice.name}} {{veradevice.id}} {{veradevice.category}}
    - - - + + + - + @@ -56,26 +73,32 @@ Add Scene
    +
    - +
    +
    +
    +
    - +
    +
    +
    NameIdRoom + Name + + + Id + + + Room + + Actions
    {{verascene.name}} {{verascene.id}} {{verascene.room}}