如何在订阅时让 mosquitto_sub 打印主题和消息 #
How to make mosquitto_sub print topic and message when subscribed to #
以下命令显示发布到与正则表达式匹配但不是确切主题本身的主题的所有消息。
mosquitto_sub -h localhost -u user -P pass -t 'devices/#'
{"value":"50"}
{"value":"45"}
例如上面的 json 消息被发布到主题 devices/1234/transducer/46364/ 但我想不出任何方法来打印主题以及使用 mosquitto_sub.
使用-v
选项
mosquitto_sub -h localhost -u user -P pass -v -t 'devices/#'
来自手册页:
-v, --verbose
Print received messages verbosely. With this argument, messages
will be printed as "topic payload". When this argument is not
given, the messages are printed as "payload".
以下命令显示发布到与正则表达式匹配但不是确切主题本身的主题的所有消息。
mosquitto_sub -h localhost -u user -P pass -t 'devices/#'
{"value":"50"}
{"value":"45"}
例如上面的 json 消息被发布到主题 devices/1234/transducer/46364/ 但我想不出任何方法来打印主题以及使用 mosquitto_sub.
使用-v
选项
mosquitto_sub -h localhost -u user -P pass -v -t 'devices/#'
来自手册页:
-v, --verbose
Print received messages verbosely. With this argument, messages
will be printed as "topic payload". When this argument is not
given, the messages are printed as "payload".