Topic Message

2022-06-23
No Rating

System Topic

Topic NamePublishers --> SubscribersMessageDescription
sys/product/#{pid}/statusGateway Devices --> Cloud PlatformIt is mainly used to update the device topology.
sys/product/#{pid}/status_replyCloud Platform --> Gateway DevicesReply the topic.
sys/product/#{pid}/network/probeCloud Platform --> Gateway DevicesSend a null message with Qos=1 to the device and determine the network latency based on the ACK.

status: Device status

The entire device topology can be updated by updating_topo several times.

// 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":[]
    }
}

status_reply: Device status reply

// Topic: sys/product/#{pid}/status_reply 
{
    "tid": "xxx",
    "bid": "xxx",
    "method": "update_topo",
    "timestamp": 1234567890123,
    "data": {
        "result": 0
    }
}

Note : The command send and response match is done by matching the tid and bid fields in the message, send the reply response to keep the tid and bid the same.

Response parameters description:

ParameterTypeDescription
resultIntegerError codes, see the following error codes.

Error codes:

Error codeMessageDescription
212510Wrong signature for device one machine one secret.
212511The device is already online, no need to repeat online.

Thing Model Topic

If you are not sure about the concept of thing model, please study the chapter Thing Model.

In order to facilitate the device cloud platform to distinguish the processing strategies of different attributes. We divide the device reporting model attributes into osd and state categories, which are reported with different topics.

  • osd:The attribute reported by the device fixed frequency, corresponding to the original thing model attribute with PushMode = 0.
  • state:The thing model attribute for device event-based reporting or server-initiated request for device reporting. Corresponds to the original PushMode =1 and PushMode =2 thing model attributes. It is recommended that the cloud platform cache the state class attributes and provide them in the form of device shadows for upper layer business applications for query.
Topic NamePublishersSubscribersDescription
thing/product/#{pid}/osdGateway devices or aircraftNon-gateway clients (web browsers)Device properties that are actively published to the cloud platform from the device side.(see thing model content for content scope)
thing/product/#{pid}/stateGateway devices or aircraftNon-gateway clients (web browsers)Device properties that are actively published to the cloud platform from the device side.(see thing model content for content scope)
thing/product/#{pid}/state_replyCloud platformGateway devices or aircraftThe cloud platform sends a state_reply response to the device.
thing/product/#{pid}/servicesNon-gateway clients (web browsers)Gateway devices or aircraftServices commands sent from the browser or cloud platform to the device.(see Thing Model content for commands scope)
thing/product/#{pid}/services_replyGateway devices or aircraftNon-gateway clients (web browsers)Service reply.

osd: fixed frequency

{
  "tid": "xxx", 
  "bid": "xxx", 
  "timestamp": 1598411295123,
  "data": {
    "43-0-0":{  // gimbal. Format:type-sub_type-gimbal_index
      "gimbal_pitch":0,
      "gimbal_roll":0,
      "gimbal_yaw":-103.7,
      "measure_target_altitude":100,
      "measure_target_distance":1256.800049,
      "measure_target_error_state":1,
      "measure_target_latitude":21.99849,
      "measure_target_longitude":112.987933,
      "payload_index":"43-0-0",
      "version":1
    },
    "attitude_head":0,
    "attitude_pitch":-0.5,
    "attitude_roll":-0.1,
    "battery":{
      "batteries":[
        {
          "capacity_percent":90,
          "firmware_version":"01.02.05.31",
          "index":0,   // battery index
          "loop_times":131,
          "sn":"xxx", // battery sn
          "sub_type":0,
          "temperature":23.1,
          "type":0,
          "voltage":49032
        }
      ],
      "capacity_percent":45,
      "landing_power":5,
      "remain_flight_time":0,
      "return_home_power":10
    },
    "elevation":0,
    "firmware_version":"04.00.0014",
    "gear":1,
    "height":100.020332,
    "home_distance":0,
    "horizontal_speed":0,
    "latitude":22,
    "longitude":113,
    "mode_code":0,
    "position_state":{
      "gps_number":15,
      "is_fixed":0,
      "quality":5,
      "rtk_number":0
    },
    "total_flight_distance":0,
    "total_flight_time":0,
    "vertical_speed":0,
    "wind_direction":0,
    "wind_speed":0
  },
  "gateway":"xxx" // controller's sn
}

state

{
  "bid":"xxx",
  "data":{
    "control_source":"A",
    "home_latitude":22,
    "home_longitude":113,
    "low_battery_warning_threshold":20,
    "payloads":[
      {
        "control_source":"A",
        "payload_index":"43-0-0", // unique index
        "sn":"xxx"
      }
    ],
    "serious_low_battery_warning_threshold":10
  },
  "tid":"xxx",
  "timestamp":1643268146298,
  "gateway":"xxx" // controller's sn
}

services

{ 
    "tid": "xxxx", 
    "bid": "xxxx", 
    "method": "xxx",  
    "data": { // Consistent with the input of the service in the thing model file
        "value": 43,
        ...
    }
}

services_reply

{
    "tid": "xxxx",
    "bid": "xxxx",
    "data": {
        "result": 0, 
      "output": {	// Consistent with the output of the service in the thing model file
          "battery_capaticy": 2
      }
    }  
}

events

{
    "method":"xxxx",
    "tid":"xxxx",
    "bid":"xxxx",
    "timestamp":"1234567890123",
	"data":{
        "result":0,
        "output":{
            
        }
	}
}