简体   繁体   中英

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. From there, I have a rule that forwards the payload to my HTTP endpoint.

Prior to using AWS IoT, I did a proof of concept by sending a json payload from my device to my http endpoint. This action inserted a new record into my RDS database and returned a UUID to the device. The device then stored the UUID with the corresponding sample. 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. The only response I get from MQTT is the original message that I send. 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. 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. To return the UUID that the server generates requires the device to subscribe to a topic that the server publishes the UUID to.

An alternate approach is have the client create a UUID and publish this along with the sample in the original MQTT message. The server then persists this UUID with the sample in RDS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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