飞机ifFlying状态变化未在主要经理级别中观察到

时间:2018-05-27 00:58:26

标签: dji-sdk

我在Mavic Air上的DJIFlightControllerParamIsFlying键上设置了一个监听器。永远不会被召唤。

让flyingKey = DJIFlightControllerKey(param:DJIFlightControllerParamIsFlying)

    DJISDKManager.keyManager()?.startListeningForChanges(on: flyingKey!, withListener: self, andUpdate: { (oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in
        Logger.sharedLogger.log(message: "Received flying status change", event: "Notice", fileName: #file,line: #line,funcName: #function)                
    })

我还需要做些什么来启用该消息吗?

谢谢,

1 个答案:

答案 0 :(得分:0)

您应该检查keyManager是否为nil:

guard let km = DJISDKManager.keyManager() else {
    // handle error 
    return
}

km.startListeningForChanges(on: flyingKey!, withListener: self, andUpdate: { (oldValue: DJIKeyedValue?, newValue: DJIKeyedValue?) in
    Logger.sharedLogger.log(message: "Received flying status change", event: "Notice", fileName: #file,line: #line,funcName: #function)                
})

如果在注册前调用此键,则KeyManager可能返回nil。