【问题标题】:How to connect DJI product using DJI mobile sdk如何使用 DJI mobile sdk 连接 DJI 产品
【发布时间】:2021-01-14 12:00:34
【问题描述】:

我一直在尝试 dji github(android 或 ios)中的几乎所有示例,但无法将我的 dji 产品(phantom 4 pro+ V2.0)连接到我的应用程序。我可以使用我的 api 密钥成功注册我的应用程序,但是当我使用 USB 电缆将 dji 产品连接到手机时,我看不到任何连接。请帮帮我。

【问题讨论】:

    标签: dji-sdk


    【解决方案1】:

    对于 iOS 应用:您需要将外部 UISupportedExternalAccessoryProtocols 键添加到您的 plist 文件中。像这样 `

    <key>UISupportedExternalAccessoryProtocols</key>
         <array>
             <string>com.dji.video</string>
             <string>com.dji.protocol</string>
             <string>com.dji.common</string>
         </array>
    

    然后使用 DJIAssistantSimulator 模拟到无人机位置。

    【讨论】:

      【解决方案2】:

      将无人机连接到应用程序的第一步是调用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 部分中。

      【讨论】:

        猜你喜欢
        • 2019-05-02
        • 1970-01-01
        • 1970-01-01
        • 2022-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多