Subscribing to Device Measurement Messages
In some cases, you want to get single or multi device measurement messages.
For example, if you want to analyze the device measurements in real time, or you want to create a screen that shows the latest measurements from a list of 20 selected devices.
In both cases, you need to subscribe to MQTT measurement topics and act upon the messages you receive.
BioT allows you to so by following these steps:
- Get temporary AWS credentials
- Connect to AWS MQTT broker
- Subscribe to an MQTT topic
Get temporary AWS credentials
Make the following API call:
GET https://your-biot-domain.com/device/v2/credentials/organization
You will get the following response:
{
"endpoint": "string",
"credentials": {
"accessKeyId": "string",
"secretAccessKey": "string",
"sessionToken": "string",
"expiration": "2022-09-06T07:22:56.106Z"
},
"topic": "string"
}
Connect to AWS MQTT broker
Using the credentials acquired in step 1 connect to the AWS MQTT broker.
BioT recommends using the official AWS IoT SDK for this purpose.
Subscribe to an MQTT topic
In step 1 the topic
is a topic that will be formatted:
'[ownerOrganizationId]/+/+
The following table describes the topic structure and how it can be modified:
Parameter | Description |
---|---|
ownerOrganizationId | The unique organization ID. |
First | The first |
Second | The second |
For example, the topic d5399edb-cc47-4485-b3c8-4bcede9538b2/myDevice/+
Will listen to all type of events that myDevice
produces under the organization with IDd5399edb-cc47-4485-b3c8-4bcede9538b2
Updated 22 days ago