From 77e1b09aa2e8293c127d905743bae6fcd02ac963 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Tue, 17 May 2022 20:12:20 +0000
Subject: [PATCH] 00_MQTT2_SERVER/CLIENT: enhance the traffic display (Forum
#127223)
git-svn-id: https://svn.fhem.de/fhem/trunk@26055 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/00_MQTT2_CLIENT.pm | 3 +-
fhem/FHEM/00_MQTT2_SERVER.pm | 3 +-
fhem/FHEM/DevIo.pm | 7 +-
fhem/www/pgm2/console.js | 134 +++++++++++++++++++++++++++++------
4 files changed, 117 insertions(+), 30 deletions(-)
diff --git a/fhem/FHEM/00_MQTT2_CLIENT.pm b/fhem/FHEM/00_MQTT2_CLIENT.pm
index ef067c63c..9a284f273 100644
--- a/fhem/FHEM/00_MQTT2_CLIENT.pm
+++ b/fhem/FHEM/00_MQTT2_CLIENT.pm
@@ -746,8 +746,7 @@ MQTT2_CLIENT_feedTheList($$$)
delete($fl->{$fwid});
next;
}
- FW_AsyncOutput($cl, "",
- defined($cid) ? "RCVD: $tp $val
" : "SENT: $tp $val
");
+ FW_AsyncOutput($cl, "", toJSON([defined($cid)?"RCVD":"SENT", $tp,$val]));
}
delete($server->{".feedList"}) if(!keys %{$fl});
}
diff --git a/fhem/FHEM/00_MQTT2_SERVER.pm b/fhem/FHEM/00_MQTT2_SERVER.pm
index e14ca02b9..1a0ab9080 100644
--- a/fhem/FHEM/00_MQTT2_SERVER.pm
+++ b/fhem/FHEM/00_MQTT2_SERVER.pm
@@ -576,8 +576,7 @@ MQTT2_SERVER_doPublish($$$$;$)
delete($fl->{$fwid});
next;
}
- FW_AsyncOutput($cl, "",
- defined($cid) ? "RCVD: $tp $val
" : "SENT: $tp $val
");
+ FW_AsyncOutput($cl, "", toJSON([defined($cid)?$cid:"SENT", $tp, $val]));
}
delete($server->{".feedList"}) if(!keys %{$fl});
}
diff --git a/fhem/FHEM/DevIo.pm b/fhem/FHEM/DevIo.pm
index 76660cc33..d7bc388f1 100644
--- a/fhem/FHEM/DevIo.pm
+++ b/fhem/FHEM/DevIo.pm
@@ -360,9 +360,10 @@ DevIo_Expect($$$)
# - UNIX:(SEQPACKET|STREAM):filename => Open filename as a UNIX socket
# - FHEM:DEVIO:IoDev[:IoPort] => Cascade I/O over another FHEM Device
#
-# callback is only meaningful for TCP/IP (in which case a nonblocking connect
-# is executed) every cases. It will be called with $hash and a (potential)
-# error message. If $hash->{SSL} is set, SSL encryption is activated.
+# callback is only meaningful for TCP/IP, in which case a nonblocking connect
+# is executed. It will be called with $hash and a (potential) error message.
+# If # $hash->{SSL} is set, SSL encryption is activated.
+
sub
DevIo_OpenDev($$$;$)
{
diff --git a/fhem/www/pgm2/console.js b/fhem/www/pgm2/console.js
index 5c9a32041..fe0eb0ec0 100644
--- a/fhem/www/pgm2/console.js
+++ b/fhem/www/pgm2/console.js
@@ -23,6 +23,28 @@ cons_closeConn()
consConn = undefined;
}
+function
+consAppender(new_content)
+{
+ // Extract the FHEM-Log, to avoid escaping its formatting (Forum #104842)
+ var logContent = "";
+ var rTab = {'<':'<', '>':'>',' ':' ', '\n':'
' };
+ new_content = new_content.replace(
+ /(
'+JSON.stringify(js, undefined, 2)+''; + } + $(this).html(content); + } catch(e) { } + } + }); + } +} + function cons4dev(screenId, filter, feedFn, devName) { @@ -350,6 +399,7 @@ cons4dev(screenId, filter, feedFn, devName) consName = screenId+">div.console"; consFilter = filter; + consAppender = cons4devAppender; var opened; function @@ -359,7 +409,16 @@ cons4dev(screenId, filter, feedFn, devName) var cmd = FW_root+"?cmd="+encodeURIComponent("{"+feedFn+"('"+devName+"',"+ (opened ? 0 : 1)+")}")+"&XHR=1"; if(!opened) { - $(screenId).append(''); + $(screenId) + .append(` `); + $(screenId) + .append(`