onComponentChange and onProductDisconnect not working as expected.
Device: Smart Controller Firmware: Latest SDK Version: 4.12
In the following snippet from the SDK callback, onComponentChange and onProductConnect are being called as expected when the drone is turned on. However, when I turn the drone off, onProductDisconnect is not being called. How can I detect that the drone was disconnected?
override fun onComponentChange(
componentKey: BaseProduct.ComponentKey?,
old: BaseComponent?,
new: BaseComponent?
) {
Timber.i("SDK Init: Component changed - $componentKey - [$old] -> [$new]")
if (componentKey != BaseProduct.ComponentKey.FLIGHT_CONTROLLER) {
return
}
new?.let {
flightController = it as FlightController
setupCallbacks()
EventBus.getDefault().post(DroneConnectionEvent(true))
Timber.i("SDK Init: Aircraft connected")
} ?: run {
resetDefaultValues()
Timber.i("SDK Init: Aircraft disconnected")
EventBus.getDefault().post(DroneConnectionEvent(false))
}
}
override fun onProductDisconnect() {
Timber.i("SDK Init: Aircraft disconnected.")
}
override fun onProductConnect(product: BaseProduct?) {
product?.let {
aircraft = it as Aircraft
Timber.i("SDK Init: Product Connected $product.")
}
Agent comment from William Wong in Zendesk ticket #36942:
Dear Client
Thank you for contacting DJI.
Please check our demo. Normally the onProductDisconnect appears in registerApp function. You don't need write it independently. Link:https://github.com/dji-sdk/Mobile-SDK-Android/blob/master/Sample%20Code/app/src/main/java/com/dji/sdk/sample/internal/controller/MainActivity.java
Hopefully our solution can help you. Kindly Regards, DJI Developer Support
@dji-dev It isn't independent; I just only included the relevant snippets. It is inside of my registerApp callback - DJISDKManager.SDKManagerCallback. It still is not being called.
Agent comment from William Wong in Zendesk ticket #36942:
Dear Client
Thank you for contacting DJI.
I have checked with our dev team and this issue will be fixed in the next patch which is planned to be released on next Monday.
Hopefully our solution can help you. Kindly Regards, DJI Developer Support
I am using the SDK version 4.15 and still seeing similar behaviour. Testing with the Phantom 4 Pro and the DJI Assistant application. If I turn the controller off, the onProductDisconnect will get called, but if I turn off the drone while leaving the controller on, the the callback wont be triggered.