mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
00_MQTT2_CLIENT.pm: add encoding unicode support
git-svn-id: https://svn.fhem.de/fhem/trunk@25700 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cb7641a1ba
commit
669f32a3d9
@ -500,6 +500,7 @@ MQTT2_CLIENT_Read($@)
|
||||
$off += 2;
|
||||
}
|
||||
$val = substr($pl, $off);
|
||||
$val = Encode::decode('UTF-8', $val) if($unicodeEncoding);
|
||||
MQTT2_CLIENT_send($hash, pack("CCnC*", 0x40, 2, $pid)) if($qos); # PUBACK
|
||||
MQTT2_CLIENT_updateDisconnectTimer($hash);
|
||||
|
||||
@ -565,6 +566,11 @@ MQTT2_CLIENT_doPublish($@)
|
||||
push(@{$hash->{qosQueue}}, [$topic,$val,$retain]);
|
||||
$pi = pack("n",1+($hash->{qosCnt}++%65535)); # Packet Identifier, if QoS > 0
|
||||
}
|
||||
|
||||
if($unicodeEncoding) {
|
||||
$topic = Encode::encode('UTF-8', $topic);
|
||||
$val = Encode::encode('UTF-8', $val);
|
||||
}
|
||||
my $msg = pack("C", $hdr).
|
||||
MQTT2_CLIENT_calcRemainingLength(2+length($topic)+length($val)+
|
||||
length($pi)).
|
||||
@ -660,7 +666,9 @@ MQTT2_CLIENT_getStr($$)
|
||||
{
|
||||
my ($in, $off) = @_;
|
||||
my $l = unpack("n", substr($in, $off, 2));
|
||||
return (substr($in, $off+2, $l), $off+2+$l);
|
||||
my $r = substr($in, $off+2, $l);
|
||||
$r = Encode::decode('UTF-8', $r) if($unicodeEncoding);
|
||||
return ($r, $off+2+$l);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -3862,8 +3862,12 @@ DoTrigger($$@)
|
||||
my $event = $events->[$i];
|
||||
my $t = (($ct && $ct->[$i]) ? $ct->[$i] : $tn);
|
||||
next if($re && !($dev =~ m/$re/ || "$dev:$event" =~ m/$re/));
|
||||
addToWritebuffer($dc,($inform{$c}{type} eq "timer" ? "$t " : "").
|
||||
"$hash->{TYPE} $dev $event\n");
|
||||
|
||||
my $txt = ($inform{$c}{type} eq "timer" ? "$t " : "").
|
||||
"$hash->{TYPE} $dev $event\n";
|
||||
my $enc = $dc->{encoding} && $dc->{encoding} eq "latin1" ? "Latin1":"UTF-8";
|
||||
$txt = Encode::encode($enc, $txt);
|
||||
addToWritebuffer($dc, $txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user