mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 00:10:20 +00:00
Fixed broadlink discover loop
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>5.2.0RC11</version>
|
<version>5.2.0RC12</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -66,38 +66,39 @@ public class BroadlinkHome implements Home {
|
|||||||
broadlinkMap = new HashMap<String, BLDevice>();
|
broadlinkMap = new HashMap<String, BLDevice>();
|
||||||
int aDiscoverPort = Configuration.BROADLINK_DISCOVER_PORT;
|
int aDiscoverPort = Configuration.BROADLINK_DISCOVER_PORT;
|
||||||
while(aDiscoverPort > 0) {
|
while(aDiscoverPort > 0) {
|
||||||
try {
|
try {
|
||||||
log.info("Broadlink discover....");
|
log.info("Broadlink discover....");
|
||||||
if(isDevMode) {
|
if(isDevMode) {
|
||||||
clients = TestBLDevice.discoverDevices(InetAddress.getByName(bridgeSettings.getBridgeSettingsDescriptor().getUpnpConfigAddress()), aDiscoverPort, Configuration.BROADLINK_DISCONVER_TIMEOUT);
|
clients = TestBLDevice.discoverDevices(InetAddress.getByName(bridgeSettings.getBridgeSettingsDescriptor().getUpnpConfigAddress()), aDiscoverPort, Configuration.BROADLINK_DISCONVER_TIMEOUT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
clients = BLDevice.discoverDevices(InetAddress.getByName(bridgeSettings.getBridgeSettingsDescriptor().getUpnpConfigAddress()), aDiscoverPort, Configuration.BROADLINK_DISCONVER_TIMEOUT);
|
clients = BLDevice.discoverDevices(InetAddress.getByName(bridgeSettings.getBridgeSettingsDescriptor().getUpnpConfigAddress()), aDiscoverPort, Configuration.BROADLINK_DISCONVER_TIMEOUT);
|
||||||
if(clients.length <= 0) {
|
if(clients.length <= 0) {
|
||||||
log.warn("Did not discover any Broadlinks, try again with bridge reinitialization");
|
log.warn("Did not discover any Broadlinks, try again with bridge reinitialization");
|
||||||
|
broadlinkMap = null;
|
||||||
|
validBroadlink = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
for(int i = 0; i < clients.length; i++) {
|
||||||
|
if(clients[i].getDeviceType() != BLDevice.DEV_A1) {
|
||||||
|
broadlinkMap.put(clients[i].getHost() + "-" + String.format("%04x", clients[i].getDeviceType()), clients[i]);
|
||||||
|
log.debug("Adding Device to Map - host: " + clients[i].getHost() + ", device Type: " + clients[i].getDeviceDescription() + ", mac: " + (clients[i].getMac() == null ? "no Mac in client" : clients[i].getMac().getMacString()));
|
||||||
|
} else {
|
||||||
|
log.debug("Ignoring A1 Device - host: " + clients[i].getHost() + ", device Type: " + clients[i].getDeviceDescription() + ", mac: " + (clients[i].getMac() == null ? "no Mac in client" : clients[i].getMac().getMacString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aDiscoverPort = 0;
|
||||||
|
} catch (BindException e) {
|
||||||
|
log.warn("Could not discover Broadlinks, Port in use, increasing by 11");
|
||||||
|
aDiscoverPort += 11;
|
||||||
|
if(aDiscoverPort > Configuration.BROADLINK_DISCOVER_PORT + 110)
|
||||||
|
aDiscoverPort = 0;
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Could not discover Broadlinks, with IO Exception", e);
|
||||||
broadlinkMap = null;
|
broadlinkMap = null;
|
||||||
validBroadlink = false;
|
validBroadlink = false;
|
||||||
return this;
|
|
||||||
}
|
|
||||||
for(int i = 0; i < clients.length; i++) {
|
|
||||||
if(clients[i].getDeviceType() != BLDevice.DEV_A1) {
|
|
||||||
broadlinkMap.put(clients[i].getHost() + "-" + String.format("%04x", clients[i].getDeviceType()), clients[i]);
|
|
||||||
log.debug("Adding Device to Map - host: " + clients[i].getHost() + ", device Type: " + clients[i].getDeviceDescription() + ", mac: " + (clients[i].getMac() == null ? "no Mac in client" : clients[i].getMac().getMacString()));
|
|
||||||
} else {
|
|
||||||
log.debug("Ignoring A1 Device - host: " + clients[i].getHost() + ", device Type: " + clients[i].getDeviceDescription() + ", mac: " + (clients[i].getMac() == null ? "no Mac in client" : clients[i].getMac().getMacString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (BindException e) {
|
|
||||||
log.warn("Could not discover Broadlinks, Port in use, increasing by 11");
|
|
||||||
aDiscoverPort += 11;
|
|
||||||
if(aDiscoverPort > Configuration.BROADLINK_DISCOVER_PORT + 110)
|
|
||||||
aDiscoverPort = 0;
|
aDiscoverPort = 0;
|
||||||
} catch (IOException e) {
|
}
|
||||||
log.warn("Could not discover Broadlinks, with IO Exception", e);
|
|
||||||
broadlinkMap = null;
|
|
||||||
validBroadlink = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user