2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

MAX: ParseFn should return list of matched devices

git-svn-id: https://svn.fhem.de/fhem/trunk@2587 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mgehre 2013-01-28 20:32:22 +00:00
parent 06f4a878f1
commit dc20316766
3 changed files with 18 additions and 20 deletions

View File

@ -463,7 +463,7 @@ MAXLAN_Parse($$)
#One can write to that memory with the "m:" command
#The actual configuration comes with the "C:" response and can be set
#with the "s:" command.
return if(@args < 3); #On virgin devices, we get nothing, not even $magic$version$numgroups$numdevices
return $name if(@args < 3); #On virgin devices, we get nothing, not even $magic$version$numgroups$numdevices
my $bindata = decode_base64($args[2]);
#$version is the version the serialized data format I guess
@ -473,7 +473,7 @@ MAXLAN_Parse($$)
1;
} or do {
Log 1, "MAXLAN_Parse: Metadata response is malformed!";
return;
return $name;
};
if($magic != $metadata_magic || $version != $metadata_version) {
@ -504,12 +504,12 @@ MAXLAN_Parse($$)
#Log $ll5, "Got Metadata, hash: ".Dumper($hash);
}elsif($cmd eq "C"){#Configuration
return if(@args < 2);
return $name if(@args < 2);
my $bindata = decode_base64($args[1]);
if(length($bindata) < 18) {
Log 1, "Invalid C: response, not enough data";
return "MAXLAN_Parse: Invalid C: response, not enough data";
return $name;
}
#Parse the first 18 bytes, those are send for every device
@ -522,7 +522,7 @@ MAXLAN_Parse($$)
if($len != length($bindata)) {
Dispatch($hash, "MAX,1,Error,$addr,Parts of configuration are missing", {RAWMSG => $rmsg});
return "MAXLAN_Parse: Invalid C: response, len does not match";
return $name;
}
#devicetype: Cube = 0, HeatingThermostat = 1, HeatingThermostatPlus = 2, WallMountedThermostat = 3, ShutterContact = 4, PushButton = 5
@ -626,7 +626,7 @@ MAXLAN_Parse($$)
if(@args==0){
$hash->{STATE} = "initalized"; #pairing ended
$hash->{pairmode} = 0;
return undef;
return $name;
}
my ($type, $addr, $serial) = unpack("CH6a[10]", decode_base64($args[0]));
Log 2, "MAXLAN_Parse: Paired new device, type $device_types{$type}, addr $addr, serial $serial";
@ -645,12 +645,10 @@ MAXLAN_Parse($$)
Log 3, "MAXLAN_Parse: 1% rule: we sent too much, cmd is now in queue" if($hash->{dutycycle} == 100 && $hash->{freememoryslot} > 0);
Log 2, "MAXLAN_Parse: 1% rule: we sent too much, queue is full" if($hash->{dutycycle} == 100 && $hash->{freememoryslot} == 0);
Log 2, "MAXLAN_Parse: Command was discarded" if($discarded);
return "Command was discarded" if($discarded);
} else {
Log $ll5, "$name Unknown command $cmd";
return "MAXLAN_Parse: Unknown command $cmd";
Log 2, "MAXLAN_Parse: Unknown command $cmd";
}
return undef;
return $name;
}

View File

@ -427,7 +427,7 @@ MAX_Parse($$)
my ($MAX,$isToMe,$msgtype,$addr,@args) = split(",",$msg);
#$isToMe is 1 if the message was direct at the device $hash, and 0
#if we just snooped a message directed at a different device (by CUL_MAX).
return if($MAX ne "MAX");
return () if($MAX ne "MAX");
Log 5, "MAX_Parse $msg";
#Find the device with the given addr

View File

@ -157,13 +157,13 @@ CUL_MAX_Parse($$)
}
my $shash = $modules{CUL_MAX}{defptr};
$rmsg =~ m/Z(..)(..)(..)(..)(......)(......)(..)(.*)/;
return () if($rmsg !~ m/Z(..)(..)(..)(..)(......)(......)(..)(.*)/);
my ($len,$msgcnt,$msgFlag,$msgTypeRaw,$src,$dst,$groupid,$payload) = ($1,$2,$3,$4,$5,$6,$7,$8);
$len = hex($len);
if(2*$len+3 != length($rmsg)) { #+3 = +1 for 'Z' and +2 for len field in hex
my $msg = "CUL_MAX_Parse: len mismatch";
Log 1, $msg;
return $msg;
Log 1, "CUL_MAX_Parse: len mismatch";
return $shash->{NAME};
}
$groupid = hex($groupid);
@ -178,10 +178,10 @@ CUL_MAX_Parse($$)
if(exists($msgId2Cmd{$msgTypeRaw})) {
if($msgType eq "Ack") {
return undef if($src eq $shash->{addr}); #Ignore packets generated by culfw's auto-Ack
return $shash->{NAME} if($src eq $shash->{addr}); #Ignore packets generated by culfw's auto-Ack
Dispatch($shash, "MAX,$isToMe,Ack,$src,$payload", {RAWMSG => $rmsg});
return undef if(!$isToMe);
return $shash->{NAME} if(!$isToMe);
my $i = 0;
while ($i < @waitForAck) {
@ -189,7 +189,7 @@ CUL_MAX_Parse($$)
if($packet->{dest} eq $src and $packet->{cnt} == hex($msgcnt)) {
Log 5, "Got matching ack";
splice @waitForAck, $i, 1;
return undef;
return $shash->{NAME};
} else {
$i++;
}
@ -224,7 +224,7 @@ CUL_MAX_Parse($$)
#2. It is sent after changing batteries or repressing the pair button (without factory reset) and has a destination address of the last paired device. We can answer it with PairPong and even get an Ack, but it will still not be paired to us. A factory reset (originating from the last paired device) is needed first.
if(($dst ne "000000") and !$isToMe) {
Log 2, "Device want's to be re-paired to $dst, not to us";
return undef;
return $shash->{NAME};
}
if($shash->{pairmode}) {
@ -248,7 +248,7 @@ CUL_MAX_Parse($$)
} else {
Log 2, "CUL_MAX_Parse: Got unhandled message type $msgTypeRaw";
}
return undef;
return $shash->{NAME};
}
sub