Commanding Feature – Samples for Publishing MQTT commands to agents¶
Commanding Feature is a service that provides the APIs to manage delivery jobs to send commands to MQTT agents for execution. The examples below exemplify how to use the provided endpoints:
Prerequisites¶
- Onboard a
core.mcmqtt
agent. For more information, refer to Onboarding MindConnect MQTT Agent. - Agent must subscribe to a corresponding MQTT topic. For instructions to configure MQTT agents, refer Commanding Feature Async API specifications.
Creating a delivery job¶
The Commanding feature provides functionality for sending MQTT command to a list of agents for execution.
The following validations are performed when a delivery job is created:
- The provided list of agents must be valid.
- Maximum number of agents can be 20 in a delivery job.
- Data size is restricted to 4KB.
A command is sent using the following endpoint:
POST/deliveryJobs
Sample Request:
{
"name": "firmware update",
"clientIds": [
"mytenant_201541ad38a4495a96e2021c762b647f"
],
"data": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
},
"createdBy": "user@mailId.com"
}
Sample Response:
{
"id": "21349765fe45652c8e126814c283a114",
"name": "firmware update",
"clientIds": [
"mytenant_201541ad38a4495a96e2021c762b647f"
],
"tenantId": "mytenant",
"status": "EXECUTING",
"data": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
},
"createdAt": "2011-08-12T20:17:46.384Z",
"createdBy": "user@mailId.com"
}
The ID generated tenantId
is referenced further to get, delete a delivery job and get all commands for a given delivery job.
For more information, refer Commanding Feature Sync API specifications.
Listing all delivery jobs¶
Use the following endpoint to list all delivery Jobs:
GET/deliveryJobs
Sample Response:
{
"_embedded": {
"deliveryJobs": [
{
"id": "21349765fe45652c8e126814c283a114",
"name": "firmware update",
"status": "EXECUTING",
"createdAt": "2011-08-12T20:17:46.384Z"
}
]
},
"page": {
"size": 0,
"totalElements": 0,
"totalPages": 0,
"number": 0
},
"_links": {
"self": {
"href": "string"
},
"first": {
"href": "string"
},
"prev": {
"href": "string"
},
"next": {
"href": "string"
},
"last": {
"href": "string"
}
}
}
For more information, refer Commanding Feature Sync API specifications.
Managing delivery jobs¶
Here, tenantId
, the id generated while Creating a delivery job is used.
-
Use the following endpoint to get a delivery job:
GET/deliveryJobs/{id}
-
Use the following endpoint to delete a delivery job:
DELETE/deliveryJobs/{id}
-
Use the following endpoint to get the all the commands for a given delivery job:
GET/deliveryJobs/{id}/commands
-
Use the following endpoint to get the command associated with a delivery job by command id:
GET/deliveryJobs/{id}/commands/{commandId}
For more information, refer Commanding Feature Sync API specifications.
Except where otherwise noted, content on this site is licensed under the Development License Agreement.