10_CUL_HM: move aes key to vccu - step1

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8711 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2015-06-07 17:35:33 +00:00
parent 48c12384e5
commit c5158c3ae5
2 changed files with 43 additions and 11 deletions

View File

@ -196,6 +196,7 @@ sub HMLAN_Attr(@) {############################################################
elsif($aName =~ m /^hmKey/){ elsif($aName =~ m /^hmKey/){
my $retVal= ""; my $retVal= "";
if ($cmd eq "set"){ if ($cmd eq "set"){
# eQ3 default key A4E375C6B09FD185F27C4E96FC273AE4
my $kno = ($aName eq "hmKey")?1:substr($aName,5,1); my $kno = ($aName eq "hmKey")?1:substr($aName,5,1);
my ($no,$val) = (sprintf("%02X",$kno),$aVal); my ($no,$val) = (sprintf("%02X",$kno),$aVal);
if ($aVal =~ m/:/){#number given if ($aVal =~ m/:/){#number given
@ -886,14 +887,17 @@ sub HMLAN_assignIDs($){
sub HMLAN_writeAesKey($) {##################################################### sub HMLAN_writeAesKey($) {#####################################################
my ($name) = @_; my ($name) = @_;
return if (!$name || !$defs{$name});
my ($k,$kNo); my $vccu = InternalVal($name,"owner_CCU",$name);
foreach my $i (1..3){ $vccu = $name if(!AttrVal($vccu,"hmKey",""));#General if keys are not in vccu
($kNo,$k) = ("0".$i,AttrVal($name,"hmKey".($i== 1?"":$i),"")); foreach my $i (1..5){
($kNo,$k) = split(":",$k); my ($kNo,$k) = split(":",AttrVal($vccu,"hmKey".($i== 1?"":$i),""));
HMLAN_SimpleWrite($defs{$name}, "Y0$i,".($k?"$kNo,$k":"00,")); HMLAN_SimpleWrite($defs{$name}, "Y0$i,".($k?"$kNo,$k":"00,"));
} }
} }
sub HMLAN_KeepAlive($) {####################################################### sub HMLAN_KeepAlive($) {#######################################################
my($in ) = shift; my($in ) = shift;
my(undef,$name) = split(':',$in); my(undef,$name) = split(':',$in);

View File

@ -143,6 +143,7 @@ sub CUL_HM_Initialize($) {
."hmProtocolEvents:0_off,1_dump,2_dumpFull,3_dumpTrigger " ."hmProtocolEvents:0_off,1_dump,2_dumpFull,3_dumpTrigger "
."rssiLog:1,0 " # enable writing RSSI to Readings (device only) ."rssiLog:1,0 " # enable writing RSSI to Readings (device only)
."actCycle " # also for action detector ."actCycle " # also for action detector
."hmKey hmKey2 hmKey3 hmKey4 hmKey5 "
; ;
$hash->{Attr}{devPhy} = # -- physical device only attributes $hash->{Attr}{devPhy} = # -- physical device only attributes
"serialNr firmware .stc .devInfo " "serialNr firmware .stc .devInfo "
@ -741,7 +742,7 @@ sub CUL_HM_Attr(@) {#################################
} }
} }
elsif($attrName eq "IOList"){ elsif($attrName eq "IOList"){
return "use $attrName only for ccu device" return "use $attrName only for vccu device"
if (!$hash->{helper}{role}{dev} if (!$hash->{helper}{role}{dev}
|| AttrVal($name,"model","CCU-FHEM") !~ "CCU-FHEM"); || AttrVal($name,"model","CCU-FHEM") !~ "CCU-FHEM");
if($cmd eq "set"){$attr{$name}{$attrName} = $attrVal;} if($cmd eq "set"){$attr{$name}{$attrName} = $attrVal;}
@ -809,6 +810,33 @@ sub CUL_HM_Attr(@) {#################################
return "$attrName only usable for ActionDetector" if(CUL_HM_hash2Id($hash) ne "000000");#only for device return "$attrName only usable for ActionDetector" if(CUL_HM_hash2Id($hash) ne "000000");#only for device
} }
} }
elsif($attrName =~ m /^hmKey/){
my $retVal= "";
return "use $attrName only for vccu device"
if (!$hash->{helper}{role}{dev}
|| AttrVal($name,"model","CCU-FHEM") !~ "CCU-FHEM");
if ($cmd eq "set"){
# eQ3 default key A4E375C6B09FD185F27C4E96FC273AE4
my $kno = ($attrName eq "hmKey")?1:substr($attrName,5,1);
my ($no,$val) = (sprintf("%02X",$kno),$attrVal);
if ($attrVal =~ m/:/){#number given
($no,$val) = split ":",$attrVal;
return "illegal number:$no" if (hex($no) < 1 || hex($no) > 255 || length($no) != 2);
}
$attr{$name}{$attrName} = "$no:".
(($val =~ m /^[0-9A-Fa-f]{32}$/ )
? $val
: unpack('H*', md5($val)));
$retVal = "$attrName set to $attr{$name}{$attrName}"
if($attrVal ne $attr{$name}{$attrName});
}
else{
delete $attr{$name}{$attrName};
}
HMLAN_writeAesKey($_) foreach (split ",",AttrVal($name,"IOList",""));
return $retVal;
}
CUL_HM_queueUpdtCfg($name) if ($updtReq); CUL_HM_queueUpdtCfg($name) if ($updtReq);
return; return;
@ -7250,7 +7278,7 @@ sub CUL_HM_noDupInString($) {#return string with no duplicates, comma separated
} }
sub CUL_HM_storeRssi(@){ sub CUL_HM_storeRssi(@){
my ($name,$peerName,$val,$mNo) = @_; my ($name,$peerName,$val,$mNo) = @_;
return if (!$val || !defined $defs{$name}); return if (!$val || !$name|| !defined $defs{$name});
my $hash = $defs{$name}; my $hash = $defs{$name};
if (AttrVal($peerName,"subType","") eq "virtual"){ if (AttrVal($peerName,"subType","") eq "virtual"){
my $h = InternalVal($name,"IODev","");#CUL_HM_name2IoName($peerName); my $h = InternalVal($name,"IODev","");#CUL_HM_name2IoName($peerName);
@ -7637,7 +7665,7 @@ sub CUL_HM_getAttr($$$){#return attrValue - consider device if empty
sub CUL_HM_getAttrInt($@){#return attrValue as integer sub CUL_HM_getAttrInt($@){#return attrValue as integer
my ($name,$attrName,$default) = @_; my ($name,$attrName,$default) = @_;
$default = 0 if (!defined $default); $default = 0 if (!defined $default);
if($defs{$name}){ if($name && $defs{$name}){
my $val = (defined $attr{$name}{$attrName}) my $val = (defined $attr{$name}{$attrName})
?$attr{$name}{$attrName} ?$attr{$name}{$attrName}
:""; :"";