mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 20:24:36 +00:00
10_ZWave.pm: sec timer patch (Forum #38587)
git-svn-id: https://svn.fhem.de/fhem/trunk@10422 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2185461e25
commit
ca3259d5a7
@ -2327,10 +2327,10 @@ sub
|
|||||||
ZWave_secStart($)
|
ZWave_secStart($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
my $dt = gettimeofday();
|
my $dt = gettimeofday();
|
||||||
$hash->{secTime} = $dt;
|
$hash->{secTime} = $dt;
|
||||||
InternalTimer($dt+7, "ZWave_secUnlock", $hash, 0);
|
$hash->{secTimer} = { hash => $hash };
|
||||||
|
InternalTimer($dt+7, "ZWave_secUnlock", $hash->{secTimer}, 0);
|
||||||
|
|
||||||
return if($hash->{secInProgress});
|
return if($hash->{secInProgress});
|
||||||
$hash->{secInProgress} = 1;
|
$hash->{secInProgress} = 1;
|
||||||
@ -2341,11 +2341,12 @@ ZWave_secStart($)
|
|||||||
sub
|
sub
|
||||||
ZWave_secUnlock($)
|
ZWave_secUnlock($)
|
||||||
{
|
{
|
||||||
my ($hash)= @_;
|
my ($p) = @_;
|
||||||
|
my $hash= $p->{hash};
|
||||||
my $dt = gettimeofday();
|
my $dt = gettimeofday();
|
||||||
if (($hash->{secInProgress}) && ($dt > ($hash->{secTime} + 6))) {
|
if (($hash->{secInProgress}) && ($dt > ($hash->{secTime} + 6))) {
|
||||||
Log3 $hash->{NAME}, 3, "secStart is older than 6 seconds, "
|
Log3 $hash->{NAME}, 3, "$hash->{NAME}: secStart older than "
|
||||||
."secUnlock will call Zwave_secEnd";
|
."6 seconds detected, secUnlock will call Zwave_secEnd";
|
||||||
ZWave_secEnd($hash);
|
ZWave_secEnd($hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2356,9 +2357,11 @@ ZWave_secEnd($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
return if(!$hash->{secInProgress});
|
return if(!$hash->{secInProgress});
|
||||||
|
|
||||||
|
RemoveInternalTimer($hash->{secTimer});
|
||||||
my $secStack = $hash->{secStack};
|
my $secStack = $hash->{secStack};
|
||||||
delete $hash->{secInProgress};
|
delete $hash->{secInProgress};
|
||||||
delete $hash->{secStack};
|
delete $hash->{secStack};
|
||||||
|
delete $hash->{secTimer};
|
||||||
foreach my $cmd (@{$secStack}) {
|
foreach my $cmd (@{$secStack}) {
|
||||||
ZWave_SCmd($cmd->{T}, $hash, @{$cmd->{A}});
|
ZWave_SCmd($cmd->{T}, $hash, @{$cmd->{A}});
|
||||||
}
|
}
|
||||||
@ -2500,7 +2503,8 @@ ZWave_secNonceReceived($$)
|
|||||||
Log3 $name, 5, "$name: SECURITY initializing, networkkey sent";
|
Log3 $name, 5, "$name: SECURITY initializing, networkkey sent";
|
||||||
|
|
||||||
# start timer here to check state if networkkey was not verified
|
# start timer here to check state if networkkey was not verified
|
||||||
InternalTimer(gettimeofday()+25, "ZWave_secTestNetworkkeyVerify", $hash, 0);
|
$hash->{networkkeyTimer} = { hash => $hash };
|
||||||
|
InternalTimer(gettimeofday()+25, "ZWave_secTestNetworkkeyVerify", $hash->{networkkeyTimer}, 0);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2625,7 +2629,8 @@ ZWave_secNetWorkKeyVerify ($)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#Log3 $iodev, 4, "$name: NetworkKeyVerify received, SECURITY is enabled";
|
RemoveInternalTimer($hash->{networkkeyTimer});
|
||||||
|
delete $hash->{networkkeyTimer};
|
||||||
readingsSingleUpdate($hash, "SECURITY", 'ENABLED', 0);
|
readingsSingleUpdate($hash, "SECURITY", 'ENABLED', 0);
|
||||||
Log3 $name, 3, "$name: SECURITY enabled, networkkey was verified";
|
Log3 $name, 3, "$name: SECURITY enabled, networkkey was verified";
|
||||||
ZWave_Cmd("get", $hash, $name, ("secSupported"));
|
ZWave_Cmd("get", $hash, $name, ("secSupported"));
|
||||||
@ -2634,9 +2639,12 @@ ZWave_secNetWorkKeyVerify ($)
|
|||||||
sub
|
sub
|
||||||
ZWave_secTestNetworkkeyVerify ($)
|
ZWave_secTestNetworkkeyVerify ($)
|
||||||
{
|
{
|
||||||
my($hash) = @_;
|
my ($p) = @_;
|
||||||
|
my $hash = $p->{hash};
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $sec_status = ReadingsVal($name, "SECURITY", undef);
|
my $sec_status = ReadingsVal($name, "SECURITY", undef);
|
||||||
|
|
||||||
|
delete $hash->{networkkeyTimer};
|
||||||
if ($sec_status !~ m/ENABLED/) {
|
if ($sec_status !~ m/ENABLED/) {
|
||||||
readingsSingleUpdate($hash, "SECURITY",
|
readingsSingleUpdate($hash, "SECURITY",
|
||||||
'DISABLED (networkkey not verified and timer expired)', 0);
|
'DISABLED (networkkey not verified and timer expired)', 0);
|
||||||
@ -3000,13 +3008,7 @@ ZWave_processSendStack($)
|
|||||||
|
|
||||||
if(index($ss->[0],"sent") == 0) {
|
if(index($ss->[0],"sent") == 0) {
|
||||||
shift @{$ss};
|
shift @{$ss};
|
||||||
if(!ZWave_isWakeUp($hash)) {
|
RemoveInternalTimer($hash) if(!ZWave_isWakeUp($hash));
|
||||||
RemoveInternalTimer($hash);
|
|
||||||
|
|
||||||
if($hash->{secInProgress}) {
|
|
||||||
InternalTimer(gettimeofday()+7, "ZWave_secUnlock", $hash, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(@{$ss} == 0) {
|
if(@{$ss} == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user