MQTT Management

SmartWorks IoT allows you to enhance your Thing Management experience by being compatible with both HTTP and MQTT protocols. They are not only compatible separately but are also synchronized so that both protocols can be used at the same time, adding flexibility and resourcefulness to your Things. This means that any action developed through HTTP protocols can be received, sent and updated through MQTT as well. The only action that MQTT cannot carry out is the deletion of a Thing or its elements. To delete a Thing (or even only one of its properties, events or actions) you must use the API.

Focusing on MQTT protocols, to engage activities between your Things through MQTT, you must first enable the topic (of Data or Things) that you want to control using MQTT by assigning it a username and password. In order to set these, the following HTTP POST request is necessary (user-manual is the account-id used for all the examples):
POST  user-manual/mqtt
Payload:
{
 "resources": [{
  "entity": "things",
  "id": ["ULIDs"]
  }],
  "user": "",
  "password": ""
  }

The field resources identifies the platform resources where you want to enable the default topics. Every topic of the resources field in the request will have the same user and password. If the fields user and password are left empty, they will be automatically generated. The automatic password will be returned, but not persisted.

Once the POST request has been triggered, the return will be:
201 created
{
  "ulid": "<ulid>",
  "username": "049ufq03hf0",
  "password": "T$Z7cf!9Evix",
  "topics": [
      {
        "pattern_pub": "set/MyAccount001/things/AwesomeDevice/properties/#",
        "pattern_sub": "status/MyAccount001/things/AwesomeDevice/properties/#"
      },
      {
        "pattern_pub": "set/MyAccount001/things/AwesomeDevice/actions/#",
        "pattern_sub": "status/MyAccount001/things/AwesomeDevice/actions/#"
      },
      {
        "pattern_pub": "set/MyAccount001/things/AwesomeDevice/events/#",
        "pattern_sub": "status/MyAccount001/things/AwesomeDevice/events/#"
      }
    ]
}

Once the authentication process has been complete, you can start working on your topics via MQTT. However, when working with MQTT it is crucial to understand the different behaviors between the platform resources. Each of these types of topics have different capabilities and serve different purposes.