2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 07:19:24 +00:00

new attr blockSenderID: Block receiving telegrams with a TCM SenderID sent by repeaters

git-svn-id: https://svn.fhem.de/fhem/trunk@3176 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
klaus-schauer 2013-05-14 14:48:00 +00:00
parent eb9fd33573
commit 5ee3af8d76

View File

@ -53,7 +53,7 @@ TCM_Initialize($)
$hash->{UndefFn} = "TCM_Undef"; $hash->{UndefFn} = "TCM_Undef";
$hash->{GetFn} = "TCM_Get"; $hash->{GetFn} = "TCM_Get";
$hash->{SetFn} = "TCM_Set"; $hash->{SetFn} = "TCM_Set";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 loglevel:0,1,2,3,4,5,6"; $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 loglevel:0,1,2,3,4,5,6 blockSenderID:own,no";
} }
##################################### #####################################
@ -64,6 +64,7 @@ TCM_Define($$)
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
my $name = $a[0]; my $name = $a[0];
my $model = $a[2]; my $model = $a[2];
my $baseID;
return "wrong syntax. Correct is: define <name> TCM [120|310] ". return "wrong syntax. Correct is: define <name> TCM [120|310] ".
"{devicename[\@baudrate]|ip:port}" "{devicename[\@baudrate]|ip:port}"
@ -81,6 +82,14 @@ TCM_Define($$)
$hash->{DeviceName} = $dev; $hash->{DeviceName} = $dev;
$hash->{MODEL} = $model; $hash->{MODEL} = $model;
my $ret = DevIo_OpenDev($hash, 0, undef); my $ret = DevIo_OpenDev($hash, 0, undef);
my @getBaseID = ("get", "baseID");
if (TCM_Get($hash, @getBaseID) =~ /[Ff]{2}[\dA-Fa-f]{6}/ ) {
$hash->{BaseID} = sprintf "%08X", hex $&;
$hash->{LastID} = sprintf "%08X", (hex $&) + 127;
} else {
$hash->{BaseID} = "00000000";
$hash->{LastID} = "00000000";
}
return $ret; return $ret;
} }
@ -209,6 +218,9 @@ TCM_Read($)
return "" if(!defined($buf)); return "" if(!defined($buf));
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $blockSenderID = ReadingsVal($name, "blockSenderID", "no");
my $baseID = hex $hash->{BaseID};
my $lastID = hex $hash->{LastID};
my $ll5 = GetLogLevel($name, 5); my $ll5 = GetLogLevel($name, 5);
my $ll2 = GetLogLevel($name, 2); my $ll2 = GetLogLevel($name, 2);
@ -224,13 +236,13 @@ TCM_Read($)
my $rest = substr($data, 28); my $rest = substr($data, 28);
if($crc ne $mycrc) { if($crc ne $mycrc) {
Log $ll2, "$name: wrong checksum: got $crc, computed $mycrc" ; Log $ll2, "TCM: $name wrong checksum: got $crc, computed $mycrc" ;
$data = $rest; $data = $rest;
next; next;
} }
# Receive Radio Telegram (RRT)
if($net =~ m/^0B(..)(........)(........)(..)/) { 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);
# Re-translate the ORG to RadioORG / TCM310 equivalent # Re-translate the ORG to RadioORG / TCM310 equivalent
@ -240,9 +252,15 @@ TCM_Read($)
} else { } else {
Log 1, "TCM120: unknown ORG mapping for $org"; Log 1, "TCM120: unknown ORG mapping for $org";
} }
Dispatch($hash, "EnOcean:$org:$d1:$id:$status", undef);
} else { # Receive Message Telegram (RMT) if ($blockSenderID eq "own" && (hex $id) >= $baseID && (hex $id) <= $lastID) {
Log $ll5, "TCM: $name Telegram from $id blocked.";
} else {
Dispatch($hash, "EnOcean:$org:$d1:$id:$status", undef);
}
} else {
# Receive Message Telegram (RMT)
TCM_Parse120($hash, $net, 0); TCM_Parse120($hash, $net, 0);
} }
@ -272,14 +290,14 @@ TCM_Read($)
my $mycrc = TCM_CRC8($hdr); my $mycrc = TCM_CRC8($hdr);
if($mycrc ne $crc) { if($mycrc ne $crc) {
Log $ll2, "$name: wrong header checksum: got $crc, computed $mycrc" ; Log $ll2, "TCM: $name wrong header checksum: got $crc, computed $mycrc" ;
$data = $rest; $data = $rest;
next; next;
} }
$mycrc = TCM_CRC8($mdata . $odata); $mycrc = TCM_CRC8($mdata . $odata);
$crc = substr($data, -2); $crc = substr($data, -2);
if($mycrc ne $crc) { if($mycrc ne $crc) {
Log $ll2, "$name: wrong data checksum: got $crc, computed $mycrc" ; Log $ll2, "TCM: $name wrong data checksum: got $crc, computed $mycrc" ;
$data = $rest; $data = $rest;
next; next;
} }
@ -289,11 +307,19 @@ TCM_Read($)
my ($org, $d1, $id, $status) = ($1,$2,$3,$4); my ($org, $d1, $id, $status) = ($1,$2,$3,$4);
$odata =~ m/^(..)(........)(..)(..)$/; $odata =~ m/^(..)(........)(..)(..)$/;
my %addvals = (SubTelNum => hex($1), DestinationID => $2, my %addvals = (
RSSI => hex($3), SecurityLevel => hex($4),); SubTelNum => hex($1),
DestinationID => $2,
RSSI => hex($3),
SecurityLevel => hex($4),
);
$hash->{RSSI} = hex($3); $hash->{RSSI} = hex($3);
if ($blockSenderID eq "own" && (hex $id) >= $baseID && (hex $id) <= $lastID) {
Log $ll5, "TCM: $name Telegram from $id blocked.";
} else {
Dispatch($hash, "EnOcean:$org:$d1:$id:$status:$odata", \%addvals); Dispatch($hash, "EnOcean:$org:$d1:$id:$status:$odata", \%addvals);
}
} elsif($t eq "02") { } elsif($t eq "02") {
my $rc = substr($mdata, 0, 2); my $rc = substr($mdata, 0, 2);
@ -441,6 +467,7 @@ TCM_Ready($)
my %gets120 = ( my %gets120 = (
"sensitivity" => "AB48", "sensitivity" => "AB48",
"idbase" => "AB58", "idbase" => "AB58",
"baseID" => "AB58",
"modem_status" => "AB68", "modem_status" => "AB68",
"sw_ver" => "AB4B", "sw_ver" => "AB4B",
); );
@ -453,7 +480,10 @@ my %gets310 = (
ChipVersion => "13,4", ChipVersion => "13,4",
Desc => "17,16,STR",}, Desc => "17,16,STR",},
"idbase" => {cmd => "08", "idbase" => {cmd => "08",
BaseId => "1,4", BaseID => "1,4",
RemainingWriteCycles => "5,1",},
"baseID" => {cmd => "08",
BaseID => "1,4",
RemainingWriteCycles => "5,1",}, RemainingWriteCycles => "5,1",},
"repeater" => {cmd => "10", "repeater" => {cmd => "10",
repEnable => "1,1", repEnable => "1,1",
@ -518,6 +548,7 @@ TCM_RemovePair($)
my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer
"pairForSec" => { cmd=>"AB18", arg=>"\\d+" }, "pairForSec" => { cmd=>"AB18", arg=>"\\d+" },
"idbase" => { cmd=>"AB18", arg=>"FF[8-9A-F][0-9A-F]{5}" }, "idbase" => { cmd=>"AB18", arg=>"FF[8-9A-F][0-9A-F]{5}" },
"baseID" => { cmd=>"AB18", arg=>"FF[8-9A-F][0-9A-F]{5}" },
"sensitivity" => { cmd=>"AB08", arg=>"0[01]" }, "sensitivity" => { cmd=>"AB08", arg=>"0[01]" },
"sleep" => { cmd=>"AB09" }, "sleep" => { cmd=>"AB09" },
"wake" => { cmd=>"" }, # Special "wake" => { cmd=>"" }, # Special
@ -529,6 +560,7 @@ my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer
my %sets310 = ( my %sets310 = (
"pairForSec" => { cmd=>"AB18", arg=>"\\d+" }, "pairForSec" => { cmd=>"AB18", arg=>"\\d+" },
"idbase" => { cmd=>"07", arg=>"FF[8-9A-F][0-9A-F]{5}" }, "idbase" => { cmd=>"07", arg=>"FF[8-9A-F][0-9A-F]{5}" },
"baseID" => { cmd=>"07", arg=>"FF[8-9A-F][0-9A-F]{5}" },
# The following 3 does not seem to work / dont get an answer # The following 3 does not seem to work / dont get an answer
# "sleep" => { cmd=>"01", arg=>"00[0-9A-F]{6}" }, # "sleep" => { cmd=>"01", arg=>"00[0-9A-F]{6}" },
# "reset" => { cmd=>"02" }, # "reset" => { cmd=>"02" },
@ -711,6 +743,12 @@ TCM_Undef($$)
As the TCM120 and the TCM310 speak completely different protocols, this As the TCM120 and the TCM310 speak completely different protocols, this
module implements 2 drivers in one. It is the "physical" part for the <a module implements 2 drivers in one. It is the "physical" part for the <a
href="#EnOcean">EnOcean</a> module.<br><br> href="#EnOcean">EnOcean</a> module.<br><br>
Please note that EnOcean repeaters also send Fhem data telegrams again. Use
<code>attr &lt;name&gt; <a href="#blockSenderID">blockSenderID</a> own</code>
to block receiving telegrams with TCM SenderIDs.<br>
The address range used by your transceiver module, you can find in the
parameters BaseID and LastID.
<br><br>
<a name="TCMdefine"></a> <a name="TCMdefine"></a>
<b>Define</b> <b>Define</b>
@ -735,41 +773,52 @@ TCM_Undef($$)
<a name="TCMset"></a> <a name="TCMset"></a>
<b>Set </b> <b>Set </b>
<ul> <ul>
<li>baseID<br>
Set the BaseID.<br>
Note: The firmware executes this command only up to then times to prevent misuse.
</li>
<li>idbase<br> <li>idbase<br>
Set the ID base. Note: The firmware executes this command only up to Set the BaseID.<br>
then times to prevent misuse. Note: The firmware executes this command only up to then times to prevent misuse.
</li> </li>
<li>modem_off</li> <li>modem_off</li>
<li>modem_on</li> <li>modem_on</li>
<li>reset</li> <li>reset</li>
<li>sensitivity</li> <li>sensitivity</li>
<li>sleep</li> <li>sleep</li>
<li>wake <li>wake</li><br>
For details see the datasheet available from For details see the datasheet available from <a href="http://www.enocean.com">www.enocean.com</a>.
www.enocean.com. If you do not understand it, than you probably don't If you do not understand it, than you probably don't need it :)
need it :) <br><br>
</li><br><br>
</ul> </ul>
<a name="TCMget"></a> <a name="TCMget"></a>
<b>Get</b> <b>Get</b>
<ul> <ul>
<li>baseID<br>
Get the BaseID. You need this command in order to control EnOcean devices,
see the <a href="#EnOceandefine">EnOcean</a> paragraph.
</li>
<li>idbase<br> <li>idbase<br>
Get the ID base. You need this command in order to control EnOcean Get the BaseID. You need this command in order to control EnOcean devices,
devices, see the <a href="#EnOceandefine">EnOcean</a> see the <a href="#EnOceandefine">EnOcean</a> paragraph.
paragraph.</li>><br> </li>
<li>modem_status</li><br> <li>modem_status</li>
<li>sensitivity</li><br> <li>sensitivity</li>
<li>sw_ver<br> <li>sw_ver</li><br>
for details see the datasheet available from www.enocean.com For details see the datasheet available from <a href="http://www.enocean.com">www.enocean.com</a>
</li><br> <br><br>
</ul> </ul>
<a name="TCMattr"></a> <a name="TCMattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li><a href="#do_not_notify">do_not_notify</a></li> <li><a name="blockSenderID">blockSenderID</a> &lt;own|no&gt;,
[blockSenderID] = no is default.<br>
Block receiving telegrams with a TCM SenderID sent by repeaters.
</li>
<li><a href="#attrdummy">dummy</a></li> <li><a href="#attrdummy">dummy</a></li>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
</ul> </ul>
<br> <br>