Update Device Topology
DJI Pilot 2 Publishes Topology Update for Online Devices
After loading the cloud module, DJI Pilot 2 immediately initiates an MQTT connection request to the server. After the connection request is successful, a status topic is sent to the server immediately afterwards.
Communication method: MQTT
API interface:
Scenes | Published topic | Subscribed topic | remark |
---|---|---|---|
Device online | sys/product/#{pid}/status | sys/product/#{pid}/status_reply |
Parameter Description:
- #{pid}: Refers to the product ID of the gateway device. It is generally represented by the SN number of the device. Each device is different, so it is necessary to use wildcards when the server subscribes to Topic.
Parameter | Required | Type | Illustration |
---|---|---|---|
tid | Yes | string | |
bid | Yes | string | |
method | Yes | string | Only supports update_topo |
timestamp | Yes | int | 13-bit time stamp |
data | Yes | object | Online data |
data > type | Yes | int | Product type of gateway equipment |
data > sub_type | Yes | int | Product sub-type of gateway sub-device |
data > device_secret | Yes | string | The device secret of the gateway device |
data > nonce | Yes | string | The device secret of the gateway device |
data > version | Yes | int | The thing model version of the gateway device |
data > sub_devices | Yes | array | List of sub-devices, an empty array means there are no sub-devices |
data > sub_devices > sn | Yes | string | The serial number of the child device |
data > sub_devices > type | Yes | int | Product type of sub-device |
data > sub_devices > sub_type | Yes | int | Product sub-type of sub-device |
data > sub_devices > index | Yes | int | The channel index of the connected gateway device. For example: A, B |
data > sub_devices > device_secret | Yes | string | The device secret of the child device |
data > sub_devices > nonce | Yes | string | The device secret of the child device |
data > sub_devices > version | no | int | Sub-device's thing model version |
Example:
// Topic: sys/product/#{pid}/status
// Gateway devices and sub devices are online.
{
"tid": "tid001",
"bid": "bid001",
"method": "update_topo",
"timestamp": 1234567890123,
"data": {
"type": 98,
"sub_type": 0,
"device_secret":"secret",
"nonce":"nonce",
"version": 1,
"sub_devices":[{
"sn": "drone001",
"type": 116,
"sub_type": 0,
"index": "A",
"device_secret":"secret",
"nonce":"nonce",
"version": 1
}]
}
}
// Topic: sys/product/#{pid}/status
// Sub devices are offline.
{
"tid": "tid001",
"bid": "bid001",
"method": "update_topo",
"timestamp": 1234567890123,
"data": {
"type": 98,
"sub_type": 0,
"device_secret":"secret",
"nonce":"nonce",
"version": 1,
"sub_devices":[]
}
}
// Topic: sys/product/#{pid}/status_reply
{
"tid": "xxx",
"bid": "xxx",
"method": "update_topo",
"timestamp": 1234567890123,
"data": {
"result": 0
}
}
Notice:
1. As long as there is a device topology change, the DJI Pilot 2 side will send a topic to the server side to update the topology.
2. When the server side receives the status topic, it needs to send the status_reply topic to reply, otherwise the DJI Pilot 2 side will keep on pushing until it stops after receiving the reply.