MAX: unify duplicate definitions

git-svn-id: https://svn.fhem.de/fhem/trunk@2289 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mgehre
2012-12-09 14:59:22 +00:00
parent d01f286730
commit 3763a1d4a3
3 changed files with 35 additions and 48 deletions

View File

@@ -8,6 +8,10 @@ use warnings;
use MIME::Base64; use MIME::Base64;
use POSIX; use POSIX;
require "10_MAX.pm";
our %msgCmd2Id;
our %device_types;
sub MAXLAN_Parse($$); sub MAXLAN_Parse($$);
sub MAXLAN_Read($); sub MAXLAN_Read($);
sub MAXLAN_Write(@); sub MAXLAN_Write(@);
@@ -18,15 +22,6 @@ sub MAXLAN_SendDeviceCmd($$);
sub MAXLAN_RequestConfiguration($$); sub MAXLAN_RequestConfiguration($$);
sub MAXLAN_RemoveDevice($$); sub MAXLAN_RemoveDevice($$);
my %device_types = (
0 => "Cube",
1 => "HeatingThermostat",
2 => "HeatingThermostatPlus",
3 => "WallMountedThermostat",
4 => "ShutterContact",
5 => "PushButton"
);
my @boost_durations = (0, 5, 10, 15, 20, 25, 30, 60); my @boost_durations = (0, 5, 10, 15, 20, 25, 30, 60);
my $reconnect_interval = 2; #seconds my $reconnect_interval = 2; #seconds

View File

@@ -17,7 +17,11 @@ sub MAX_DateTime2Internal($);
my @ctrl_modes = ( "auto", "manual", "temporary", "boost" ); my @ctrl_modes = ( "auto", "manual", "temporary", "boost" );
my %device_types = ( use vars qw(%device_types);
use vars qw(%msgId2Cmd);
use vars qw(%msgCmd2Id);
%device_types = (
0 => "Cube", 0 => "Cube",
1 => "HeatingThermostat", 1 => "HeatingThermostat",
2 => "HeatingThermostatPlus", 2 => "HeatingThermostatPlus",
@@ -26,6 +30,25 @@ my %device_types = (
5 => "PushButton" 5 => "PushButton"
); );
%msgId2Cmd = (
"00" => "PairPing",
"01" => "PairPong",
"02" => "Ack",
"03" => "TimeInformation",
"11" => "ConfigTemperatures", #like boost/eco/comfort etc
"30" => "ShutterContactState",
"42" => "WallThermostatState", #by WallMountedThermostat
"60" => "ThermostatState", #by HeatingThermostat
"40" => "SetTemperature", #to thermostat
"20" => "AddLinkPartner",
"21" => "RemoveLinkPartner",
"22" => "SetGroupId",
"23" => "RemoveGroupId",
"F1" => "WakeUp",
"F0" => "Reset",
);
%msgCmd2Id = reverse %msgId2Cmd;
my %interfaces = ( my %interfaces = (
"Cube" => undef, "Cube" => undef,
"HeatingThermostat" => "thermostat;battery;temperature", "HeatingThermostat" => "thermostat;battery;temperature",

View File

@@ -5,6 +5,11 @@ package main;
use strict; use strict;
use warnings; use warnings;
require "10_MAX.pm";
our %msgId2Cmd;
our %msgCmd2Id;
our %device_types;
sub CUL_MAX_SendDeviceCmd($$); sub CUL_MAX_SendDeviceCmd($$);
sub CUL_MAX_Send(@); sub CUL_MAX_Send(@);
@@ -20,16 +25,6 @@ my $timeBroadcastInterval = 6*60*60; #= 6 hours, the same time that the cube use
my $resendRetries = 10; #how often resend before giving up? my $resendRetries = 10; #how often resend before giving up?
#TODO: this is duplicated in MAXLAN
my %device_types = (
0 => "Cube",
1 => "HeatingThermostat",
2 => "HeatingThermostatPlus",
3 => "WallMountedThermostat",
4 => "ShutterContact",
5 => "PushButton"
);
sub sub
CUL_MAX_Initialize($) CUL_MAX_Initialize($)
{ {
@@ -112,32 +107,6 @@ CUL_MAX_Set($@)
return undef; return undef;
} }
###################################
my %msgTypes = ( #Receiving:
"00" => "PairPing",
"01" => "PairPong",
"02" => "Ack",
"03" => "TimeInformation",
"11" => "ConfigTemperatures", #like boost/eco/comfort etc
"30" => "ShutterContactState",
"42" => "WallThermostatState", #by WallMountedThermostat
"60" => "ThermostatState", #by HeatingThermostat
"40" => "SetTemperature", #to thermostat
"20" => "AddLinkPartner",
"21" => "RemoveLinkPartner",
"22" => "SetGroupId",
"23" => "RemoveGroupId",
"F1" => "WakeUp",
"F0" => "Reset",
);
my %sendTypes = (#Sending:
"PairPong" => "01",
"TimeInformation" => "03",
#"40" => "SetTemperature",
#"11" => "SetConfiguration",
#"F1" => "WakeUp",
);
#Array of all packet that we wait to be ack'ed #Array of all packet that we wait to be ack'ed
my @waitForAck = (); my @waitForAck = ();
@@ -163,9 +132,9 @@ CUL_MAX_Parse($$)
#convert adresses to lower case #convert adresses to lower case
$src = lc($src); $src = lc($src);
$dst = lc($dst); $dst = lc($dst);
my $msgType = exists($msgTypes{$msgTypeRaw}) ? $msgTypes{$msgTypeRaw} : $msgTypeRaw; my $msgType = exists($msgId2Cmd{$msgTypeRaw}) ? $msgId2Cmd{$msgTypeRaw} : $msgTypeRaw;
Log 5, "CUL_MAX_Parse: len $len, msgcnt $msgcnt, msgflag $msgFlag, msgTypeRaw $msgType, src $src, dst $dst, groupid $groupid, payload $payload"; Log 5, "CUL_MAX_Parse: len $len, msgcnt $msgcnt, msgflag $msgFlag, msgTypeRaw $msgType, src $src, dst $dst, groupid $groupid, payload $payload";
if(exists($msgTypes{$msgTypeRaw})) { if(exists($msgId2Cmd{$msgTypeRaw})) {
if($msgType eq "Ack") { if($msgType eq "Ack") {
Dispatch($shash, "MAX,Ack,$src,$payload", {RAWMSG => $rmsg}); Dispatch($shash, "MAX,Ack,$src,$payload", {RAWMSG => $rmsg});
my $i = 0; my $i = 0;