2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 11:26:55 +00:00

AES counter, other bugs

git-svn-id: https://svn.fhem.de/fhem/trunk@3802 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2013-08-27 09:12:11 +00:00
parent 3b5c2b9901
commit d52bdff349
2 changed files with 55 additions and 21 deletions

View File

@ -322,12 +322,14 @@ sub HMLAN_Parse($$) {##########################################################
# 00 01= ack that HMLAN waited for
# 00 02= msg send, no ack requested
# 00 08= nack - ack was requested, msg repeated 3 times, still no ack
# 00 21= ??(seen with 'R')
# 00 30= ??
# 00 21= ??(seen with 'R') - see below
# 00 2x= should: AES was accepted, here is the response
# 00 30= should: AES response failed
# 00 40= ??(seen with 'E') after 0100
# 00 41= ??(seen with 'R')
# 00 50= ??(seen with 'R')
# 00 81= ??
# 01 xx= ?? (seen with 'E')
# 01 xx= ?? 0100 AES response send (gen autoMsgSent)
# 02 xx= prestate to 04xx. Message is still sent. This is a warning
# 04 xx= nothing sent anymore. Any restart unsuccessful except power
#
@ -340,13 +342,20 @@ sub HMLAN_Parse($$) {##########################################################
my $HMcnd =$stat >>8; #high = HMLAN cond
$stat &= 0xff; # low byte related to message format
if ($HMcnd == 0x01){#HMLAN responded to AES request
# $CULinfo = "AESresp";# General needs approval
}
if ($stat){# message with status information
HMLAN_condUpdate($hash,$HMcnd)if ($hash->{helper}{HMcnd} != $HMcnd);
$hash->{helper}{$dst}{flg} = 0;#got response => unblock sending
if ($stat & 0x0A){#08 and 02 dont need to go to CUL, internal ack only
Log $ll5, "HMLAN_Parse: $name no ACK from Device" if($stat & 0x08);
Log $ll5, "HMLAN_Parse: $name no ACK from $dst" if($stat & 0x08);
return;
}elsif (($stat & 0x70) == 0x30){Log $ll5, "HMLAN_Parse: $name AES code rejected for $dst $stat";
$CULinfo = "AESerrReject";
}elsif (($stat & 0x70) == 0x20){$CULinfo = "AESok";
}elsif (($stat & 0x70) == 0x40){;#$CULinfo = "???";
}
}
@ -358,7 +367,7 @@ sub HMLAN_Parse($$) {##########################################################
$hash->{"${name}_MSGCNT"}++;
$hash->{"${name}_TIME"} = TimeNow();
my $dly = 0;
my $dly = 0; #--------- calc messageDelay ----------
if ($hash->{helper}{ref} && $hash->{helper}{ref}{drft}){
my $ref = $hash->{helper}{ref};#shortcut
my $sysC = int(time()*1000); #current systime in ms

View File

@ -480,7 +480,10 @@ sub CUL_HM_Parse($$) {##############################
my $shash = $modules{CUL_HM}{defptr}{$src};
my $dhash = $modules{CUL_HM}{defptr}{$dst};
if ($msgStat){
$shash->{"protEvt_$msgStat"} = 0 if (!$shash->{"protEvt_$msgStat"});
$shash->{"protEvt_$msgStat"}++;
}
$respRemoved = 0; #set to 'no response in this message' at start
if(!$shash) { # Unknown source
@ -869,7 +872,7 @@ sub CUL_HM_Parse($$) {##############################
my ($a,$d) = unpack 'A2A4',$_;
$d = hex($d);
$d -= 0x10000 if($d & 0xC000);
$d = sprintf("%0.1f",$d/10);
$d = sprintf("T: %0.1f",$d/10);
my $chId = sprintf("%02X",hex($a) & 0x3f);
if($modules{CUL_HM}{defptr}{$src.$chId}){
@ -1471,7 +1474,7 @@ sub CUL_HM_Parse($$) {##############################
CUL_HM_ProcessCmdStack($shash) if ($respRemoved); # cont if complete
#------------ process events ------------------
push @event, "noReceiver:src:$src ".$mFlg.$mTp." $p" if(!@event);
push @event, "noReceiver:src:$src ".$mFlg.$mTp." $p" if(!@event && !@entities);
CUL_HM_UpdtReadBulk($shash,1,@event); #events to the channel
$defs{$shash->{NAME}}{EVENTS}++; # count events for channel
push @entities,$shash->{NAME};
@ -1501,12 +1504,7 @@ sub CUL_HM_parseCommon(@){#####################################################
CUL_HM_SndCmd($shash, '++A112'.CUL_HM_IOid($shash).$src);
CUL_HM_ProcessCmdStack($shash);
}
if ($shash->{helper}{respWait}{mNo} &&
$shash->{helper}{respWait}{mNo} eq $mNo ){
#response we waited for - stop Waiting
CUL_HM_respPendRm($shash);
}
my $repeat;
if ($mTp eq "02"){# Ack/Nack ###########################
#see if the channel is defined separate - otherwise go for chief
@ -1533,6 +1531,20 @@ sub CUL_HM_parseCommon(@){#####################################################
(-1)*(hex($rssi)))
if ($rssi && $rssi ne '00' && $rssi ne'80');
$reply = "ACKStatus";
if ($shash->{helper}{tmdOn}){
my $timedOn = hex(substr($p,6,2))&0x40?1:0;
if (not hex(substr($p,6,2))&0x40){# not timed on, we have to repeat
my ($pre,$nbr,$msg) = unpack 'A4A2A*',$shash->{helper}{respWait}{cmd};
$shash->{helper}{respWait}{cmd} = sprintf("%s%02X%s",$pre,hex($nbr)+1,$msg);
# General changes pending aproval
# CUL_HM_eventP($shash,"TimedOn");
# $success = "no";
# $repeat = 1;
# $reply = "NACK";
Log 1,"General missed timedOn for ".$chnhash->{NAME};
}
}
}
else{ #ACK
$success = "yes";
@ -1735,6 +1747,14 @@ sub CUL_HM_parseCommon(@){#####################################################
# CUL_HM_SndCmd($shash, '++A112'.CUL_HM_IOid($shash).$src);
# CUL_HM_ProcessCmdStack($shash);
}
if ($shash->{helper}{respWait}{mNo} &&
$shash->{helper}{respWait}{mNo} eq $mNo &&
!$repeat){
#response we waited for - stop Waiting
CUL_HM_respPendRm($shash);
}
return $ret;
}
sub CUL_HM_queueUpdtCfg($){
@ -2366,6 +2386,7 @@ sub CUL_HM_Set($@) {
return "please enter the duration in seconds"
if (!defined $duration || $duration !~ m/^[+-]?\d+(\.\d+)?$/);
my $tval = CUL_HM_encodeTime16($duration);# onTime 0.0..85825945.6, 0=forever
return "timer value to low" if ($tval eq "0000");
CUL_HM_PushCmdStack($hash,"++$flag"."11$id$dst"."02$chn"."C80000$tval");
$hash = $chnHash; # report to channel if defined
}
@ -2781,7 +2802,7 @@ sub CUL_HM_Set($@) {
#peerChan <btnN> <device> ... [single|dual] [set|unset] [actor|remote|both]
my ($bNo,$peerN,$single,$set,$target) = ($a[2],$a[3],$a[4],$a[5],$a[6]);
$state = "";
return "$bNo is not a button number" if(($bNo < 1) && $roleD);
return "$bNo is not a button number" if(($bNo < 1) && !$roleC);
my $peerDst = CUL_HM_name2Id($peerN);
$peerDst .= "01" if( length($peerDst)==6);
return "please enter peer" if(!$peerDst);
@ -2803,7 +2824,7 @@ sub CUL_HM_Set($@) {
$set = ($set && $set eq "unset")?0:1;
my ($b1,$b2,$nrCh2Pair);
$b1 = (!$roleD) ? hex($chn) : ($single?$bNo : ($bNo*2 - 1));
$b1 = ($roleC) ? hex($chn) : ($single?$bNo : ($bNo*2 - 1));
if ($single){
$b2 = $b1;
$b1 = 0 if ($st eq "smokeDetector");
@ -3120,6 +3141,9 @@ sub CUL_HM_responseSetup($$) {#store all we need to handle the response
elsif($mTp eq '11' && $chn =~ m/^(02|81)$/){#!!! chn is subtype!!!
CUL_HM_qStateUpdatIfEnab($dst);
}
if ($mTp eq "11" && $p =~ m/02........(....)/){
$hash->{helper}{tmdOn} = $1 if ($1 ne "0000");
}
$hash->{helper}{respWait}{cmd} = $cmd;
$hash->{helper}{respWait}{mNo} = $mNo; #mNo we wait to ack
@ -3189,6 +3213,7 @@ sub CUL_HM_protState($$){
sub CUL_HM_respPendRm($) {#del response related entries in messageing entity
my ($hash) = @_;
delete ($hash->{helper}{respWait});
delete $hash->{helper}{tmdOn};
RemoveInternalTimer($hash); # remove resend-timer
RemoveInternalTimer("respPend:$hash->{DEF}");# remove responsePending timer
$respRemoved = 1;