2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 01:06:04 +00:00

96_SIP: use variable force time for each call

git-svn-id: https://svn.fhem.de/fhem/trunk@13883 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Wzut 2017-04-02 15:49:47 +00:00
parent 46001270e0
commit 2ea125516e

View File

@ -54,7 +54,7 @@ use Net::Domain qw(hostname hostfqdn);
use Blocking; # http://www.fhemwiki.de/wiki/Blocking_Call use Blocking; # http://www.fhemwiki.de/wiki/Blocking_Call
#use Data::Dumper; #use Data::Dumper;
my $sip_version ="V1.51 / 01.04.17"; my $sip_version ="V1.52 / 02.04.17";
my $ua; # SIP user agent my $ua; # SIP user agent
my @fifo; my @fifo;
@ -610,39 +610,43 @@ sub SIP_CALLDone($)
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
} }
my (undef,$nr,$ringtime,$msg,$repeat,$force) = split("\\|",$hash->{CALL}); # zerlegen wir den Original Call my (undef,$nr,$ringtime,$msg,$repeat,$force) = split("\\|",$hash->{CALL}); # zerlegen wir den Original Call
if ($force && (lc($final) ne "ok")) if ($force && (lc($final) ne "ok"))
{ {
$repeat = "0" if (!$repeat); $repeat = "0" if (!$repeat);
$force =~ s/^\&//;
$force ++; $force --;
my $nr2 = $nr; my $nr2 = $nr;
$nr2 =~ tr/0-9//cd; $nr2 =~ tr/0-9//cd;
my $t = int(AttrVal($name,"sip_force_interval",60)); my $t = ($force) ? $force : int(AttrVal($name,"sip_force_interval",60));
my $time_s = strftime("\%H:\%M:\%S", gmtime($t)); my $time_s = strftime("\%H:\%M:\%S", gmtime($t));
$error = CommandDefine(undef, "at_forcecall_".$nr2." at +".$time_s." set $name call $nr $ringtime $msg *$repeat &"); $error = CommandDefine(undef, "at_forcecall_".$nr2." at +".$time_s." set $name call $nr $ringtime $msg *".$repeat." &".$t);
if (!$error) { $attr{"at_forcecall_".$nr2}{room} = AttrVal($name,"room","Unsorted"); } if (!$error) { $attr{"at_forcecall_".$nr2}{room} = AttrVal($name,"room","Unsorted"); }
else { Log3 $name,2,"$name, $error"; } else { Log3 $name,2,"$name, $error"; }
Log3 $name,4,"$name, at_forcecall_".$nr2." at +".$time_s." set $name call $nr $ringtime $msg *".$repeat." &".$force;
} }
my $nextcall = shift @fifo; # sind da noch Calls in der Queue ? my $nextcall = shift @fifo; # sind da noch Calls in der Queue ?
if ($nextcall) if ($nextcall)
{ {
@a = split(" ",$nextcall); @a = split(" ",$nextcall);
$error = SIP_Set($hash,@a); $error = SIP_Set($hash,@a);
Log3 $name,3,"$name, error setting nextcall $nextcall -> $error" if ($error); Log3 $name,3,"$name, error setting nextcall $nextcall -> $error" if ($error);
return undef; return undef;
} else { Log3 $name,5,"$name, fifo is empty"; } } else { Log3 $name,5,"$name, fifo is empty"; }
if (exists($hash->{'.elbc'})) if (exists($hash->{'.elbc'}))
{ {
@a = (undef,"listen"); @a = (undef,"listen");
Log3 $name,4,"$name, try restarting listen process after call ends"; Log3 $name,4,"$name, try restarting listen process after call ends";
$error = SIP_Set($hash,@a); $error = SIP_Set($hash,@a);
Log3 $name,3,"$name, error restarting listen -> $error" if ($error); Log3 $name,3,"$name, error restarting listen -> $error" if ($error);
delete $hash->{'.elbc'}; delete $hash->{'.elbc'};
} else { Log3 $name,5,"$name, no elbc"; } } else { Log3 $name,5,"$name, no elbc"; }
delete $hash->{CALL}; delete $hash->{CALL};
return undef; return undef;
@ -690,8 +694,8 @@ sub SIP_Set($@)
my $anz = @a; my $anz = @a;
$anz--; # letztes Element $anz--; # letztes Element
my $force = ($a[$anz] eq "&") ? 1 : 0; my $force = (substr($a[$anz],0,1) eq "&") ? $a[$anz] : 0;
$anz-- if ($force == 1); # checken wir dann noch auf repeat $anz-- if ($force); # checken wir dann noch auf repeat
my $repeat = 0; my $repeat = 0;
if (substr($a[$anz],0,1) eq "*") if (substr($a[$anz],0,1) eq "*")
{ {
@ -1454,10 +1458,9 @@ sub SIP_wait_for_t2s($)
# nun aber calling # nun aber calling
my $repeat = "*".$hash->{repeat}; my $repeat = "*".$hash->{repeat};
my $force = ($hash->{forcecall}) ? "&" : "";
my @a; my @a;
if ($force) if ($hash->{forcecall})
{ @a = ($name,"call",$hash->{callnr}, $hash->{ringtime},$msg,$repeat,$force) ; } { @a = ($name,"call",$hash->{callnr}, $hash->{ringtime},$msg,$repeat,$hash->{forcecall}) ; }
else else
{ @a = ($name,"call",$hash->{callnr}, $hash->{ringtime},$msg,$repeat) ; } { @a = ($name,"call",$hash->{callnr}, $hash->{ringtime},$msg,$repeat) ; }