2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

00_MQTT2_CLIENT.pm: add optional retain to msgAfterConnect (Forum #101932)

git-svn-id: https://svn.fhem.de/fhem/trunk@19775 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-07-04 19:55:24 +00:00
parent 536114aa7b
commit a59f1dd9e6

View File

@ -177,7 +177,8 @@ MQTT2_CLIENT_Disco($;$)
RemoveInternalTimer($hash);
$hash->{connecting} = 1 if(!$isUndef);
my $ond = AttrVal($hash->{NAME}, "msgBeforeDisconnect", "");
MQTT2_CLIENT_doPublish($hash, split(" ", $ond, 2), 0, 1) if($ond);
MQTT2_CLIENT_doPublish($hash, $2, $3, $1)
if($ond =~ m/^(-r\s)?([^\s]*)\s*(.*)$/);
MQTT2_CLIENT_send($hash, pack("C",0xE0).pack("C",0), 1); # DISCONNECT
$isUndef ? DevIo_CloseDev($hash) : DevIo_Disconnected($hash);
}
@ -325,7 +326,8 @@ MQTT2_CLIENT_Read($@)
if($hash->{connecting}) {
delete($hash->{connecting});
my $onc = AttrVal($name, "msgAfterConnect", "");
MQTT2_CLIENT_doPublish($hash, split(" ", $onc, 2)) if($onc);
MQTT2_CLIENT_doPublish($hash, $2, $3, $1)
if($onc =~ m/^(-r\s)?([^\s]*)\s*(.*)$/);
}
} elsif($cpt eq "PINGRESP") { # ignore it
@ -569,13 +571,15 @@ MQTT2_CLIENT_getStr($$)
</li></br>
<a name="msgAfterConnect"></a>
<li>msgAfterConnect topic message<br>
publish the topic after each connect or reconnect.
<li>msgAfterConnect [-r] topic message<br>
publish the topic after each connect or reconnect.<br>
If the optional -r is specified, then the publish sets the retain flag.
</li></br>
<a name="msgBeforeDisconnect"></a>
<li>msgBeforeDisconnect topic message<br>
publish the topic bofore each disconnect.
<li>msgBeforeDisconnect [-r] topic message<br>
publish the topic bofore each disconnect.<br>
If the optional -r is specified, then the publish sets the retain flag.
</li></br>
<a name="rawEvents"></a>