dji-sdk / Mobile-SDK-iOS

DJI Mobile SDK for iOS: http://developer.dji.com/mobile-sdk/
Other
577 stars 256 forks source link

1013 Error when setting Mavic 2 Enterprise Dual Camera Display Mode #313

Closed cyoian closed 5 years ago

cyoian commented 5 years ago

Hello, I am trying to set the camera mode when the Mavic 2 Enterprise is attached but I am getting an error:

camera!.setDisplayMode(DJICameraDisplayMode.MSX, withCompletion: nil)

SWITCHING TO MSX Error: Optional(Current product does not support this feature.(code:-1013)) SWITCHING TO THERMAL Error: Optional(Current product does not support this feature.(code:-1013)) SWITCHING TO VISUAL Error: Optional(Current product does not support this feature.(code:-1013))

dji-sdk[bot] commented 5 years ago

Hi, there are two options for you to ask for help:

  1. Post your issues on StackOverflow: https://stackoverflow.com/questions/tagged/dji-sdk, the community can help you.

  2. Report your issues to dev@dji.com, as it's our official channel for developers to request DJI Developer Support now.

For DJI Developer Support, we have the following three tiers:

PaulKemppi commented 5 years ago

I have the same problem. The camera name is Mavic 2 Enterprise Dual-Visual. But changing the display mode with setDisplayMode() returns "Not supported".

cyoian commented 5 years ago

Hi Paul,

I figured out the problem on this. You have to always call setDisplayMode() on the thermal camera and not the visual camera. Here is how I implemented it:

    func checkForMavic2Enterprise() {
        guard let product = DJISDKManager.product() else {
            print("No product")
            return
        }

        if product.model == "Mavic 2 Enterprise Dual" {
            guard let camera = fetchCamera() else {
                print("Camera is nil")
                return
            }

            camera.setDisplayMode(DJICameraDisplayMode.visualOnly, withCompletion: nil)
        }
    }

    // get the drone camera
    func fetchCamera() -> DJICamera? {
        if let product = DJISDKManager.product() {
            if let productKind = product as? DJIAircraft {
                guard let cameras = productKind.cameras else {
                    print("Cameras are nil")
                    return productKind.camera
                }

                // if there is more than one camera, the second is an infrared camera that can perform functions related to switching camera view modes
                if cameras.count > 1 {
                    return cameras[1]
                } else {
                    return productKind.camera
                }

            } else if let productKind = product as? DJIHandheld {
                print("HANDHELD CAMERA: \(productKind.camera.debugDescription)")
                return productKind.camera
            }
        }
        return nil
    }
PaulKemppi commented 5 years ago

Perfect! Thanks for the tip!

Regards, Paul