Mobile-SDK-Android icon indicating copy to clipboard operation
Mobile-SDK-Android copied to clipboard

onComponentChange and onProductDisconnect not working as expected.

Open nickdonnellyriis opened this issue 5 years ago • 4 comments

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.")
                        }
                    

nickdonnellyriis avatar Jul 15 '20 12:07 nickdonnellyriis

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 avatar Jul 16 '20 04:07 dji-dev

@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.

nickdonnellyriis avatar Jul 16 '20 11:07 nickdonnellyriis

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

dji-dev avatar Jul 17 '20 07:07 dji-dev

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.

santa010 avatar Dec 20 '21 23:12 santa010