Device network status

Updated at:
Copy as MD

Wi-Fi-connected devices can report their network status and error data to the cloud over a specific topic. This topic describes the reporting topic, data format, and network error codes.

Note Devices that run AliOS Things 3.0 or later automatically detect and report network status data.

Device-initiated network status reports

Data is sent from the device to the cloud (uplink communication).

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

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

The Alink request data format:

  • Current data: Data reported immediately after collection.

    A device reports network status data immediately in these cases:

    • A network error occurs. The device collects the relevant metrics and reports the data immediately.
    • Scheduled collection is configured. The device collects and reports data at the specified time.

    For example, if a device detects a network problem at 2019-08-22 08:10:29, it reports the data immediately. The data format for a network error:

    {
      "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 For scheduled reports of normal network data, the err_stats parameter is empty.
  • Historical data: Data that is not reported immediately. During routine diagnostics, a device can delay reporting normal network metrics and 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 there are no network errors, the err_stats parameter is empty.
Table 1. Request parameters
Parameter Type Description
id String The message ID. A string-type number. The value must be unique for the device and range from 0 to 4294967295.
version String The protocol version number. The only valid value is 1.0.
params Object The request parameters.
wifi Object The Wi-Fi network status parameters. This parameter contains four network status metrics.
rssi integer The received signal strength.
snr integer The signal-to-noise ratio.
per integer The packet loss rate.
err_stats String The error data. Included only when the device detects a network error.

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

Parameter descriptions:

  • type: The error type.
  • code: The cause of the error.
  • count: The number of errors.

For details about the errors, see Table err_stats.

_time Long The timestamp.
Note The timestamp can be empty. If it is empty, the collection time is not displayed on the Device Network Status page in the console.
model String The message body pattern. Contains the following fields:
  • format: The data format. Only simple is supported, which indicates that the data is in a simplified format.
  • quantity: The data quantity. Valid values:
    • single: Reports a single data entry.
    • batch: Reports multiple data entries. This is used only for historical data.
  • time: The data time type. Valid values:
    • now: Reports current data.
    • history: Reports historical data.
Table 2. err_stats
Error type Meaning Cause
0x00 Wireless environment parameters.
  • Signal strength (RSSI): 0x01
  • Signal-to-noise ratio (SNR): 0x02
  • Packet loss rate: 0x03
0x10 The device failed to establish a connection with the cloud.
  • Failed to connect to the router (Wi-Fi fail): 0x01
  • DHCP failed. Failed to obtain an IP address (DHCP fail): 0x02
  • DNS failed. Failed to parse the cloud domain name (DNS fail): 0x03
  • TCP handshake failed (TCP fail): 0x04
  • TLS handshake failed (TLS fail): 0x05
0x20 Network error between the device and the cloud.
  • The cloud actively disconnected from the device (CLOUD_REJECT): 0x01
  • Device data uplink or downlink failed (RW_EXCEPTION): 0x02
  • PING operation between the device and the cloud failed (PING_EXCEPTION): 0x03
0x30 Device runtime error.
  • Device restarted by watchdog timer (WD_RST): 0x01
  • Device restarted due to a panic error (PANIC_ERR): 0x02
  • Device restarted after a power cycle (RE-POWER): 0x03
  • Device restarted due to a fatal error (FATAL_ERR): 0x04
0x40 Dynamic monitoring of device memory.
  • Total memory size: 0x01
  • Total free memory size: 0x02
0x50 BLE error. BLE error

The Alink response data format:

{
  "id": "123",
  "version": "1.0",
  "code": 200,
  "data": {}
}
Table 3. Response parameters
Parameter Type Description
id String The message ID. A string-type number. The value must be unique for the device and range from 0 to 4294967295.
code Integer The result code. A value of 200 indicates success.
version String The protocol version number. The only valid value is 1.0.
data Object The value is empty.