简体   繁体   English

MQTT写入设备

[英]MQTT write to device

At the moment we're looking at mqtt for connecting our controls to the internet. 目前,我们正在寻找将控件连接到Internet的mqtt。 In our application a thermostat would be the server/sender, a phone app could be the client. 在我们的应用程序中,恒温器是服务器/发送器,电话应用程序是客户端。

As far as I see the protocol is suited for sending measured temperatures to the connected clients. 据我所知,该协议适用于向连接的客户端发送测得的温度。 But I see no way to write back a setpoint. 但是我看不到任何回写设定值的方法。 It could be done over a second connection were the thermostat subscribes to the phone app. 如果恒温器订阅了电话应用程序,则可以通过第二个连接来完成。 Can it be done in another way? 可以用其他方式完成吗?

MQTT is a Publish/Subscribe protocol, there is no concept of a by directional connection between a publisher and a subscriber, because this could be a 1 to 1, 1 to many or many to many relationship for a given topic. MQTT是发布/订阅协议,在发布者和订阅者之间没有按方向连接的概念,因为对于给定主题,这可能是一对一,一对多或多对多的关系。

There is nothing to stop a publisher also being a subscriber to receive commands, many IoT frameworks work this way (for example IBM IoT Foundation). 没有什么可以阻止发布者同时也是订阅者来接收命令的,许多IoT框架都以这种方式工作(例如IBM IoT Foundation)。

Your thermostat can publish it temp on thermostat/{id}/temp and listen for incoming set values on thermostat/{id}/set 您的恒温器可以在恒温器/ {id} / temp上发布温度,并在恒温器/ {id} / set上监听传入的设置值

There is no need for multiple connections publishes and subscriptions can both happen via one connection to a broker 无需发布多个连接,订阅都可以通过与经纪人的一个连接进行

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

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