Devices that are connected to Wi-Fi can report the network status to the cloud through specified device topics. This article describes device topics, data formats, and network errors that are related to the reporting of device network status.

Note If your devices use AliOS Things of version 3.0 or later, the system automatically monitors and reports network status data.

Device automatically reports status

Data is reported through the following topics.

Request topic: /sys/{productKey}/{deviceName}/_thing/diag/post

Response topic: /sys/{productKey}/{deviceName}/_thing/diag/post_reply

The following is the request format for the Alink protocol.

  • Current data: the data that is immediately reported after being collected by the device.

    The device immediately reports the network status data for the following two scenarios.

    • When a network error occurs, the device immediately reports the error to IoT Platform.
    • If you have set scheduled collection, the device collects data at the specified time and immediately reports the data.

    For example, the device detects a network error at 08:10:29 of August 22, 2019, and immediately reports the data. Then, the data format for the network error is as follows:

    {
      "id": "123",
      "version": "1.0",
      "params": {
        "p": {
          "wifi": {
            "rssi": 75,
            "snr": 20,
            "per": 10,
            "err_stats":"10,02,01;10,05,01"
          },
          "_time": 1566432629000
        },
        "model": "quantity=single|format=simple|time=now"
      }
    }
    Note If no error occurs, the err_stats parameter is empty.
  • Historical data: the data that is not reported immediately. In most cases, the device may delay the reporting of the collected network metrics. A device can report historical data in batches.

    Data format:

    {
      "id": "123",
      "version": "1.0",
      "params": {
        "p": [
          {
            "wifi": {
              "rssi": 75,
              "snr": 20,
              "per": 10,
              "err_stats":"10,02,01;10,05,01"
            },
            "_time": 1566432629000
          }
        ],
        "model": "format=simple|quantity=batch|time=history"
      }
    }
    Note If no error occurs, the err_stats parameter is empty.
Table 1. Request parameters
Field Type Description
id String The message ID. The message ID must be a number string and it must be unique among all messages for a device.
version String The protocol version. Set the value to 1.0.
params Object Input parameters of the request.
wifi Object The network connection mode of the device is WiFi. This parameter value includes four metrics of the network status.
rssi Integer The received signal strength.
snr Integer The signal-to-noise ratio of the wireless signal.
per Integer The data packet loss rate.
err_stats String The error message. This parameter is only included in the reported data only when the device detects a network error.

Format: "type,code,count;type,code,count". Example: "10,02,01;10,05,01".

Parameter description:

  • type: the error type
  • code: the error code
  • count: the number of errors

For specific errors, you can refer to the err_stats table below.

_time Long The timestamp of the network status.
Note The timestamp can be empty.
model String The model of the message body. Valid values:
  • format: the data format. Only simple format is supported. It indicates that the data is in a simplified format.
  • quantity: the number of data records to report.
    • single: indicates that a single data record is reported.
    • batch: indicates that multiple data records are reported. This option is only used to report historical data.
  • time: reports the data based on the collection time.
    • now: reports the current data.
    • history: reports the historical data.
Table 2. err_stats
Error type Description Cause
0x00 Wireless environment parameters.
  • The signal strength (RSSI): 0x01
  • Signal-to-noise ratio (SNR): 0x02
  • Packet loss rate (drop ratio): 0x03
0x10 The device failed to connect to IoT Platform.
  • Router connection failure (Wi-Fi fail): 0x01
  • The device failed to acquire the IP address (DHCP fail): 0x02
  • DNS failed to resolve the domain name DNS (DNS fail): 0x03
  • TCP handshake failed (TCP fail): 0x04
  • TLS handshake failed (TLS fail): 0x05
0x20 Network exceptions between devices and IoT Platform.
  • IoT Platform rejected the connection from the device (CLOUD_REJECT): 0x01
  • Errors occurred during device upload or download (RW_EXCEPTION): 0x02
  • Errors occurred during the pinging between the device and IoT Platform (PING_EXCEPTION): 0x03
0x30 Device runtime exceptions.
  • The watchdog timer reset (WD_RST): 0x01
  • Unexpected restart of the device storage (PANIC_ERR): 0x02
  • Reboot errors after the device powers off (RE-POWER): 0x03
  • Reboot errors (FATAL_ERR): 0x04
0x40 Dynamic memory monitoring.
  • Total memory (type of total size): 0x01
  • Total idle memory (type of free size): 0x02
0x50 BLE exceptions. N/A

Response format:

{
  "id": "123",
  "version": "1.0",
  "code": 200,
  "data": {}
}
Table 3. Response parameters
Field Type Description
id String The message ID. It is a number string.
code Integer The response code. A value of 200 indicates that the request is successful.
version String The protocol version. The current protocol version is 1.0.
data Object If the request is successful, the data object is empty.