简体   繁体   English

AWS IoT,如何从我的 API 端点获取 UUID

[英]AWS IoT, how to get the UUID from my API endpoint

Our IoT devices collect sample data and the sample data stays on the device indefinitely.我们的物联网设备收集样本数据,样本数据无限期地保留在设备上。 Also, our IoT devices don't collect lots of samples;此外,我们的物联网设备不会收集大量样本; at most, a dozen samples per week.最多,每周十几个样品。

I'm using AWS IoT and I've successfully connected my device to IoT Core and I can publish/subscribe messages via the MQTT protocol.我正在使用 AWS IoT,并且已成功将我的设备连接到 IoT Core,并且我可以通过 MQTT 协议发布/订阅消息。 From there, I have a rule that forwards the payload to my HTTP endpoint.从那里,我有一个将有效负载转发到我的 HTTP 端点的规则。

Prior to using AWS IoT, I did a proof of concept by sending a json payload from my device to my http endpoint.在使用 AWS IoT 之前,我通过将 json 负载从我的设备发送到我的 http 端点来进行概念验证。 This action inserted a new record into my RDS database and returned a UUID to the device.此操作在我的 RDS 数据库中插入了一条新记录,并向设备返回了一个 UUID。 The device then stored the UUID with the corresponding sample.然后设备将 UUID 与相应的样本一起存储。 In this way, we're able to matched the sample on our device with the one in our cloud service.通过这种方式,我们能够将我们设备上的样本与我们的云服务中的样本进行匹配。

However, now that I've transitioned to using MQTT, I'm realizing that I'm unable to get a UUID back from my API call.但是,现在我已经过渡到使用 MQTT,我意识到我无法从 API 调用中取回 UUID。 The only response I get from MQTT is the original message that I send.我从 MQTT 得到的唯一响应是我发送的原始消息。 I supposed I at least know that it was successful but what I'd rather like to know is the UUID of the sample record inserted into my database.我想我至少知道它是成功的,但我更想知道的是插入到我的数据库中的示例记录的 UUID。 Does anyone have any suggestions on how to do this?有人对如何执行此操作有任何建议吗? If this is not a typical pattern, please explain to me an alternative approach.如果这不是典型模式,请向我解释另一种方法。

MQTT message data flows are uni-directional. MQTT 消息数据流是单向的。 To return the UUID that the server generates requires the device to subscribe to a topic that the server publishes the UUID to.要返回服务器生成的 UUID,设备需要订阅服务器将 UUID 发布到的主题。

An alternate approach is have the client create a UUID and publish this along with the sample in the original MQTT message.另一种方法是让客户端创建一个 UUID 并将其与原始 MQTT 消息中的示例一起发布。 The server then persists this UUID with the sample in RDS.然后,服务器将此 UUID 与 RDS 中的示例保持一致。

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

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