2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 16:05:19 +00:00

00_MQTT2_CLIENT.pm/SERVER.pm: enable traffic display of binary data

git-svn-id: https://svn.fhem.de/fhem/trunk@27654 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2023-06-04 15:20:06 +00:00
parent 3a3b9b1034
commit b8e053a68f
2 changed files with 10 additions and 3 deletions

View File

@ -799,6 +799,8 @@ MQTT2_CLIENT_feedTheList($$$;$)
my $fl = $server->{".feedList"};
if($fl) {
my $now = gettimeofday();
my $informVal = $val; # Convert it to text for websocket
$informVal =~ s/([^ -~])/"(".ord($1).")"/ge;
my $ts = sprintf("%s.%03d", FmtTime($now), 1000*($now-int($now)));
foreach my $fwid (keys %{$fl}) {
my $cl = $FW_id2inform{$fwid};
@ -806,7 +808,8 @@ MQTT2_CLIENT_feedTheList($$$;$)
delete($fl->{$fwid});
next;
}
FW_AsyncOutput($cl,"",toJSON([$ts,defined($cid)?"RCVD":"SENT",$tp,$val]));
FW_AsyncOutput($cl, "",
toJSON([$ts, defined($cid)?"RCVD":"SENT", $tp, $informVal]));
}
delete($server->{".feedList"}) if(!keys %{$fl});
}

View File

@ -450,7 +450,8 @@ MQTT2_SERVER_Read($@)
}
$val = (length($pl)>$off ? substr($pl, $off) : "");
if($unicodeEncoding) {
if(!$shash->{binaryTopicRegexp} || $tp !~ m/^$shash->{binaryTopicRegexp}$/) {
if(!$shash->{binaryTopicRegexp} ||
$tp !~ m/^$shash->{binaryTopicRegexp}$/) {
$val = Encode::decode('UTF-8', $val);
}
}
@ -585,13 +586,16 @@ MQTT2_SERVER_doPublish($$$$;$)
my $fl = $server->{".feedList"};
if($fl) {
my $ts = sprintf("%s.%03d", FmtTime($now), 1000*($now-int($now)));
my $informVal = $val; # Convert it to text for websocket
$informVal =~ s/([^ -~])/"(".ord($1).")"/ge;
foreach my $fwid (keys %{$fl}) {
my $cl = $FW_id2inform{$fwid};
if(!$cl || !$cl->{inform}{filter} || $cl->{inform}{filter} ne '^$') {
delete($fl->{$fwid});
next;
}
FW_AsyncOutput($cl, "", toJSON([$ts,defined($cid)?$cid:"SENT",$tp,$val]));
FW_AsyncOutput($cl, "",
toJSON([$ts, defined($cid)?$cid:"SENT", $tp, $informVal]));
}
delete($server->{".feedList"}) if(!keys %{$fl});
}