From 1d342bb701f27e955b656a335f79c9a349f1b0a6 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 21 Sep 2018 18:04:35 +0000 Subject: [PATCH] 00_MQTT2_SERVER.pm: add some more debugging (Forum #91304) git-svn-id: https://svn.fhem.de/fhem/trunk@17381 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_MQTT2_SERVER.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/00_MQTT2_SERVER.pm b/fhem/FHEM/00_MQTT2_SERVER.pm index 3a3c15a58..c45c8c2e9 100644 --- a/fhem/FHEM/00_MQTT2_SERVER.pm +++ b/fhem/FHEM/00_MQTT2_SERVER.pm @@ -339,7 +339,7 @@ MQTT2_SERVER_Read($@) delete($hash->{answerScheduled}); my $r = $defs{$sname}{retain}; foreach my $tp (sort { $r->{$a}{ts} <=> $r->{$b}{ts} } keys %{$r}) { - MQTT2_SERVER_sendto($hash, $tp, $r->{$tp}{val}); + MQTT2_SERVER_sendto($defs{$sname}, $hash, $tp, $r->{$tp}{val}); } }, undef, 0); } @@ -394,7 +394,8 @@ MQTT2_SERVER_doPublish($$$$;$) } foreach my $clName (keys %{$tgt->{clients}}) { - MQTT2_SERVER_sendto($defs{$clName}, $tp, $val) if($src->{NAME} ne $clName); + MQTT2_SERVER_sendto($tgt, $defs{$clName}, $tp, $val) + if($src->{NAME} ne $clName); } if(defined($src->{cid})) { # "real" MQTT client @@ -410,9 +411,9 @@ MQTT2_SERVER_doPublish($$$$;$) ###################################### # send topic to client if its subscription matches the topic sub -MQTT2_SERVER_sendto($$$) +MQTT2_SERVER_sendto($$$$) { - my ($hash, $topic, $val) = @_; + my ($shash, $hash, $topic, $val) = @_; return if(IsDisabled($hash->{NAME})); $val = "" if(!defined($val)); foreach my $s (keys %{$hash->{subscriptions}}) { @@ -420,6 +421,7 @@ MQTT2_SERVER_sendto($$$) $re =~ s,/?#,\\b.*,g; $re =~ s,\+,\\b[^/]+\\b,g; if($topic =~ m/^$re$/) { + Log3 $shash, 5, "$hash->{NAME} $hash->{cid} => $topic:$val"; addToWritebuffer($hash, pack("C",0x30). MQTT2_SERVER_calcRemainingLength(2+length($topic)+length($val)).