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

Data Reporting

Overview

After a device reports data, the IoT platform pushes data reported by the device to the subscribed-to address. The Developer Center provides a device simulator to simulate the scenario where a real device reports data. Developers can also connect a physical device to report data.

This topic describes how to report data using the device simulator based on the Java code sample of the data reporting API. A simple HTTP server is provided in the Java code sample of the API to help developers test whether the IoT platform has pushed messages to the subscribed-to address.

Procedure

  1. In the Eclipse, choose src > com.huawei.testMessagePush > NotifyType.java. Modify the value of TEST_CALLBACK_BASE_URL, and enter the local IP address and port number. The port number cannot be used by other local programs.

  2. Right-click src > com.huawei.testMessagePush > TestSubscribeAllServiceNotification.java, and choose Run As > Java Application.
  3. In the project space, choose Application > Application Test. Use the virtual device added in Device Access to the IoT Platform to report data.

    NOTE:

    Developers can also connect a physical device to report data.

    In Device Simulator, enter a hexadecimal code stream or JSON data (for example, enter a hexadecimal code stream) and click Send. Then, view the data reporting result in IoT Platform and Application Simulator and processing logs of the IoT platform in Message Tracking.

  4. In the Eclipse, choose the TestSubscribeAllNotification.java console and view the messages pushed by the IoT platform to the NA server.

    Developers can also test the subscription result. For example, if deviceAdded is subscribed to, developers can view messages pushed by the IoT platform on the TestSubscribeAllNotification.java console after performing the operations described in Device Registration.