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

Command Delivery

Overview

The NA server calls the device command creation API or device service calling API of the IoT platform to deliver control instructions to devices. For details about the APIs, see the API reference document.
  • When the access protocol at the application layer is LWM2M, the Creating Device Commands API is called to deliver commands.
  • When the access protocol at the application layer is MQTT, the Calling Device Services API is called to deliver commands.

This topic describes how to deliver commands with the Calling Device Services API and the Java code sample of the API.

Procedure

  1. In the Eclipse, choose src > com.huawei.service.commandDelivery > CreateDeviceCommand.java, and change the values of deviceId, serviceId, method, and paras.

    Parameters are described as follows:

    • The value of deviceId is obtained when a device is registered.
    • The values of serviceId, method, and paras are the same as those defined in the profile file.

  2. Right-click CreateDeviceCommand.java and choose Run As > Java Application.
  3. View the command delivery log on the console. If the 201 Created response is received, the command is delivered to the IoT platform.

    If the application test function of the Developer Center is used to simulate device access and data reporting, developers can select the virtual device created in Device Access to the IoT Platform to view the received commands by choosing Application > Application Test.

    After the NA server delivers a command, view the received command (for example, a hexadecimal code stream) in Device Simulator and view processing logs of the IoT platform in Message Tracking.