MQTT | Push data to Device

Prerequisites

  1. Have MQTT FX software. If you don't have it, please go to the following link MQTT FX.

Steps

  1. Login to your Antares account via Antares Console https://console.antares.id

  2. Save Access Keys, you can view Access Keys on the API Keys page

  1. Create an App, if you already have one, ignore it to proceed to the next process.

  1. Create Device, if you already have one, ignore it to proceed to the next process.

  1. Open the MQTT FX software. The user interface is shown in the following figure.

  1. Firstly, you need to configure so that you can connect with our MQTT Broker. The configuration is shown below.

  1. When you successfully connect, a green icon will appear on the top right.

  2. Click Subscribe, then run subscribe a topic by following this format: /oneM2M/resp/antares-cse/your-access-key/choose-a-serialization-format The choose-a-serialisation-format parameter can have 2 values:xml untuk format XML

    • json for JSON format

    In this step, it means that you will get a message/notification when a change happens to your account. In this tutorial, we use MQTT FX tools to subscribe, but in the real case scenario, it will be the device that subscribes to the topic.

  3. This step, we will emulate requests coming from mobile apps. It also uses MQTT FX as a tool. Start publishing to the following topics:

    /oneM2M/req/your-access-key/antares-cse/choose-a-serialization-format The choose-a-serialization-format parameter can have 2 values:

    • xml for XML format

    • json for JSON format

    Example: Topic: /oneM2M/req/your-access-key/antares-cse/json Contents

      {
      "m2m:rqp": {
        "fr": "your-access-key",
        "to": "/antares-cse/antares-id/application-name/device-name",
        "op": 1,
        "rqi": 123456,
        "pc": {
          "m2m:cin": {
            "cnf": "message",
            "con": "on"
          }
        },
        "ty": 4
      }
    }

All data in "con" is defined by yourself. You can create your own format data.

Congratulations! You have just received your first request using the MQTT API.

Last updated