mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
37_SHC: go back to last release version v0.9.0
git-svn-id: https://svn.fhem.de/fhem/trunk@8190 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cd718e50b0
commit
249c96d0d9
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- bugfix: 37_SHC: go back to last release version v0.9.0 (rr2000)
|
||||
- change: SYSMON: prevent some warnings
|
||||
- bugfix: SYSMON: ethernet readings on bbb (thx to nesges)
|
||||
- changed: 37_SHC: now add all files for the previous commit (rr2000)
|
||||
|
@ -2,7 +2,6 @@
|
||||
# This file is part of the smarthomatic module for FHEM.
|
||||
#
|
||||
# Copyright (c) 2014 Stefan Baumann
|
||||
# 2015 Uwe Freese
|
||||
#
|
||||
# You can find smarthomatic at www.smarthomatic.org.
|
||||
# You can find FHEM at www.fhem.de.
|
||||
@ -27,7 +26,6 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use Digest::CRC qw(crc32); # linux packet libdigest-crc-perl
|
||||
|
||||
sub SHC_Parse($$$$);
|
||||
sub SHC_Read($);
|
||||
@ -39,7 +37,7 @@ sub SHC_SimpleWrite(@);
|
||||
my $clientsSHC = ":SHCdev:BASE:xxx:";
|
||||
|
||||
my %matchListSHC = (
|
||||
"1:SHCdev" => "^PKT:SID=([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-3][0-9][0-9][0-9]|40[0-8][0-9]|409[0-6]);", #1-4096
|
||||
"1:SHCdev" => "^Packet Data: SenderID=[1-9]|0[1-9]|[1-9][0-9]|[0-9][0-9][0-9]|[0-3][0-9][0-9][0-9]|40[0-8][0-9]|409[0-6]", #1-4096 with leading zeros
|
||||
"2:xxx" => "^\\S+\\s+22",
|
||||
"3:xxx" => "^\\S+\\s+11",
|
||||
"4:xxx" => "^\\S+\\s+9 ",
|
||||
@ -271,15 +269,11 @@ sub SHC_Parse($$$$)
|
||||
|
||||
next if (!$dmsg || length($dmsg) < 1); # Bogus messages
|
||||
|
||||
if ($dmsg =~ m/^PKT:SID=0;/) { # "echo" from message sent by FHEM itself
|
||||
return;
|
||||
}
|
||||
|
||||
if ($dmsg !~ m/^PKT:SID=/) {
|
||||
if ($dmsg !~ m/^Packet Data: SenderID=/) {
|
||||
|
||||
# Messages just to dipose
|
||||
if ( $dmsg =~ m/^\*\*\* Enter data/
|
||||
|| $dmsg =~ m/^\*\*\* 0x/)
|
||||
if ( $dmsg =~ m/^\*\*\* Enter AES key nr/
|
||||
|| $dmsg =~ m/^\*\*\* Received character/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -300,34 +294,17 @@ sub SHC_Parse($$$$)
|
||||
# -Verbosity level 4
|
||||
if ( $dmsg =~ m/^Request added to queue/
|
||||
|| $dmsg =~ m/^Request Buffer/
|
||||
|| $dmsg =~ m/^Request Queue/)
|
||||
|| $dmsg =~ m/^Request (q|Q)ueue/)
|
||||
{
|
||||
Log3 $name, 4, "$name: $dmsg";
|
||||
return;
|
||||
}
|
||||
|
||||
# -Verbosity level 1
|
||||
if ( $dmsg =~ m/^CRC Error/ )
|
||||
{
|
||||
Log3 $name, 1, "$name: $dmsg";
|
||||
return;
|
||||
}
|
||||
|
||||
# Anything else in verbosity level 3
|
||||
Log3 $name, 3, "$name: $dmsg";
|
||||
return;
|
||||
}
|
||||
|
||||
# check CRC of "PKT:..." message and ignore message if necessary
|
||||
my $crc = crc32(substr($dmsg, 4, length($dmsg) - 12));
|
||||
$crc = sprintf("%08x", $crc);
|
||||
|
||||
if ($crc ne substr($dmsg, length($dmsg) - 8))
|
||||
{
|
||||
Log3 $name, 1, "$name: CRC Error (" . $crc . ") $dmsg";
|
||||
return;
|
||||
}
|
||||
|
||||
$hash->{"${name}_MSGCNT"}++;
|
||||
$hash->{"${name}_TIME"} = TimeNow();
|
||||
$hash->{RAWMSG} = $rmsg;
|
||||
|
@ -1,8 +1,7 @@
|
||||
##########################################################################
|
||||
# This file is part of the smarthomatic module for FHEM.
|
||||
#
|
||||
# Copyright (c) 2014 Stefan Baumann
|
||||
# 2014..2015 Uwe Freese
|
||||
# Copyright (c) 2014 Stefan Baumann, Uwe Freese
|
||||
#
|
||||
# You can find smarthomatic at www.smarthomatic.org.
|
||||
# You can find FHEM at www.fhem.de.
|
||||
@ -64,10 +63,7 @@ my %dev_state_format = (
|
||||
"port", "Port: ",
|
||||
"ains", "Ain: "
|
||||
],
|
||||
"RGBDimmer" => [
|
||||
"color", "Color: ",
|
||||
"brightness", "Brightness: "
|
||||
],
|
||||
"RGBDimmer" => ["color", "Color: "],
|
||||
"SoilMoistureMeter" => ["humidity", "H: "]
|
||||
);
|
||||
|
||||
@ -82,14 +78,13 @@ my %sets = (
|
||||
"DigitalPort " .
|
||||
"DigitalPortTimeout " .
|
||||
"DigitalPin " .
|
||||
"DigitalPinTimeout",
|
||||
"DigitalPinTimeout ",
|
||||
"Dimmer" => "on:noArg off:noArg toggle:noArg statusRequest:noArg pct:slider,0,1,100 ani " .
|
||||
# Used from SetExtensions.pm
|
||||
"blink on-for-timer on-till off-for-timer off-till intervals",
|
||||
"EnvSensor" => "",
|
||||
"RGBDimmer" => "Color " .
|
||||
"ColorAnimation " .
|
||||
"Dimmer.Brightness:slider,0,1,100",
|
||||
"ColorAnimation",
|
||||
"SoilMoistureMeter" => "",
|
||||
"Custom" => "Dimmer.Brightness " .
|
||||
"Dimmer.Animation"
|
||||
@ -112,7 +107,7 @@ sub SHCdev_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
$hash->{Match} = "^PKT:SID=([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-3][0-9][0-9][0-9]|40[0-8][0-9]|409[0-6]);";
|
||||
$hash->{Match} = "^Packet Data: SenderID=[1-9]|0[1-9]|[1-9][0-9]|[0-9][0-9][0-9]|[0-3][0-9][0-9][0-9]|40[0-8][0-9]|409[0-6]";
|
||||
$hash->{SetFn} = "SHCdev_Set";
|
||||
$hash->{GetFn} = "SHCdev_Get";
|
||||
$hash->{DefFn} = "SHCdev_Define";
|
||||
@ -190,7 +185,7 @@ sub SHCdev_Parse($$)
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
if (!$parser->parse($msg)) {
|
||||
Log3 $name, 1, "$name: Parser error: $msg";
|
||||
Log3 $hash, 4, "SHC_TEMP: parser error: $msg";
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -202,7 +197,7 @@ sub SHCdev_Parse($$)
|
||||
my $rname = $rhash ? $rhash->{NAME} : $raddr;
|
||||
|
||||
if (!$modules{SHCdev}{defptr}{$raddr}) {
|
||||
Log3 $name, 3, "$name: Unknown device $rname, please define it";
|
||||
Log3 $name, 3, "SHC_TEMP: Unknown device $rname, please define it";
|
||||
return "UNDEFINED SHCdev_$rname SHCdev $raddr";
|
||||
}
|
||||
|
||||
@ -610,16 +605,6 @@ sub SHCdev_Set($@)
|
||||
}
|
||||
readingsSingleUpdate($hash, "state", "set-coloranimation", 1);
|
||||
SHCdev_Send($hash);
|
||||
} elsif ($cmd eq 'Dimmer.Brightness') {
|
||||
my $brightness = $arg;
|
||||
|
||||
# DEBUG
|
||||
# Log3 $name, 3, "$name: Args: $arg, $arg2, $arg3, $brightness";
|
||||
|
||||
readingsSingleUpdate($hash, "state", "set-brightness:$brightness", 1);
|
||||
$parser->initPacket("Dimmer", "Brightness", "SetGet");
|
||||
$parser->setField("Dimmer", "Brightness", "Brightness", $brightness);
|
||||
SHCdev_Send($hash);
|
||||
} else {
|
||||
return SetExtensions($hash, "", $name, @aa);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
##########################################################################
|
||||
# This file is part of the smarthomatic module for FHEM.
|
||||
#
|
||||
# Copyright (c) 2014, 2015 Uwe Freese
|
||||
# Copyright (c) 2014 Uwe Freese
|
||||
#
|
||||
# You can find smarthomatic at www.smarthomatic.org.
|
||||
# You can find FHEM at www.fhem.de.
|
||||
@ -30,12 +30,11 @@
|
||||
# Receiving packets:
|
||||
# ------------------
|
||||
# 1.) Receive string from base station (over UART).
|
||||
# 2.) Check CRC (last 8 characters, optional).
|
||||
# 3.) Parse received string:
|
||||
# $parser->parse("PKT:SID=22;...");
|
||||
# 4.) Get MessageGroupName: my $grp = $parser->getMessageGroupName();
|
||||
# 5.) Get MessageName: my $msg = $parser->getMessageName();
|
||||
# 6.) Get data fields depending on MessageGroupName and MessageName, e.g.
|
||||
# 2.) Parse received string:
|
||||
# $parser->parse("Packet Data: SenderID=22;...");
|
||||
# 3.) Get MessageGroupName: my $grp = $parser->getMessageGroupName();
|
||||
# 4.) Get MessageName: my $msg = $parser->getMessageName();
|
||||
# 5.) Get data fields depending on MessageGroupName and MessageName, e.g.
|
||||
# $val = $parser->getField("Temperature");
|
||||
#
|
||||
# Sending packets:
|
||||
@ -45,7 +44,6 @@
|
||||
# 2.) Set fields:
|
||||
# $parser->setField("PowerSwitch", "SwitchState", "TimeoutSec", 8);
|
||||
# 3.) Get send string: $str = $parser->getSendString($receiverID);
|
||||
# It includes a CRC32 as last 8 characters.
|
||||
# 4.) Send string to base station (over UART).
|
||||
##########################################################################
|
||||
# $Id$
|
||||
@ -56,7 +54,6 @@ use strict;
|
||||
use feature qw(switch);
|
||||
use XML::LibXML;
|
||||
use SHC_datafields;
|
||||
use Digest::CRC qw(crc32); # linux packet libdigest-crc-perl
|
||||
|
||||
# Hash for data field definitions.
|
||||
my %dataFields = ();
|
||||
@ -253,10 +250,10 @@ sub parse
|
||||
if (
|
||||
(
|
||||
$msg =~
|
||||
/^PKT:SID=(\d+);PC=(\d+);MT=(\d+);MGID=(\d+);MID=(\d+);MD=([^;]+);.*/
|
||||
/^Packet Data: SenderID=(\d*);PacketCounter=(\d*);MessageType=(\d*);MessageGroupID=(\d*);MessageID=(\d*);MessageData=([^;]*);.*/
|
||||
)
|
||||
|| ($msg =~
|
||||
/^PKT:SID=(\d+);PC=(\d+);MT=(\d+);ASID=\d+;APC=\d+;E=\d+;MGID=(\d+);MID=(\d+);MD=([^;]+);.*/
|
||||
/^Packet Data: SenderID=(\d*);PacketCounter=(\d*);MessageType=(\d*);AckSenderID=\d*;AckPacketCounter=\d*;Error=\d*;MessageGroupID=(\d*);MessageID=(\d*);MessageData=([^;]*);.*/
|
||||
)
|
||||
)
|
||||
{
|
||||
@ -314,9 +311,6 @@ sub getMessageData
|
||||
$res .= sprintf("%02X", $_);
|
||||
}
|
||||
|
||||
# strip trailing zeros (pairwise)
|
||||
$res =~ s/(00)+$//;
|
||||
|
||||
return $res;
|
||||
} else {
|
||||
return $self->{_messageData};
|
||||
@ -371,8 +365,8 @@ sub setField
|
||||
$obj->setValue(\@msgData, $value, $index);
|
||||
}
|
||||
|
||||
# cKK01RRRRGGMMDD{CRC32}
|
||||
# c0001003D3C0164 = SET Dimmer Switch Brightness 50%
|
||||
# sKK01RRRRGGMMDD
|
||||
# s0001003D3C0164 = SET Dimmer Switch Brightness 50%
|
||||
sub getSendString
|
||||
{
|
||||
my ($self, $receiverID, $aesKeyNr) = @_;
|
||||
@ -388,15 +382,13 @@ sub getSendString
|
||||
$aesKeyNr = 0;
|
||||
}
|
||||
|
||||
my $s = "c"
|
||||
my $s = "s"
|
||||
. sprintf("%02X", $aesKeyNr)
|
||||
. sprintf("%02X", $self->{_messageTypeID})
|
||||
. sprintf("%04X", $receiverID)
|
||||
. sprintf("%02X", $self->{_messageGroupID})
|
||||
. sprintf("%02X", $self->{_messageID})
|
||||
. getMessageData();
|
||||
|
||||
return $s . sprintf("%08x", crc32($s));
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user