IoT Platform allows you to simulate devices to facilitate IoT application development and testing.

Background information

You can implement an IoT Platform device by using the following process: A device is developed, the device sends data to IoT Platform, IoT Platform receives data from the device, and then an application is developed in the IoT Platform console. This development process is time-consuming.

IoT Platform provides the device simulation feature that allows you to simulate a device and the connection between the device and IoT Platform. You can use this feature for debugging in the following scenarios:

  • Debug the topics and procedures in the upstream:
    • Custom topics, including message reporting and message subscription
    • The procedure to report properties
    • The procedure to report events
  • Debug the following topics and procedures in the downstream:
    • Custom topics
    • The procedures that are related to properties, including the procedures that are used to retrieve and set property values
    • The procedure to invoke services

Limits

  • The device simulation feature cannot be used to simulate devices that adopt pass-through transmission or devices that transmit data in a custom format.
  • Device simulation cannot be started if the selected physical device is online or disabled. After you leave the device simulation page, the simulated device becomes offline.

Procedure

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Maintenance > Device Simulation.
  3. Select a device for simulation.
  4. Click Start Device Simulation.
  5. Push simulated data.
    Custom upstream topics
    Scenario Procedure
    Debug a custom upstream topic Enable a simulated device to use a custom topic to send IoT Platform a message.
    1. Choose Upstream Debug > Custom Topics.
    2. Select a topic that is used to report messages, enter payload data, and then set QoS to 0 or 1. Click Message Reporting.
    3. Select a topic that is used for message subscription. Click Subscribe.
    Report property values Enable a simulated device to report the property values to IoT Platform.
    1. Choose Upstream Debug > Properties.
    2. Select or enter a value in a property field. The value must match the data type and value range of the property.
    3. Click Send command.
    Report events Enable a simulated device to report an event to IoT Platform.
    1. Choose Upstream Debug > Events.
    2. Select a feature and enter the event data in the JSON format, for example, {"Power": "on"}.
    3. Click Send Command.
    Debug a custom downstream topic Enable IoT Platform to use a custom topic to send a simulated device a message.
    1. Choose Downstream Debug > Custom Topics.
    2. Select a custom topic, enter payload data, and then set QoS to 0 or 1.
    3. Click Send Command.
    Set and retrieve a property value Enable IoT Platform to send a simulated device a command to set a property value and enable IoT Platform to retrieve a property value.
    1. Choose Downstream Debug > Property debugging.
    2. Select a feature and select Set from the Method drop-down list.

      The syntax of the property data is displayed in the field, for example, {"Temperature":0}. Then, modify the value of the property. Click Send Command.

      After the simulated device receives the command, it sets the property to the new value.

    3. Select a feature and select Get from the Method drop-down list.

      Click Send Command.

      After the command is sent and a response is received, the latest value of the property is displayed in the text box. If the data of the property is unavailable on the simulated device, a pair of braces {} is displayed.

    Invoke a service Enable IoT Platform to send a command to a simulated device to set a property to a specified value. The simulated device updates and reports the value to IoT Platform. If the simulated device is offline when IoT Platform sends the command, the simulated device will obtain, update, and report the specified property value to IoT Platform after going online.
    1. Choose Downstream Debug > Invoke Service.
    2. Select a feature and enter the service input parameters in the JSON format, for example, {"Switch":0}.
    3. Click Send Command.

Result

After data is pushed, you can view device logs in the Device Logs section on the right side of the page. Click View Cloud Logs. On the Cloud run log tab, you can view the related IoT Platform logs.