[英]Detect DJI drone power down event while RC is still powered on
Is there a way to determine when the drone has been powered down (when the remote controller is still powered on)?有没有办法判断无人机什么时候已经关机(遥控器controller还在开机的时候)? For example a pilot may change the drone battery but does not power down the remote controller.例如,飞行员可能会更换无人机电池,但不会关闭遥控器 controller。
I have tried using keyManager to listen to the DJIParamConnection param of DJIProductKey, DJIFlightControllerKey and DJIAirLinkKey.我尝试使用 keyManager 来监听 DJIPructKey、DJIFlightControllerKey 和 DJIAirLinkKey 的 DJIParamConnection 参数。
I also tried listening to the DJISDKManagerDelegate methods productConnected, productDisconnected, productChanged, componentConnectedWithKey, and componentDisconnectedWithKey.我还尝试收听 DJISSDKManagerDelegate 方法 productConnected、productDisconnected、productChanged、componentConnectedWithKey 和 componentDisconnectedWithKey。
But none of these key values or delegate methods are triggered when the drone is powered down.但是当无人机断电时,这些键值或委托方法都不会被触发。 They only trigger when the Remote controller is also powered down.它们仅在远程 controller 也断电时触发。
Is there another way to detect this event?还有另一种方法来检测此事件吗?
Tested on M300 and Mavic Pro with iOS SDK 4.15.2经 M300 和 Mavic Pro 测试 iOS SDK 4.15.2
EDIT编辑
I should have mentioned that this is running on a react native, native module.我应该提到这是在反应本机、本机模块上运行的。 When creating a RN native module, RN puts the module on a background thread unless specified.在创建 RN 原生模块时,除非指定,否则 RN 会将模块放在后台线程中。
componentDisconnectedWithKey and productConnected delegate functions were not firing for me because the instance running the DJISDKManagerDelegate protocol was not running on the main thread so bizarrely sometimes they would fire and sometimes not. componentDisconnectedWithKey 和 productConnected 委托函数没有为我触发,因为运行 DJISDKManagerDelegate 协议的实例没有在主线程上运行,所以奇怪的是有时它们会触发,有时不会。
I should have mentioned in my original post, this is a native module running on a react native app.我应该在我的原始帖子中提到,这是一个运行在 React Native 应用程序上的本地模块。 Most of the DJI samples have the DJISDKManagerDelegate attached to a ViewController which I assume runs on the main thread.大多数 DJI 示例都将 DJISSDKManagerDelegate 附加到我假设在主线程上运行的 ViewController。 When creating a RN native module, RN puts the module on a background thread unless specified.在创建 RN 原生模块时,除非指定,否则 RN 会将模块放在后台线程中。 There may be a more elegant solution but I solved this issue by specifying that this native module should run on the main thread.可能有更优雅的解决方案,但我通过指定此本机模块应在主线程上运行来解决此问题。
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.