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.
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.
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: Parameter description:
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:
|
Error type | Description | Cause |
---|---|---|
0x00 | Wireless environment parameters. |
|
0x10 | The device failed to connect to IoT Platform. |
|
0x20 | Network exceptions between devices and IoT Platform. |
|
0x30 | Device runtime exceptions. |
|
0x40 | Dynamic memory monitoring. |
|
0x50 | BLE exceptions. | N/A |
Response format:
{
"id": "123",
"version": "1.0",
"code": 200,
"data": {}
}
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. |