All Products
Search
Document Center

IoT Platform:Add devices to an MQTT gateway product

Last Updated:Aug 22, 2023

You must import the verification information about a device to a gateway product whose Authentication Type parameter is set to One-party Verification. This way, the information can be used to verify the device when you connect the device to IoT Platform. This topic describes how to import the verification information about devices.

Prerequisites

A gateway whose Authentication Type parameter is set to One-party Verification is created as a product in the IoT Platform console. For more information, see Create an MQTT gateway.

Background information

  • After you create a gateway whose Authentication Type parameter is set to Third-party Certification and use the gateway to connect a device to IoT Platform for the first time, IoT Platform automatically uses the return value of the deviceName parameter as the device name to create a device.

    You can use MQTT.fx to simulate a device and connect the device to IoT Platform by using a gateway to enable communication. For more information, see Use MQTT.fx to connect a device (Function Compute for device verification).

  • After you create a gateway whose Authentication Type parameter is set to One-party Verification, you must import the verification information about devices to add the devices to the gateway product in the IoT Platform console. The following section describes how to add devices.

Add multiple devices

  1. Log on to the IoT Platform console.

  2. On the Overview tab, click the Exclusive Enterprise Edition instance that you want to manage.

  3. In the left-side navigation pane, choose Devices > Products. Find the gateway that you created and click Manage Devices in the Actions column.

  4. On the Devices page, click Batch Add.

    批量添加
  5. In the Batch Add Devices dialog box, click Download. csv Template to download the template of device verification information.

    批量添加设备
  6. In the template file, enter the serial number (SN), Message Queuing Telemetry Transport (MQTT) username, and MQTT password of each device that you want to add, and save the file.

    Important
    • MQTT usernames and MQTT passwords are required. SNs are optional.

    • An MQTT username must be 4 to 32 characters in length, and can contain letters, digits, hyphens (-), underscores (_), at signs (@), periods (.), and colons (:). Each MQTT username must be unique in a product.

    • An MQTT password must be 1 to 32 characters in length, and can contain letters, digits, hyphens (-), underscores (_), at signs (@), periods (.), and colons (:).

    • Each template file can contain the information of up to 10,000 devices. Do not import information about duplicate devices.

    设备文件
  7. Go to the Batch Add Devices dialog box, click Upload File, upload the completed template file to the IoT Platform console, and then click OK.

    上传文件

    If a template file contains invalid information, an error is returned. Click Download Invalid Device Name List, view and change the invalid information, and then re-upload the template file.

    不合法输入

Related operations

API

Description

ImportDevice

Adds a device to an MQTT gateway product.

BatchImportDevice

Adds multiple devices to an MQTT gateway product at the same time.

BatchCheckImportDevice

Verifies multiple devices that are added at the same time.

QueryImportedDeviceByApplyId

Queries multiple devices that are added at the same time by application ID.

Result

After the device verification information is imported, IoT Platform creates devices and uses the uploaded MQTT usernames as DeviceNames. The Devices page displays the information about the devices that are created. 设备列表

What to do next

After the devices are added to the gateway product, you must update the endpoint of each device.

  • If an endpoint is specified for a device, you must configure a CNAME record to change the endpoint to the gateway URL. For information about how to resolve domain names, see Alibaba Cloud DNS.

  • If no endpoint is specified for a device, you must specify the gateway URL as the endpoint of the device. For more information, see Connect a device to IoT Platform over MQTT.

For information about how to obtain a gateway URL, see View the gateway URL of a gateway.

For information about how to connect a device to IoT Platform by using a gateway, see Messaging.

You can use MQTT.fx to simulate a device and connect the device to IoT Platform by using a gateway to establish communication. For more information, see Use MQTT.fx to connect a device (one-party verification).