2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 14:04:15 +00:00

FB_CALLMONITOR: change connection setup to non-blocking connect procedure, close connection when disabled (Forum: #59380)

git-svn-id: https://svn.fhem.de/fhem/trunk@12393 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2016-10-21 14:46:48 +00:00
parent c7b98f50ac
commit 7bc2f11647
2 changed files with 41 additions and 7 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- change: FB_CALLMONITOR: open TCP connection non-blocking,
shutdown connection when disabled
- bugfix: 73_km200: Experimental keys on scalar is now forbidden - bugfix: 73_km200: Experimental keys on scalar is now forbidden
- feature: 10_SOMFY: positionInverse für homebridge + fixes - feature: 10_SOMFY: positionInverse für homebridge + fixes
- feature: 50_TelegramBot: multibot support / markup on send text / msgEdit - feature: 50_TelegramBot: multibot support / markup on send text / msgEdit

View File

@ -89,7 +89,9 @@ FB_CALLMONITOR_Define($$)
return $msg; return $msg;
} }
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
delete($hash->{NEXT_OPEN});
my $dev = $a[2]; my $dev = $a[2];
@ -97,7 +99,7 @@ FB_CALLMONITOR_Define($$)
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
return DevIo_OpenDev($hash, 0, undef); return DevIo_OpenDev($hash, 0, undef, \&FB_CALLMONITOR_DevIoCallback)
} }
@ -457,6 +459,21 @@ FB_CALLMONITOR_Read($)
} }
} }
#####################################
# Reconnects to FritzBox in case of disconnects
sub
FB_CALLMONITOR_DevIoCallback($$)
{
my ($hash, $err) = @_;
my $name = $hash->{NAME};
if($err)
{
Log3 $name, 4, "FB_CALLMONITOR ($name) - unable to connect to Fritz!Box: $err";
}
}
##################################### #####################################
# Reconnects to FritzBox in case of disconnects # Reconnects to FritzBox in case of disconnects
sub sub
@ -464,7 +481,7 @@ FB_CALLMONITOR_Ready($)
{ {
my ($hash) = @_; my ($hash) = @_;
return DevIo_OpenDev($hash, 1, undef); return DevIo_OpenDev($hash, 1, undef, \&FB_CALLMONITOR_DevIoCallback);
} }
##################################### #####################################
@ -495,8 +512,14 @@ FB_CALLMONITOR_Attr($@)
if($attrib eq "disable" and $value eq "1") if($attrib eq "disable" and $value eq "1")
{ {
DevIo_CloseDev($hash);
delete($hash->{NEXT_OPEN});
$hash->{STATE} = "disabled"; $hash->{STATE} = "disabled";
} }
elsif($attrib eq "disable" and $value eq "0")
{
DevIo_OpenDev($hash, 0, undef, \&FB_CALLMONITOR_DevIoCallback);
}
} }
elsif($cmd eq "del") elsif($cmd eq "del")
{ {
@ -514,6 +537,11 @@ FB_CALLMONITOR_Attr($@)
{ {
delete($hash->{helper}{TEXTFILE}) if(defined($hash->{helper}{TEXTFILE})); delete($hash->{helper}{TEXTFILE}) if(defined($hash->{helper}{TEXTFILE}));
} }
if($attrib eq "disable")
{
DevIo_OpenDev($hash, 0, undef, \&FB_CALLMONITOR_DevIoCallback);
}
} }
return undef; return undef;
@ -525,12 +553,16 @@ FB_CALLMONITOR_Attr($@)
sub sub
FB_CALLMONITOR_Notify($$) FB_CALLMONITOR_Notify($$)
{ {
my ($hash,$dev) = @_; my ($hash,$device) = @_;
return if($dev->{NAME} ne "global"); my $events = deviceEvents($device, undef);
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
return if($device->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$events}));
FB_CALLMONITOR_readPhonebook($hash); FB_CALLMONITOR_readPhonebook($hash);
return undef;
} }
############################################################################################################ ############################################################################################################