简体   繁体   English

AWS IoT-将消息发送到车队的特定设备

[英]AWS IoT - Sending a message to a specific device of the fleet

I'm trying to play with AWS IoT to communicate with multiple identical devices. 我正在尝试使用AWS IoT与多个相同的设备进行通信。

So far, so good, all my devices are connected to it, and the only difference between them could be a single device ID (like a mac address or a serial number) 到目前为止,到目前为止,我所有的设备都已连接到其上,它们之间的唯一区别可能是单个设备ID(例如mac地址或序列号)

Now I'd like to send a message to a single specific device using its device ID and I don't know if there is a good way to do that? 现在,我想使用其设备ID将消息发送到单个特定设备,但我不知道是否有很好的方法?

I could make each device to subscribe to a topic like /<DEVICE_ID> , however it doesn't seem like a good practice especially if I have thousands of devices. 我可以让每个设备都订阅类似/<DEVICE_ID>的主题,但是这似乎不是一个好习惯,尤其是当我有成千上万个设备时。

Plus, AWS discourages it as stated in the AWS IoT documentation : 此外,AWS不鼓励其如AWS IoT文档中所述

Note 注意

We do not recommend using personally identifiable information in your topics. 我们不建议在主题中使用个人身份信息。

Is there a good way to handle this use case? 是否有处理此用例的好方法? Or is AWS IoT only useful to manage multiple devices at once? 还是AWS IoT仅可用于一次管理多个设备?

Here is the best practice for creating an MQTT topic. 这是创建MQTT主题的最佳实践。

https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/ https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices/

Talking about your specific case 谈论你的具体情况

  • Each device needs to have a unique identity to send a command to a particular device. 每个设备都需要具有唯一身份,才能将命令发送到特定设备。 In this case, you need to have device_id into your MQTT topic. 在这种情况下,您需要在MQTT主题中加入device_id
  • You can use the following pattern to send a message for a destination device 您可以使用以下模式为目标设备发送消息
  • protocol_prefix / type_of_message / dest_id / message_id protocol_prefix /消息类型/ dest_id / message_id
  • hexaiot/controldevice/d12345/x123 hexaiot / controldevice / d12345 / X123
  • Use wild card character at the time of device subscription to subscribe to the topic 设备订阅时使用通配符来订阅主题

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

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