我可以向通过MQTT WebSocket连接的一组Azure IoT中心设备发送消息吗? [英] Can I send a message to a group of Azure IoT Hub Devices connected via MQTT WebSocket?

查看:135
本文介绍了我可以向通过MQTT WebSocket连接的一组Azure IoT中心设备发送消息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:将消息发送到通过MQTT WebSocket连接的一组Azure IoT中心设备.

Goal: Send messages to a group of Azure IoT Hub Devices that are connected via MQTT WebSocket.

初步构想:让一组IoT中心设备(组X)订阅主题为X的消息.

Initial Idea: Have a group of IoT Hub Devices (group X) subscribe to messages with topic X.

问题:

与IoT中心进行通信使用MQTT协议文档,我看不到将设备订阅其他主题的方法.我只看到预订设备特定端点 devices/{device_id}/messages/devicebound/#的示例.

On the Communicate with your IoT hub using the MQTT protocol docs, I don't see a way to subscribe a device to additional topics. I only see examples of a subscription to a device specific endpoint devices/{device_id}/messages/devicebound/#.

页面上继续说:"IoT中心不是通用的发布订阅消息代理,它仅支持记录的主题名称和主题过滤器."我认为这些主题是

The page goes on to say "IoT Hub is not a general purpose pub-sub messaging broker, it only supports the documented topic names and topic filters." I think those topics are

  • devices/{device_id}/messages/devicebound/
  • devices/{device_id}/messages/devicebound/#
  • devices/{device_id}/messages/devicebound/
  • devices/{device_id}/messages/devicebound/#

我的结论:我不能有一组IoT中心设备(X组)订阅主题为X的消息.

My Conclusion: I can't have a group of IoT Hub Devices (group X) subscribe to messages with topic X.

问题:

  1. 我的结论正确吗?
  2. 如果我的结论是正确的,还有其他方法可以将消息发送到通过MQTT WebSocket连接的一组Azure IoT集线器设备吗?

推荐答案

您的结论是正确的. Azure IoT中心本身不是MQTT代理. 如果要将消息发送到连接到Azure IoT中心的一组设备(与它们所连接的协议无关),则需要查看

Your conclusion is correct. Azure IoT Hub is not an MQTT broker per se. If you want to send messages to a group of devices connected to Azure IoT Hub (independently of the protocol they are connected with), you need to look into one of the Cloud 2 Device features of IoT Hub. Depending on your scenario you can use one of the following: Cloud 2 Device messages, Twins or Methods. IoT Hub exposes APIs on the back-end side (easily used with the Service Client SDKs) allowing to use any of those.

C2D消息用于将原始数据发送到设备,这意味着您在云和设备之间实现了自己的协议". C2D消息在云中也保持不变,因为如果未连接设备,则IoT中心将保留它们(在设置中定义的特定时间).

C2D messages are used to send raw data to devices, meaning you implement your own "protocol" between cloud and device. C2D messages are also persistent in the Cloud as IoT Hub will retain them (for a certain time defined in settings) if the device is not connected.

Device Twins允许将设备的配置与Cloud同步,并允许在设备上进行批处理操作(某些情况下您需要仔细研究).

Device Twins allows to synchronize a configuration of a device with the Cloud and allows for batch operations on devices (certainly one you want to look closer into).

设备直接方法允许从云中调用在设备上运行的函数,就像Twins支持批处理操作一样.

Device Direct Methods allows to call a function running on a device from the cloud and like Twins supports batch operations.

这篇关于我可以向通过MQTT WebSocket连接的一组Azure IoT中心设备发送消息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆