2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-08 13:24:56 +00:00

MYSENSORS: request gateway-version on connect, fix ack=>0 for I_VERSION and I_INCLUSION_MODE

git-svn-id: https://svn.fhem.de/fhem/trunk@6910 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2014-11-07 22:15:45 +00:00
parent b33dabd925
commit 33e897e7ce
2 changed files with 8 additions and 3 deletions

View File

@ -214,6 +214,7 @@ sub Init($) {
});
}
readingsSingleUpdate($hash,"connection","connected",1);
sendMessage($hash, radioId => 0, childId => 0, cmd => C_INTERNAL, ack => 0, subType => I_VERSION, payload => '');
return undef;
}
@ -349,6 +350,10 @@ sub onInternalMsg($$) {
});
last;
};
$type == I_VERSION and do {
$hash->{version} = $msg->{payload};
last;
};
$type == I_LOG_MESSAGE and do {
Log3($hash->{NAME},5,"MYSENSORS gateway $hash->{NAME}: $msg->{payload}");
last;
@ -405,7 +410,7 @@ sub onAcknowledge($$) {
sub sendMessage($%) {
my ($hash,%msg) = @_;
$msg{ack} = $hash->{ack} unless $msg{ack};
$msg{ack} = $hash->{ack} unless defined $msg{ack};
my $txt = createMsg(%msg);
Log3 ($hash->{NAME},5,"MYSENSORS send: ".dumpMsg(\%msg));
DevIo_SimpleWrite($hash,"$txt\n",undef);

View File

@ -515,7 +515,7 @@ sub onInternalMessage($$) {
sub sendClientMessage($%) {
my ($hash,%msg) = @_;
$msg{radioId} = $hash->{radioId};
$msg{ack} = 1 if $hash->{ack};
$msg{ack} = $hash->{ack} unless defined $msg{ack};
sendMessage($hash->{IODev},%msg);
}
@ -527,7 +527,7 @@ sub rawToMappedReading($$$$) {
if(defined (my $val = $mapping->{val} // $hash->{typeMappings}->{$type}->{val})) {
return ($mapping->{name},$val->{$value} // $value);
}
die "not type-mapping for type ".variableTypeToStr($type);
die "no type-mapping for type ".variableTypeToStr($type);
}
die "no reading-mapping for childId $childId, type ".($hash->{typeMappings}->{$type}->{type} ? $hash->{typeMappings}->{$type}->{type} : variableTypeToStr($type));
}