IoT Platform provides the device simulator to simulate the connection between a physical device and IoT Platform. You can use simulated data to test the communication between the device and IoT Platform and identify problems.

Description

You can use the device simulator to debug the following features:

  • Send upstream data
    • Custom topics that are used to send and receive data
    • Property submission
    • Event submission
  • Send downstream commands
    • Custom topics
    • Property query and setting
    • Service calling

Limits

  • You can set a push policy. If you set the push policy multiple times, only the last settings take effect.
  • The minimum interval to push consecutive messages is 1 second.
  • The maximum duration to push consecutive messages is 3 hours.
  • The device simulation feature cannot be used to simulate devices that transmit data in custom formats.
  • If a physical device is online or disabled, you cannot use device simulation. After you leave the Device Simulation page, the device simulator is disabled.

Procedure

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Maintenance > Device Simulation.
  3. Select a product and then a device that you want to simulate. On the Device Simulation page, click Start Device Simulation.
  4. Select a feature and send data to debug the feature. The following table describes the features.
    Topic Category
    Feature type Procedure
    Custom topics that are used to send and receive data Use the device simulator to send an upstream message to a custom topic.
    1. Click the Upstream Debug tab and then the Topic Category tab.
    2. Select a custom topic that is used to send the message, 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.
    Property submission Use the device simulator to submit a property to IoT Platform.
    1. Click the Upstream Debug tab and then the Properties tab.
    2. Select a Thing Specification Language (TSL) module from the Module drop-down list.
    3. Select or enter a value in a property field. The value must match the data type and value range of the property.
    4. Push the data.

      Valid options:

      • Send Command: Immediately push the data.
      • Push Policy: Set a push policy. Valid values:
        • At Specific Time: The data is pushed only once at a specified time.
        • At Specific Interval: The data is pushed at a fixed interval during a specified period. The interval is measured in seconds.
    Event submission Use the device simulator to submit an event to IoT Platform.
    1. Click the Upstream Debug tab and then the Events tab.
    2. Select a Thing Specification Language (TSL) module from the Module drop-down list.
    3. Select an event and enter the event data in the JSON format, such as {"Power": "on"}.
    4. Push the data.

      Valid options:

      • Send Command: Immediately push the data.
      • Push Policy: Set a push policy. Valid values:
        • At Specific Time: The data is pushed only once at a specified time.
        • At Specific Interval: The data is pushed at a fixed interval during a specified period. The interval is measured in seconds.
    Custom topics to send downstream data Enable IoT Platform to send a downstream message to a custom topic.
    1. Click the Downstream Debug tab and then the Topic Category tab.
    2. Select a custom topic, enter payload data, and then set QoS to 0 or 1.
    3. Click Send Command.
    Property query and setting Enable IoT Platform to send a downstream command to set a property value and then retrieve the property value from the device simulator.
    1. Click the Downstream Debug tab and then the Property debugging tab.
    2. Select a Thing Specification Language (TSL) module from the Module drop-down list.
    3. Enter a value in a property field and click Debugging. Then, click Set. After the device simulator receives the command, it sets the property to the new value.
    4. On the right side of a property field, click Debugging. Then, click Get.

      The latest property value is displayed in the field. If the property value does not exist on the device simulator, no data is retrieved.

    Service calling
    1. Click the Downstream Debug tab and then the Invoke Service tab.
    2. Select a Thing Specification Language (TSL) module from the Module drop-down list.
    3. In the field, enter the input parameters of the service. Then, click Send Command.

      The input parameters must be in the JSON format. Example: {"Switch":0}.

Result

After data is pushed, you can view device logs in the Device log section on the right side of the page.

The following figure shows an example.

Device logs

Click View Cloud Logs. On the Cloud run log tab, you can view the related IoT Platform logs.

For more information, see IoT Platform logs.

Cloud run log