[tr064] fix fritz.box lookup (#9454)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K 2020-12-23 04:19:37 +01:00 committed by GitHub
parent f29d405837
commit 22ac639233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -65,7 +65,7 @@ public class Tr064HandlerFactory extends BaseThingHandlerFactory {
this.channelTypeProvider = channelTypeProvider;
this.phonebookProfileFactory = phonebookProfileFactory;
// use an insecure client (i.e. without verifying the certificate)
this.httpClient = new HttpClient(new SslContextFactory(true));
this.httpClient = new HttpClient(new SslContextFactory.Client(true));
try {
this.httpClient.start();
} catch (Exception e) {

View File

@ -76,7 +76,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
private @Nullable SCPDUtil scpdUtil;
private SOAPConnector soapConnector;
private String endpointBaseURL = "http://fritz.box:49000";
private String endpointBaseURL = "";
private final Map<ChannelUID, Tr064ChannelConfig> channels = new HashMap<>();
// caching is used to prevent excessive calls to the same action
@ -87,14 +87,19 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
private @Nullable ScheduledFuture<?> pollFuture;
private @Nullable ScheduledFuture<?> phonebookFuture;
private boolean communicationEstablished = false;
Tr064RootHandler(Bridge bridge, HttpClient httpClient) {
super(bridge);
this.httpClient = httpClient;
soapConnector = new SOAPConnector(httpClient, endpointBaseURL);
this.soapConnector = new SOAPConnector(httpClient, endpointBaseURL);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (!communicationEstablished) {
logger.debug("Tried to process command, but thing is not yet ready: {} to {}", channelUID, command);
}
Tr064ChannelConfig channelConfig = channels.get(channelUID);
if (channelConfig == null) {
logger.trace("Channel {} not supported.", channelUID);
@ -157,6 +162,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
updateThing(thingBuilder.build());
}
communicationEstablished = true;
installPolling();
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
}
@ -172,6 +178,7 @@ public class Tr064RootHandler extends BaseBridgeHandler implements PhonebookProv
@Override
public void dispose() {
communicationEstablished = false;
removeConnectScheduler();
uninstallPolling();
stateCache.clear();