喊话器md

LP12对接上云API说明

概述

LP12 实现大疆 PSDK,除了 pilot 和 MSDK 外,现在可以通过上云API远程控制 PSDK,从而控制 LP12 自定义控件。
机场通过连接 MQTT 与云端进行绑定,云端需要向文档中定义的主题,发送相应数据即可操作 LP12,可通过 MQTTX 进行开发调试。

上云 API 与 PSDK 交互的主题均为 thing/product/{gateway_sn}/services ,通过消息中的 method 区分操作类型。
订阅 thing/product/{gateway_sn}/services_reply 主题获取 LP12 返回响应,result 为 0 则成功,否则需要查阅大疆错误码文档排除问题。

官方接口

喊话器-开始播放音频


Topic: thing/product/{gateway_sn}/services

Direction: down (云端 -> 设备)

Method: speaker_audio_play_start

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0}固定为 2 (机身上方云台)
file音频文件struct
file.name文件名text{}
file.url文件下载链接text{}
file.md5音频文件的md5校验和, 用作机场唯一标识text
file.format喊话器输入文件格式enum_string{“pcm”:“pcm 格式”}

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689912303287,
  "method": "speaker_audio_play_start",
  "data": {
    "file": {
      "format": "pcm",
      "md5": "b38257017001f45ec064b5157b2e4416",
      "name": "20230720162718",
      "url": "https://example.com/5a6f9d4b-2a38-4b4b-86f9-3a678da0bf4a/3dd27366-bf21-41a7-9f07-62b74f2e93a7/fe2f2474-720a-4122-a552-010e1ed08920/20230720162718.webm.pcm"
    },
    "psdk_index": 2
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_audio_play_start

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

喊话器-开始播放TTS文本


Topic: thing/product/{gateway_sn}/services

Direction: down (云端 -> 设备)

Method: speaker_tts_play_start

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0}固定为 2 (机身上方云台)
ttstts 文本struct
tts.name文件名text{}
tts.text文本内容text{}
tts.md5文件内容的md5校验和, 用作机场唯一标识text

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689860575397,
  "method": "speaker_tts_play_start",
  "data": {
    "psdk_index": 2,
    "tts": {
      "md5": "0bfb9bceee974f41a6ddfd81521bd795",
      "name": "1111",
      "text": "1111"
    }
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_tts_play_start

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

喊话器-重新播放


Topic: thing/product/{gateway_sn}/services

Direction: down

Method: speaker_replay

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0}固定为 2 (机身上方云台)

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689748764875,
  "method": "speaker_replay",
  "data": {
    "psdk_index": 2
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_replay

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

喊话器-停止播放


Topic: thing/product/{gateway_sn}/services

Direction: down

Method: speaker_play_stop

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0}固定为 2 (机身上方云台)

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689748815503,
  "method": "speaker_play_stop",
  "data": {
    "psdk_index": 2
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_play_stop

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

喊话器-设置播放模式


Topic: thing/product/{gateway_sn}/services

Direction: down

Method: speaker_play_mode_set

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0,“max”:3,“step”:1}固定为 2 (机身上方云台)
play_mode喊话器播放模式enum_int{“0”:“单次播放”,“1”:“循环播放(单曲)”}

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689842974113,
  "method": "speaker_play_mode_set",
  "data": {
    "play_mode": 1,
    "psdk_index": 2
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_play_mode_set

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

喊话器-设置音量


Topic: thing/product/{gateway_sn}/services

Direction: down

Method: speaker_play_volume_set

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0,“max”:3,“step”:1}固定为 2 (机身上方云台)
play_volume喊话器音量int{“min”:0,“max”:100,“step”:1}

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689842989237,
  "method": "speaker_play_volume_set",
  "data": {
    "play_volume": 13,
    "psdk_index": 2
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: speaker_play_volume_set

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
  "timestamp:": 1654070968655,
  "data": {
    "result": 0
  }
}

自定义组件

LP12内置了PSDK“自定义控件”。“自定义控件”是一个将“负载设备的功能”封装为按钮、开关以及范围条等控件的功能,将负载设备的功能映射到遥控器上的预留按键上,通过使用遥控器上的预留按键,以更便捷的方式控制负载设备。

LP12控件配置于 widget_config.json,这是一个用于配置控件静态属性的文件,具体参考大疆PSDK文档

该文件最重要的属性是 widget_indexwidget_type,分别为控件编号和控件类型。 上云API主要通过这两个字段对PSDK进行自定义控件操作,具体参考大疆上云API文档

psdk-设置控件值


Topic: thing/product/{gateway_sn}/services

Direction: down (云端 -> 设备)

Method: psdk_widget_value_set

Data:

ColumnNameTypeconstraintDescription
psdk_indexpsdk 负载设备索引int{“min”:0}固定为 2 (机身上方云台)
index控件编号int{“min”:0,“step”:1}widget_config.json中的widget_index
value控件值int{}widget_config.json中的widget_type而定

Example:

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 1,
    "value": 60
  }
}

Topic: thing/product/{gateway_sn}/services_reply

Direction: up (设备 -> 云端)

Method: psdk_widget_value_set

Data:

ColumnNameTypeconstraintDescription
result返回码int

Example:

{
	"tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
	"bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx",
	"timestamp:": 1654070968655,
	"data": {
		"result": 0
	}
}
button (按钮)

控制按钮控件需要云端模仿按钮先按下再释放,即发送2次消息,value先发送1,再发送0。

以播放功能为例,控件编号为 9,控件类型为按钮。

widget_config.json

{
  "widget_index": 9,
  "widget_type": "button",
  "widget_name": "Play",
  "customize_rc_buttons_config": {
    "is_enable": true,
    "mapping_config_display_order": 9
  }
}

模拟按钮按下

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 9,
    "value": 1
  }
}

模拟按钮释放

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 9,
    "value": 0
  }
}
switch (开关)

控制开关控件需要云端发送状态位,value为1时开启,0为关闭。

以循环播放功能为例,控件编号为 6,控件类型为开关。

widget_config.json

{
  "widget_index": 6,
  "widget_type": "switch",
  "widget_name": "Cycle Play",
  "customize_rc_buttons_config": {
    "is_enable": true,
    "mapping_config_display_order": 6
  }
}

开启循环播放

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 6,
    "value": 1
  }
}

关闭循环播放

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 6,
    "value": 0
  }
}
list (列表)

控制列表控件需要云端发送列表下标索引,以0开始。

以切换TTS语言类型功能为例,控件编号为 5,控件类型为列表(示例内容列表有所缩减)。

widget_config.json

{
  "widget_index": 5,
  "widget_type": "list",
  "widget_name": "TTS Tone",
  "list_item": [
    {
      "item_name": "Mandarin Female"
    },
    {
      "item_name": "Mandarin Male"
    },
    {
      "item_name": "Cantonese"
    }
  ],
  "customize_rc_buttons_config": {
    "is_enable": true,
    "mapping_config_display_order": 5
  }
}

切换粤语(列表下标索引为 2)

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 5,
    "value": 2
  }
}
scale (比例)

控制比例控件需要云端发送数字比例,value传值范围从0到100。

以切换音量功能为例,控件编号为 8,控件类型为比例。

widget_config.json

{
  "widget_index": 8,
  "widget_type": "scale",
  "widget_name": "Volume",
  "customize_rc_buttons_config": {
    "is_enable": true,
    "mapping_config_display_order": 8,
    "button_value_step_length": 5
  }
}

设置音量为50%

{
  "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "timestamp": 1689740550047,
  "method": "psdk_widget_value_set",
  "data": {
    "psdk_index": 2,
    "index": 8,
    "value": 50
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值