2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 19:32:42 +00:00

00_ZWDongle.pm: serialize neighborUpdate (Forum #54574)

git-svn-id: https://svn.fhem.de/fhem/trunk@11759 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-07-07 15:00:43 +00:00
parent 24a3e2c095
commit 56265292f9

View File

@ -13,6 +13,7 @@ sub ZWDongle_ReadAnswer($$$);
sub ZWDongle_Ready($);
sub ZWDongle_Write($$$);
sub ZWDongle_ProcessSendStack($);
sub ZWDongle_NUCheck($$$$);
# See also:
@ -466,12 +467,40 @@ ZWDongle_DoInit($)
return undef;
}
#####################################
# neighborUpdate special: have to serialize. Forum #54574
my @nuStack;
sub
ZWDongle_NUCheck($$$$)
{
my($hash, $fn, $msg, $isWrite) = @_;
if($isWrite) {
return 0 if($msg !~ m/^0048/ || $hash->{calledFromNuCheck});
push @nuStack, "$fn/$msg";
return (@nuStack > 1);
} else {
return if($msg !~ m/^0048..(..)$/ || $1 eq "21"); # 21: started
shift @nuStack;
return if(@nuStack == 0);
my @a = split("/", $nuStack[0]);
$hash->{calledFromNuCheck} = 1;
ZWDongle_Write($hash, $a[0], $a[1]);
delete($hash->{calledFromNuCheck});
}
}
#####################################
sub
ZWDongle_Write($$$)
{
my ($hash,$fn,$msg) = @_;
return if(ZWDongle_NUCheck($hash, $fn, $msg, 1));
Log3 $hash, 5, "ZWDongle_Write $msg ($fn)";
# assemble complete message
$msg = sprintf("%02x%s", length($msg)/2+1, $msg);
@ -753,6 +782,7 @@ ZWDongle_Parse($$$)
my %addvals = (RAWMSG => $rmsg);
ZWDongle_NUCheck($hash, undef, $rmsg, 0);
Dispatch($hash, $rmsg, \%addvals);
}