From 6bc45d64266de82118164c6d590f2c9ba41fd013 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 18 Aug 2018 14:54:09 +0000 Subject: [PATCH] 00_MQTT2_SERVER.pm: accept clients with empty clientId (Forum #90145) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@17163 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/00_MQTT2_SERVER.pm | 13 +++++++------ FHEM/10_MQTT2_DEVICE.pm | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/FHEM/00_MQTT2_SERVER.pm b/FHEM/00_MQTT2_SERVER.pm index c0c74e160..b5937b3e6 100644 --- a/FHEM/00_MQTT2_SERVER.pm +++ b/FHEM/00_MQTT2_SERVER.pm @@ -221,11 +221,12 @@ MQTT2_SERVER_Read($@) my $cpt = $cptype{$cp}; $hash->{lastMsgTime} = gettimeofday(); - #my $pltxt = $pl; - #$pltxt =~ s/[^ -~]/./g; - #Log3 $sname, 5, "$pltxt"; + # Lowlevel debugging + # my $pltxt = $pl; + # $pltxt =~ s/([^ -~])/"(".ord($1).")"/ge; + # Log3 $sname, 5, "$pltxt"; - if(!$hash->{cid} && $cpt ne "CONNECT") { + if(!defined($hash->{cid}) && $cpt ne "CONNECT") { Log3 $sname, 2, "$cname $cpt before CONNECT, disconnecting"; CommandDelete(undef, $cname); return MQTT2_SERVER_Read($hash, 1); @@ -234,8 +235,8 @@ MQTT2_SERVER_Read($@) #################################### if($cpt eq "CONNECT") { ($hash->{protoTxt}, $off) = MQTT2_SERVER_getStr($pl, 0); # V3:MQIsdb V4:MQTT - $hash->{protoNum} = unpack('C*', substr($pl, $off++, 1)); - $hash->{cflags} = unpack('C*', substr($pl, $off++, 1)); + $hash->{protoNum} = unpack('C*', substr($pl,$off++,1)); # 3 or 4 + $hash->{cflags} = unpack('C*', substr($pl,$off++,1)); $hash->{keepalive} = unpack('n', substr($pl, $off, 2)); $off += 2; ($hash->{cid}, $off) = MQTT2_SERVER_getStr($pl, $off); diff --git a/FHEM/10_MQTT2_DEVICE.pm b/FHEM/10_MQTT2_DEVICE.pm index dce1c2aa1..300537c8b 100644 --- a/FHEM/10_MQTT2_DEVICE.pm +++ b/FHEM/10_MQTT2_DEVICE.pm @@ -126,7 +126,7 @@ MQTT2_DEVICE_Parse($$) # autocreate and expand readingList if($autocreate && !%fnd) { - return "" if($cid =~ m/mosqpub.*/); + return "" if($cid && $cid =~ m/mosqpub.*/); my $cidHash = $modules{MQTT2_DEVICE}{defptr}{cid}{$cid}; my $nn = $cidHash ? $cidHash->{NAME} : "MQTT2_$cid"; PrioQueue_add(sub{