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{