From 08aec277e6cf0905a1a855123ff7f4390b6a7e46 Mon Sep 17 00:00:00 2001 From: liuyunhu <3286117488@qq.com> Date: Tue, 2 Apr 2024 14:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=8E=E8=99=8E=E8=99=8E=E8=99=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/couplet/online/utils/MqttMonitor.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index b3b85b3..cb2b57e 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -86,11 +86,23 @@ public class MqttMonitor { @Override public void messageArrived(String topic, MqttMessage mqttMessage) { - log.info("消息已送达"); - log.info("接收消息主题:{}",topic); - log.info("接收消息qos:{}", mqttMessage.getQos()); +// log.info("消息已送达"); +// log.info("接收消息主题:{}",topic); +// log.info("接收消息qos:{}", mqttMessage.getQos()); + + //接收到的原始报文 + String message = new String(mqttMessage.getPayload()); + + log.info("接收消息原始内容:{}", message); + + //去除空格 得到16进制字符串 + String replaced = message.replaceAll(" ", ""); + log.info("接收消息剪切后内容:{}", replaced); + + + + - log.info("接收消息内容:{}", new String(mqttMessage.getPayload())); } @Override