Updated on 2022-02-24 GMT+08:00

Device Registration

Overview

The NA server calls the API for registering a directly connected device to add devices to the IoT platform. For details about the API, see the API reference document.

This topic describes how to call the API for registering a directly connected device based on the Java code sample of the API.

Procedure

  1. In the Eclipse, choose src > com.huawei.service.deviceManagement > RegisterDirectConnectedDevice.java, and change the values of verifyCode, nodeId, timeout, manufacturerId, manufacturerName, deviceType, model, and protocolType.

    Parameters are described as follows:

    • The values of verifyCode and nodeId must be the same as the IMEI or MAC address of a physical device. If a device simulator is used, the value of verifyCode can be a combination of digits, letters, and special characters. The value can be user-defined but must be unique.
    • The unit of timeout is second. The values of timeout are as follows:
      • 0: indicates that the device never expires.
      • > 0: indicates that the device must be made online within the specified period. Otherwise, the IoT platform removes the device immediately after the period expires. If timeout is not specified, the default interval (180 seconds) is used.
      • After a device is bound, timeout becomes invalid and the device will never expire.
    • The values of manufacturerId, manufacturerName, deviceType, model, and protocolType must be the same as those in the profile file.

  2. Right-click RegisterDirectConnectedDevice.java and choose Run As > Java Application.
  3. View the response log on the console. If deviceId is obtained, the registration is successful.

    Developers can check whether the newly registered device is displayed on the Product > Device Management of the Developer Center. In this case, the registered device has only the device ID information.