IoT Platform provides virtual devices for application development and debugging. You can use virtual devices to debug property reporting, event reporting, property configurations, and service calls. Devices that use custom data formats can also be supported.

Background information

You can implement an IoT Platform device by using the following process: After you develop a device, the device can connect with and report data to IoT Platform. Then, you can develop applications that are used on IoT Platform. However, this process is time-consuming.

To simplify the implementation process, Alibaba Cloud IoT Platform provides virtual devices. Virtual devices simulate the connections between physical devices and IoT Platform, report properties and events to IoT Platform, and receive commands from IoT Platform. You can use these commands to configure properties and call services. Then, you can develop and debug applications based on the virtual devices.

When you use virtual devices in the IoT Platform console, take note of the following limits:

  • The minimum interval for pushing consecutive messages is 1 second.
  • You can push a maximum of 1,000 consecutive messages.
  • You can click Push 100 times per day to push debugging information.
  • If a device uses custom data format, the Base64-encoded string of the binary data cannot exceed 4,096 characters.
  • A virtual device cannot be started if the physical device is online or disabled. After a physical device goes online, the virtual device that corresponds automatically goes offline.

Procedure

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Maintenance > Online Debug.
  3. On the Online Debug page, select the device that you want to debug.

    After you select the device, the debugging page is displayed.

  4. Click the Debug Virtual Device tab, and then click Start Virtual Device.
  5. Send a debug command.
    Debug virtual devices
    Scenario Procedure
    Report properties Use the virtual device to report property values to IoT Platform.
    1. Click Properties.
    2. Enter a value in a property field.

      The value must match the data type and value range of the property. You can also use the random() function to generate a random value.

    3. Push the data.

      You can select one of the following push methods:

      • Push: Immediately push the data.
      • Push Policy: Set a push policy. Valid values:
        • At Specific Time: Push data at a specified time.
        • At Specific Interval: Push data at a fixed interval during a specified period. The interval is measured in seconds.
    Report events Use the virtual device to report events to IoT Platform.
    1. Click Events.
    2. Enter a value in the event field.

      The value must match the data type and value range of the event. You can also use the random() function to generate a random value.

    3. Push the data.

      You can select one of the following push methods:

      • Push: Immediately push the data.
      • Push Policy: Set a push policy. Valid values:
        • At Specific Time: Push data at a specified time.
        • At Specific Interval: Push data at a fixed interval during a specified period. The interval is measured in seconds.
    Set properties Set the properties of a physical device from the cloud. After the device receives the command, the device sets its properties and reports the property values to IoT Platform.
    1. Click Property Debugging.
    2. From the Debug Feature list, select the property to debug and set the method to Set.

      The format for the property data is automatically displayed in the text box, for example, {"Temperature":0}.

    3. Set a value for the property and click Send Command.
    Get properties Obtain the property values of the device.
    1. Click Property Debugging.
    2. From the Debug Feature list, select the property to debug and set the method to Get.
    3. Click Send Command.
      Note When you try to obtain the property of the device, you do not need to enter data in the text box.

    After you dispatch the command, the text box automatically shows the latest data of the property. If the device does not have a value for the property, the data is empty.

    Call service
    1. Click Service Calls.
    2. From the Debug Feature list, select the service to debug.
    3. In the text box, enter the input parameters for the service, and click Send Command.

      The input parameters must be in JSON format, for example, {"Switch":0}.

Result

After data is pushed, you can view operations logs in the Real-time Logs section.

After data is pushed, you can go to the TSL Data tab of the Device Details page. On the Status tab, you can view the reported properties. On the Events tab, you can view the reported events. On the Invoke Service tab, you can view the records of service calls.

Note If you select Push Policy, you can view the logs, properties, and events after the data is pushed.