【发布时间】:2021-01-14 12:00:34
【问题描述】:
我一直在尝试 dji github(android 或 ios)中的几乎所有示例,但无法将我的 dji 产品(phantom 4 pro+ V2.0)连接到我的应用程序。我可以使用我的 api 密钥成功注册我的应用程序,但是当我使用 USB 电缆将 dji 产品连接到手机时,我看不到任何连接。请帮帮我。
【问题讨论】:
标签: dji-sdk
我一直在尝试 dji github(android 或 ios)中的几乎所有示例,但无法将我的 dji 产品(phantom 4 pro+ V2.0)连接到我的应用程序。我可以使用我的 api 密钥成功注册我的应用程序,但是当我使用 USB 电缆将 dji 产品连接到手机时,我看不到任何连接。请帮帮我。
【问题讨论】:
标签: dji-sdk
对于 iOS 应用:您需要将外部 UISupportedExternalAccessoryProtocols 键添加到您的 plist 文件中。像这样 `
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.dji.video</string>
<string>com.dji.protocol</string>
<string>com.dji.common</string>
</array>
然后使用 DJIAssistantSimulator 模拟到无人机位置。
【讨论】:
将无人机连接到应用程序的第一步是调用DJISDKManager.registerApp 并传递DJISDKManagerDelegate 的实例。
class ProductPublisher : NSObject, ObservableObject {
...
func registerWithSDK() {
...
DJISDKManager.registerApp(with: self)
}
...
}
重要的部分是您的委托实现了一些必需的方法并调用DJISDKManager.startConnectionToProduct()。
extension ProductPublisher : DJISDKManagerDelegate {
func appRegisteredWithError(_ error: Error?) {
// set breakpoint here
DJISDKManager.startConnectionToProduct()
}
func productConnected(_ product: DJIBaseProduct?) {
// set breakpoint here, this marks a successful connection
}
}
ProductPublisher 类是我自己的一个类,我封装了有关注册和连接的所有逻辑。它是我正在编写的 iOS 的 tutorial series 的一部分。我刚才解释的内容在第 2 部分中。
【讨论】: