From 71f8afb2ada5833d7e3e1418529028a604428668 Mon Sep 17 00:00:00 2001 From: "klaus.schauer" Date: Sun, 30 May 2021 08:04:12 +0000 Subject: [PATCH] 00_TCM: new attribute rcvIDShift git-svn-id: https://svn.fhem.de/fhem/trunk@24540 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_TCM.pm | 55 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/fhem/FHEM/00_TCM.pm b/fhem/FHEM/00_TCM.pm index 04ca6d538..648cdc955 100755 --- a/fhem/FHEM/00_TCM.pm +++ b/fhem/FHEM/00_TCM.pm @@ -28,28 +28,29 @@ sub TCM_CSUM($); sub TCM_Initialize($) { my ($hash) = @_; # Provider - $hash->{ReadFn} = "TCM_Read"; - $hash->{WriteFn} = "TCM_Write"; - $hash->{ReadyFn} = "TCM_Ready"; - $hash->{Clients} = ":EnOcean:"; my %matchList= ( "1:EnOcean" => "^EnOcean:", ); + $hash->{Clients} = "EnOcean"; $hash->{MatchList} = \%matchList; + $hash->{ReadFn} = "TCM_Read"; + $hash->{ReadyFn} = "TCM_Ready"; + $hash->{WriteFn} = "TCM_Write"; # Normal devices + $hash->{AttrFn} = "TCM_Attr"; $hash->{DefFn} = "TCM_Define"; $hash->{FingerprintFn} = "TCM_Fingerprint"; - $hash->{UndefFn} = "TCM_Undef"; + $hash->{NotifyFn} = "TCM_Notify"; + $hash->{NotifyOrderPrefix} = "45-"; $hash->{GetFn} = "TCM_Get"; $hash->{SetFn} = "TCM_Set"; - $hash->{NotifyFn} = "TCM_Notify"; - $hash->{AttrFn} = "TCM_Attr"; + $hash->{ShutdownFn} = "TCM_Shutdown"; + $hash->{UndefFn} = "TCM_Undef"; $hash->{AttrList} = "assignIODev:select,no,yes baseID .baseIDSaved blockSenderID:own,no .chipIDSaved comModeUTE:auto,biDir,uniDir comType:TCM,RS485 do_not_notify:1,0 " . "dummy:1,0 fingerprint:off,on learningDev:all,teachMsg learningMode:always,demand,nearfield " . - "msgCounter:select,off,on sendInterval:0,25,40,50,100,150,200,250 smartAckMailboxMax:slider,0,1,20 " . + "msgCounter:select,off,on rcvIDShift sendInterval:0,25,40,50,100,150,200,250 smartAckMailboxMax:slider,0,1,20 " . "smartAckLearnMode:simple,advance,advanceSelectRep"; - $hash->{ShutdownFn} = "TCM_Shutdown"; - $hash->{NotifyOrderPrefix} = "45-"; + return undef; } # Define @@ -389,7 +390,7 @@ sub TCM_CRC8($) { sub TCM_Read($) { my ($hash) = @_; my $buf = DevIo_SimpleRead($hash); - return "" if(!defined($buf)); + return "" if (!defined($buf)); my $name = $hash->{NAME}; my $blockSenderID = AttrVal($name, "blockSenderID", "own"); my $data = $hash->{PARTIAL} . uc(unpack('H*', $buf)); @@ -411,10 +412,12 @@ sub TCM_Read($) { if($net =~ m/^0B(..)(........)(........)(..)/) { # Receive Radio Telegram (RRT) - my ($org, $d1,$id,$status) = ($1, $2, $3, $4); + my ($org, $d1, $id, $status) = ($1, $2, $3, $4); my $packetType = 1; + # shift rcvID range + $id = sprintf("%08X", hex($id) + hex($attr{$name}{rcvIdShift})) if (defined $attr{$name}{rcvIdShift}); # Re-translate the ORG to RadioORG / TCM310 equivalent - my %orgmap = ("05"=>"F6", "06"=>"D5", "07"=>"A5", ); + my %orgmap = ("05" => "F6", "06" => "D5", "07" => "A5"); if($orgmap{$org}) { $org = $orgmap{$org}; } else { @@ -432,8 +435,10 @@ sub TCM_Read($) { # Receive Message Telegram (RMT) my $msg = TCM_Parse120($hash, $net, 1); if (($msg eq 'OK') && ($net =~ m/^8B(..)(........)(........)(..)/)){ - my ($org, $d1,$id,$status) = ($1, $2, $3, $4); + my ($org, $d1, $id, $status) = ($1, $2, $3, $4); my $packetType = 1; + # shift rcvID range + $id = sprintf("%08X", hex($id) + hex($attr{$name}{rcvIDShift})) if (defined $attr{$name}{rcvIDShift}); # Re-translate the ORG to RadioORG / TCM310 equivalent my %orgmap = ("05" => "F6", "06" => "D5", "07" => "A5"); if($orgmap{$org}) { @@ -1371,7 +1376,7 @@ sub TCM_Attr(@) { } elsif ($attrName eq "baseID") { if (!defined $attrVal){ - } elsif ($attrVal !~ m/^[Ff]{2}[\dA-Fa-f]{6}$/) { + } elsif ($attrVal !~ m/^[Ff]{2}[\dA-Fa-f]{4}[08]0$/ || $attrVal =~ m/^[Ff]{8}$/) { Log3 $name, 2, "TCM $name attribute-value [$attrName] = $attrVal wrong"; CommandDeleteAttr(undef, "$name $attrName"); } else { @@ -1448,6 +1453,14 @@ sub TCM_Attr(@) { CommandDeleteAttr(undef, "$name $attrName"); } + } elsif ($attrName eq "rcvIDShift") { + if (!defined $attrVal){ + + } elsif ($attrVal !~ m/^[\dA-Fa-f]{6}[08]0$/ || $attrVal =~ m/^[Ff]{8}$/) { + Log3 $name, 2, "TCM $name attribute-value [$attrName] = $attrVal wrong"; + CommandDeleteAttr(undef, "$name $attrName"); + } + } elsif ($attrName eq "sendInterval") { if (!defined $attrVal){ @@ -1684,7 +1697,7 @@ sub TCM_Shutdown($) { Set