Brent Patterson
Brent Patterson

Reputation: 78

Unable to enable precision landing via api call

I'm working with a Phantom 4 Pro drone, which have precision landing capacity. I'm using Swift and a iPad for controlling the drone. In DJI Go software, I can enable it, and it works correctly. However, in the app that I'm working on, any calls to enable it fails.

This is the code that tries to enable it:

static func setPrecisionLandingEnabled(precisionLandingEnabled: Bool, _ completeFunction: @escaping (Error?) -> Void) throws {
    guard let djiKeyManager = DJISDKManager.keyManager() else {
        GLog.Log("Error in Flight Controller Observer. Problem getting djiKeyManager in \(#file) \(#function)")
        throw FlightControllerManager.FlightControllerError.cantGetKeyManager
    }

    guard let precisionLandingEnabledKey = DJIFlightControllerKey(param: DJIFlightAssistantParamPrecisionLandingEnabled) else {
        GLog.Log("Error in Flight Controller Observer. Problem getting precisionLandingEnabledKey in \(#file) \(#function)")
        throw FlightControllerManager.FlightControllerError.cantGetKey
    }

    djiKeyManager.setValue(precisionLandingEnabled, for: precisionLandingEnabledKey, withCompletion: completeFunction)
}

When I call the function, the completion function of DJI SDK returned the following error:

Error Domain=DJISDKErrorDomain Code=-1013 \"Current product does not support this feature.(code:-1013)\"

The API in question is found here: https://developer.dji.com/api-reference/ios-api/Components/IntelligentFlightAssistant/DJIIntelligentFlightAssistant.html?search=precision&i=0&#djiintelligentflightassistant_setprecisionlandingenabled_inline

I checked, and there's no parameters passed in when issuing the "take-off" call that is related to precision landing. So, why am I getting this error when I know that the drone have this feature (as verified by DJI's own app)? Does the drone have to be flying first before enabling this? Or are there other conditions that must be met before I can enable this?

Upvotes: 2

Views: 232

Answers (1)

Duncan C
Duncan C

Reputation: 131501

It looks to me like you should be creating a DJIFlightAssistant object, and then using the existing method setPrecisionLandingEnabled(_: Bool, completion: DJICompletionBlock)

Why are you writing your own setPrecisionLandingEnabled() method?

Upvotes: 1

Related Questions