From 767da87ba258f8846d10d613cd0ea565306f8f77 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 27 Jun 2020 09:14:04 +0000 Subject: [PATCH] 00_MQTT2_CLIENT.pm: "dynamic" packet identifier (Forum #91304) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@22280 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/00_MQTT2_CLIENT.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FHEM/00_MQTT2_CLIENT.pm b/FHEM/00_MQTT2_CLIENT.pm index 0130ff72d..915d1a9f9 100644 --- a/FHEM/00_MQTT2_CLIENT.pm +++ b/FHEM/00_MQTT2_CLIENT.pm @@ -258,6 +258,7 @@ MQTT2_CLIENT_Attr(@) return "qosMaxQueueLength must be an integer" if($param[0] !~ m/^\d+$/); $hash->{qosMaxQueueLength} = $param[0]; $hash->{qosQueue} = []; + $hash->{qosCnt} = 0; } else { delete $hash->{qosQueue}; delete $hash->{qosMaxQueueLength}; @@ -424,6 +425,7 @@ MQTT2_CLIENT_Read($@) ###################################### # send topic to client if its subscriptions matches the topic + sub MQTT2_CLIENT_doPublish($@) { @@ -439,7 +441,7 @@ MQTT2_CLIENT_doPublish($@) @{$hash->{qosQueue}} < $hash->{qosMaxQueueLength}) { $hdr += 2; # QoS:1 push(@{$hash->{qosQueue}}, [$topic,$val,$retain]); - $pi = "FM"; # Packet Identifier, if QoS > 0 + $pi = pack("n",1+($hash->{qosCnt}++%65535)); # Packet Identifier, if QoS > 0 } my $msg = pack("C", $hdr). MQTT2_CLIENT_calcRemainingLength(2+length($topic)+length($val)+ @@ -468,7 +470,7 @@ MQTT2_CLIENT_send($$;$$) if($immediate) { DevIo_SimpleWrite($hash, $msg, 0); } else { - addToWritebuffer($hash, $msg); + addToWritebuffer($hash, $msg, undef, 1); # nolimit } }