Update upnp listener module to even be less strict in normal mode as I

have found instances of devices that do not follow the pure upnp
standard. Updated README as it was wrong for the upnp.device.db...it had
an s after device. updated the code to return back to config after
adding or updating a device.
This commit is contained in:
Admin
2015-09-10 16:08:29 -05:00
parent 74d4548beb
commit 774bc8a36b
5 changed files with 14 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ The argument for the vera address should be given as it the system does not have
The server defaults to the first available address on the host. Replace the -Dupnp.config.address=`<ip address>` value with the server ipv4 address you would like to use.
### -Dserver.port=`<port>`
The server defaults to running on port 8080. If you're already running a server (like openHAB) on 8080, -Dserver.port=`<port>` on the command line.
### -Dupnp.devices.db=`<filepath>`
### -Dupnp.device.db=`<filepath>`
The default location for the db to contain the devices as they are added is "data/devices.db". If you would like a different filename or directory, specify -Dupnp.devices.db=`<directory>/<filename> or <filename>` if it is the same directory.
### -Dupnp.resonse.port=`<port>`
The upnp response port that will be used. The default is 50000.
@@ -90,4 +90,9 @@ After this Tell Alexa: "Alexa, discover my devices"
Then you can say "Alexa, Turn on the office light" or whatever name you have given your configured devices.
To view or remove devices that Alexa knows about, you can use the mobile app Menu / Settings / Connected Home
To view or remove devices that Alexa knows about, you can use the mobile app Menu / Settings / Connected Home
## Debugging
To turn on debugging for the bridge, use the following extra parm in the command line:
```
-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG
```

View File

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

View File

@@ -72,7 +72,7 @@ public class UpnpListener {
DatagramPacket packet = new DatagramPacket(buf, buf.length);
upnpMulticastSocket.receive(packet);
String packetString = new String(packet.getData());
if(packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1")) {
if(packetString != null && packetString.contains("M-SEARCH")) {
if(traceupnp)
log.info("Trace SSDP packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort() + " body : " + packetString);
else
@@ -99,8 +99,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\"")){
if(strict && body.contains("ST: urn:schemas-upnp-org:device:basic:1"))
if(body != null && body.contains("M-SEARCH") && body.contains("\"ssdp:discover\"")){
if(strict && body.startsWith("M-SEARCH * HTTP/1.1") && body.contains("MAN: \"ssdp:discover\"") && body.contains("ST: urn:schemas-upnp-org:device:basic:1"))
return true;
else if (!strict || vTwoCompatibility)
return true;

View File

@@ -36,7 +36,7 @@
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="http://www.bwssystems.com" target="_blank">Developed by BWS Systems</a></li>
<li><a href="http://www.amazon.com/echo" target="_blank">Amazon Echo</a></li>
<li><a href="#">HA Bridge Version 0.4.2</a></li>
<li><a href="#">HA Bridge Version 0.4.3</a></li>
</ul>
</li>
</ul>

View File

@@ -252,7 +252,7 @@ app.controller('ViewingController', function ($scope, $location, bridgeService,
app.controller('AddingController', function ($scope, bridgeService, BridgeSettings) {
$scope.device = {id: "", name: "", deviceType: "switch", onUrl: "", offUrl: ""};
$scope.device = {id: "", name: "", deviceType: "switch", onUrl: "", offUrl: "", httpVerb: "", contentType: "", contentBody: ""};
$scope.vera = {base: "", port: "3480", id: ""};
$scope.vera.base = "http://" + BridgeSettings.veraaddress;
bridgeService.device = $scope.device;
@@ -334,6 +334,7 @@ app.controller('AddingController', function ($scope, bridgeService, BridgeSettin
$scope.device.httpVerb = "";
$scope.device.contentType = "";
$scope.device.contentBody = "";
$location.path('/');
},
function (error) {
}