Fixing EnOcean send routines, implementing it for the TCM310
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@1060 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -100,16 +100,17 @@ TCM_Write($$$)
|
||||
$bstring = "A55A".$bstring.TCM_CSUM($bstring);
|
||||
|
||||
} else { # 310 / ESP3
|
||||
|
||||
if(!$fn) { # Radio Paket from the EnOcean Module
|
||||
$msg =~ m/^6B05(..)000000(........)(..)$/;
|
||||
# FIXME
|
||||
$fn = "00070701";
|
||||
$msg = "F6$1$2${3}03FFFFFFFFFF00";
|
||||
}
|
||||
|
||||
$bstring = sprintf("55%s%s%s%s", # $fn == Header, $msg == DATA
|
||||
$fn, TCM_CRC8($fn), $msg, TCM_CRC8($msg));
|
||||
|
||||
}
|
||||
Log $ll5, "$hash->{NAME} sending $bstring";
|
||||
Log $ll5, "$hash->{NAME} sending $bstring";
|
||||
|
||||
DevIo_SimpleWrite($hash, $bstring);
|
||||
}
|
||||
@@ -201,7 +202,7 @@ TCM_Read($)
|
||||
|
||||
# Receive Radio Telegram (RRT)
|
||||
if($net =~ m/^0B(..)(........)(........)(..)/) {
|
||||
my ($org, $d1,$id,$status) = ($1, $2);
|
||||
my ($org, $d1,$id,$status) = ($1, $2, $3, $4);
|
||||
|
||||
# Re-translate the ORG to RadioORG / TCM310 equivalent
|
||||
my %orgmap = ("05"=>"F6", "06"=>"D5", "07"=>"A5", );
|
||||
@@ -265,12 +266,23 @@ TCM_Read($)
|
||||
|
||||
Dispatch($hash, "EnOcean:$org:$d1:$id:$status:$odata", \%addvals);
|
||||
|
||||
} elsif($t eq "02") {
|
||||
my $rc = substr($mdata, 0, 2);
|
||||
my %codes = (
|
||||
"00"=>"RET_OK",
|
||||
"01"=>"RET_ERROR",
|
||||
"02"=>"RET_NOT_SUPPORTED",
|
||||
"03"=>"RET_WRONG_PARAM",
|
||||
"04"=>"RET_OPERATION_DENIED",
|
||||
);
|
||||
$rc = $codes{$rc} if($codes{$rc});
|
||||
Log $ll2, "$name: RESPONSE: $rc" ;
|
||||
|
||||
} else {
|
||||
Log $ll2, "$name: unknown packet type $t: $data" ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if(length($data) >= 4) {
|
||||
$data =~ s/.*55/55/ if($data !~ m/^55/);
|
||||
|
||||
@@ -67,23 +67,35 @@ EnOcean_Set($@)
|
||||
{
|
||||
my ($hash, @a) = @_;
|
||||
return "no set value specified" if(@a < 2);
|
||||
return "there a no set commands with argument" if(@a > 2);
|
||||
|
||||
my $cmd = $a[1];
|
||||
my $arg = $a[2];
|
||||
my $cmdhash = $ptm200btn{$cmd};
|
||||
return "Unknown argument $cmd, choose one of " .
|
||||
join(" ", sort keys %ptm200btn) if(!defined($cmdhash));
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
my $ll2 = GetLogLevel($name, 2);
|
||||
Log $ll2, "EnOcean: set $name $cmd";
|
||||
|
||||
my ($db_3, $status) = split(":", $cmdhash, 2);
|
||||
IOWrite($hash, "",
|
||||
sprintf("6B05%s000000%s%s", ($db_3<<5), $hash->{DEF}, $status));
|
||||
shift @a;
|
||||
for(my $i = 0; $i < @a; $i++) {
|
||||
my $cmd = $a[$i];
|
||||
my ($c1,$c2) = split(",", $cmd, 2);
|
||||
return "Unknown argument $cmd, choose one of " .
|
||||
join(" ", sort keys %ptm200btn)
|
||||
if(!defined($ptm200btn{$c1}) || ($c2 && !defined($ptm200btn{$c2})));
|
||||
Log $ll2, "EnOcean: set $name $cmd";
|
||||
|
||||
my ($db_3, $status) = split(":", $ptm200btn{$c1}, 2);
|
||||
$db_3 <<= 5;
|
||||
$db_3 |= 0x10 if($c1 ne "released"); # set the pressed flag
|
||||
if($c2) {
|
||||
my ($d2, undef) = split(":", $ptm200btn{$c2}, 2);
|
||||
$db_3 |= ($d2<<1) | 0x01;
|
||||
}
|
||||
|
||||
IOWrite($hash, "",
|
||||
sprintf("6B05%02X000000%s%s", $db_3, $hash->{DEF}, $status));
|
||||
|
||||
select(undef, undef, undef, 0.1) if($i < int(@a)-1);
|
||||
}
|
||||
|
||||
my $tn = TimeNow();
|
||||
my $cmd = join(" ", @a);
|
||||
$hash->{CHANGED}[0] = $cmd;
|
||||
$hash->{STATE} = $cmd;
|
||||
$hash->{READINGS}{state}{TIME} = $tn;
|
||||
@@ -134,8 +146,11 @@ EnOcean_Parse($$)
|
||||
|
||||
if($nu) {
|
||||
|
||||
# Theoretically there can be a released event with some of the A0,BI
|
||||
# pins set, but with the plastic cover on this wont happen.
|
||||
$msg = $ptm200btn[($db_3&0xe0)>>5];
|
||||
$msg .= ",".$ptm200btn[($db_3&0x0e)>>1] if($db_3 & 1);
|
||||
$msg .= " released" if(!($db_3 & 0x10));
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user