简体   繁体   English

使用Arduino和Mosquitto的MQTT实现

[英]MQTT implementation using Arduino and Mosquitto

I downloaded the Mosquitto broker and trying to implement MQTT protocol using Arduino UNO + Ethernet shield as client and Mosquitto on a desktop. 我下载了Mosquitto代理,并尝试使用Arduino UNO +以太网屏蔽作为客户端并在桌面上使用Mosquitto来实现MQTT协议。 As soon as I run the .exe file of the broker named "mosquitto", a Command line prompt pops up, and stays just like that with no lines! 一旦运行名为“ mosquitto”的代理的.exe文件,就会弹出一个命令行提示符,并且保持不变,没有任何行! Does this happen as such or should it be displaying some message? 是这样发生还是应该显示一些消息?

Also, the pub and sub files of the Mosquitto (.exe) when run, open a command propmpt and immediately close! 另外,运行时Mosquitto(.exe)的发布和子文件,请打开命令提示符,然后立即关闭! They don't stay stagnant at all! 他们根本不会停滞不前! I am using Arduino UNO with Ethernet shield to publish data but then the broker is what creates the above mentioned problem. 我正在使用带有以太网屏蔽的Arduino UNO来发布数据,但随后的代理正是造成上述问题的原因。

The mosquitto broker and the mosquitto_pub & mosquitto_sub commands are not GUI applications. mosquitto代理以及mosquitto_pub和mosquitto_sub命令不是GUI应用程序。

The mosquitto broker command on windows when run by double clicking on it will just open a terminal and wait for connections, this is working properly. 在Windows上通过双击运行mosquitto broker命令时,将打开一个终端并等待连接,此操作正常。

The mosquitto_pub and mosquitto_sub commands need to be run from a command prompt, not by just clicking on them. mosquitto_pub和mosquitto_sub命令需要从命令提示符处运行,而不仅仅是单击它们。 This is because they require command line arguments in order to do anything useful. 这是因为它们需要命令行参数才能执行任何有用的操作。

Basically to publish something with mosquitto_pub you need to supply a message to send 基本上,要使用mosquitto_pub发布内容,您需要提供一条消息以发送

mosquitto_pub -t some/topic -m "message payload"

To subsribe you need to supply the topic to listen on: 要订阅,您需要提供主题以进行聆听:

mosquitto_sub -v -t some/topic 

Please read the following answer for more details: How to test the `Mosquitto` server? 请阅读以下答案以获取更多详细信息: 如何测试Mosquitto服务器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM