Devices that use Wi-Fi can report the network status to IoT Platform by using specified topics. This article describes the topics and data formats that are used by devices to report the network status, and the network errors that can be reported.
Automatically report the network status to IoT Platform
The following topics are used when a device sends requests to IoT Platform and IoT Platform sends responses to the device:
Request topic: /sys/${productKey}/${deviceName}/_thing/diag/post
Response topic: /sys/${productKey}/${deviceName}/_thing/diag/post_reply
Sample request in the Alink JSON format:
- Current data: the data that is immediately reported after the data is collected by the device.
The device immediately reports the network status data in the following two scenarios:
- When a network error is detected, 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. Sample request that reports data when the device detects 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 If no error is detected during scheduled collection, the err_stats parameter is empty. - Historical data: the data that is not immediately reported. In most cases, the device may delay the
reporting of the collected network metrics. When the device reports historical data,
the device can report multiple data records at a time.
Sample request:
{ "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 is detected, the err_stats parameter is empty.
Parameter | Type | Description |
---|---|---|
id | String | The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device. |
version | String | The version of the protocol. Valid value: 1.0. |
params | Object | The request parameters. |
wifi | Object | The metrics of the network status. Four metrics are reported when the device uses Wi-Fi. |
rssi | integer | The strength of the received wireless signal. |
snr | integer | The signal-to-noise ratio of the wireless signal. |
per | integer | The packet loss rate. |
err_stats | String | The network error message. This parameter is included in the reported data only when
the device detects a network error.
Format: Fields in the network error message:
For more information about specific errors, see err_stats. |
_time | Long | The timestamp that indicates when the network status was collected.
Note The timestamp can be empty. If it is empty, the Device Network Status tab in the IoT Platform console does not display the time when data was collected.
|
model | String | The model of the message body. The parameter value includes the following fields:
|
Error type | Description | Cause |
---|---|---|
0x00 | The parameters of the wireless network environment. |
|
0x10 | The device failed to connect to IoT Platform. |
|
0x20 | A network exception occurred between the device and IoT Platform. |
|
0x30 | An exception occurred on the device. |
|
0x40 | The memory information. |
|
0x50 | A Bluetooth Low Energy (BLE) exception occurred. | BLE exception. |
Sample response in the Alink JSON format:
{
"id": "123",
"version": "1.0",
"code": 200,
"data": {}
}
Parameter | Type | Description |
---|---|---|
id | String | The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device. |
code | Integer | The status code in the response. A value of 200 indicates that the request was successful. |
version | String | The version of the protocol. Valid value: 1.0. |
data | Object | The value is empty. |