2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 16:56:04 +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.
# 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
- feature: 10_SOMFY: positionInverse für homebridge + fixes
- feature: 50_TelegramBot: multibot support / markup on send text / msgEdit

View File

@ -89,15 +89,17 @@ FB_CALLMONITOR_Define($$)
return $msg;
}
DevIo_CloseDev($hash);
delete($hash->{NEXT_OPEN});
my $dev = $a[2];
$dev .= ":1012" if($dev !~ m/:/ && $dev ne "none" && $dev !~ m/\@/);
$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
sub
@ -464,7 +481,7 @@ FB_CALLMONITOR_Ready($)
{
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")
{
DevIo_CloseDev($hash);
delete($hash->{NEXT_OPEN});
$hash->{STATE} = "disabled";
}
elsif($attrib eq "disable" and $value eq "0")
{
DevIo_OpenDev($hash, 0, undef, \&FB_CALLMONITOR_DevIoCallback);
}
}
elsif($cmd eq "del")
{
@ -514,6 +537,11 @@ FB_CALLMONITOR_Attr($@)
{
delete($hash->{helper}{TEXTFILE}) if(defined($hash->{helper}{TEXTFILE}));
}
if($attrib eq "disable")
{
DevIo_OpenDev($hash, 0, undef, \&FB_CALLMONITOR_DevIoCallback);
}
}
return undef;
@ -525,12 +553,16 @@ FB_CALLMONITOR_Attr($@)
sub
FB_CALLMONITOR_Notify($$)
{
my ($hash,$dev) = @_;
my ($hash,$device) = @_;
return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
my $events = deviceEvents($device, undef);
return if($device->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$events}));
FB_CALLMONITOR_readPhonebook($hash);
return undef;
}
############################################################################################################