2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 00:26:03 +00:00

37_harmony.pm: try to fallback to xmpp if no discovery response is received. (segmented network)

git-svn-id: https://svn.fhem.de/fhem/trunk@18027 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2018-12-22 09:35:14 +00:00
parent 348f91655f
commit e5017ab2aa

View File

@ -61,7 +61,7 @@ sub
harmony_startDiscovery()
{
if( defined($modules{harmony}{defptr}{'harmony:discovery'}) ) {
fhem( "set harmony:discovery discover" );
harmony_sendDiscovery();
}
return if( $modules{harmony}{defptr}{'harmony:discovery'} );
@ -88,16 +88,44 @@ harmony_startDiscovery()
$defs{$chash->{NAME}} = $chash;
$selectlist{$chash->{NAME}} = $chash;
harmony_sendDiscovery();
} else {
Log3 undef, 2, "harmony: failed to start discovery" ;
}
} else {
Log3 undef, 2, "harmony: failed to start discovery" ;
}
}
sub
harmony_sendDiscovery()
{
my $chash = $modules{harmony}{defptr}{'harmony:discovery'};
return if( !$chash );
Log3 undef, 3, "harmony: sending discovery" ;
my $sin = sockaddr_in(5224, inet_aton('255.255.255.255'));
$chash->{sendSocket}->send( "_logitech-reverse-bonjour._tcp.local.\n$chash->{PORT}", 0, $sin );
} else {
Log3 undef, 2, "harmony: failed to start discovery" ;
}
} else {
Log3 undef, 2, "harmony: failed to start discovery" ;
}
foreach my $chash ( values %{$modules{'harmony'}{defptr}} ) {
next if( $chash->{NAME} eq 'harmony:discovery' );
next if( $chash->{ConnectionState} eq 'Connected' );
next if( !defined($chash->{ip}) );
next if( $chash->{remoteId} );
RemoveInternalTimer($chash);
InternalTimer(gettimeofday()+10, "harmony_tryXMPP", $chash, 0);
}
}
sub
harmony_tryXMPP($)
{
my ($hash) = @_;
my $name = $hash->{NAME};
Log3 $name, 3, "$name no discovery response received, trying fallback to xmpp" ;
harmony_connect($hash);
}
sub
harmony_stopDiscovery()
@ -376,8 +404,7 @@ harmony_Set($$@)
my $list = "discover:noArg";
if( $cmd eq "discover" ) {
my $sin = sockaddr_in(5224, inet_aton('255.255.255.255'));
$hash->{sendSocket}->send( "_logitech-reverse-bonjour._tcp.local.\n$hash->{PORT}", 0, $sin );
harmony_sendDiscovery();
return;
}