Android Question DJI binding process

aeropic

Active Member
Licensed User
Longtime User
Hi all,
I'm still fighting with my connection problem to the DJI SDK
It systematically falls into an UNBOUND state and I found it fails just when the HOME is found.
Just before it is UNBOUND the state it gets is "NOT REQUIRED" and it remains in "NOT REQUIRED" until the GPS has fixed.
Flying in UNBOUND is possible but the drone is limited in range (~30m)

So I tried to switch off the data just before the GPS is fixed and it seems to work fine.
I wanted to switch into Plane OFF mode but this seems being impossible with most recent ANDROID.

Hence my question, is there a way to block the connection to DJI servers by software or to kill something to forbid it goes on trying to connect when the "NOT REQUIRED" state is reached ?

** Activity (main) Resume **
Registered successfully!
activation state: UNKNOWN
binding state: UNKNOWN
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Registered successfully!
activation state: UNKNOWN
binding state: UNKNOWN
onComponentChange: REMOTE_CONTROLLER
Product connected
onProductChanged: WM160
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
onComponentChange: CAMERA
onComponentChange: GIMBAL
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
Activation state changed: ACTIVATED
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
*** Service (remote) Create ***
** Service (remote) Start **
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
** Service (remote) Start **
MAVIC_MINI
MAVIC_MINI
home set
SDK_BindingStateChanged: NOT_REQUIRED <<<<<<<<<<<<<<<<<<<< HERE GPS is not fixed
AfterAircraftConnected <<<<<<<<<<<<<<<<<<<<<<<<<<<< I would want to stop here ;-)
simulator: false
** Service (remote) Start **
SDK_BindingStateChanged: UNBOUND <<<<<<<<<<<<<<<<<<<<<<<<<<< HERE HOME POINT is set
Aircraft disconnected!
MAVIC_MINI
** Activity (main) Pause, UserClosed = false **
** Service (remote) Destroy **
 
Solution
I want to give a short feedback of my tests:

Everything works perfect. As Erel said, the binding-problem belongs to the past. Much thanks for the new DJI-lib combined with the new b4a-version.šŸ‘

Erel

B4X founder
Staff member
Licensed User
Longtime User
Are you located in China?

1625656478972.png
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
But I must say that I tried to port your mods (resume) into my code and it didn't work.
So I went back to your code and bug also ...
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
I have relauched the app after having opened the oficial DJIFly one.

Here are the logs :

B4X:
** Activity (main) Resume **
sdk version: 4.15
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (sdk_registeredresult)
** Activity (main) Pause, UserClosed = false **
No wakelock.
running waiting messages (1)
Registered successfully!
activation state: UNKNOWN
binding state: UNKNOWN
** Activity (main) Resume **
** Activity (main) Resume **
WakeLock already held.
Activation state changed: LOGIN_REQUIRED
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
Activation state changed: ACTIVATED
Product connected
AfterAircraftConnected
simulator: true
Product connected
AfterAircraftConnected
simulator: true
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: true
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: true
SDK_BindingStateChanged: UNBOUND
Aircraft disconnected!
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
I try to add this code to login...

B4X:
Sub logging (ena As Boolean)
    If ena Then
        logIntoDJIUserAccount
    Else
        logoutOfDJIUserAccount
        ena = False
    End If
End Sub
Sub  logIntoDJIUserAccount
    Try
        UserManager.Initialize("user")
        Dim myLog As JavaObject = UserManager
        Dim context As JavaObject
        context.initializeContext
        Dim cc As Object = myLog.CreateEventFromUI("dji.common.util.CommonCallbacks.CompletionCallbackWith", "callback", Null)
        myLog.RunMethod("logIntoDJIUserAccount", Array(context, cc))
        Wait For (myLog) Callback_Event (MethodName As String, Args() As Object)
        If Args(0) <> Null Then
            Dim tt As String
            tt = Args(0)
            Log(tt)
            'NOT_LOGGED_IN          User is not logged in. User needs to be logged in to retrieve currently unlocked, and unlock authorization zones.
            'NOT_AUTHORIZED       User is logged in but has not been authorized to unlock authorization zones.
            'AUTHORIZED   User is logged in and has been authorized to unlock authorization zones.
            'TOKEN_OUT_OF_DATE The token of the user account is out of date.
            'UNKNOWN       Unknown.
        End If
    Catch
        Log(LastException)
    End Try
End Sub

Sub  logoutOfDJIUserAccount
    Try
        UserManager.Initialize("user")
        Dim myLog As JavaObject = UserManager
        Dim cc As Object = myLog.CreateEventFromUI("dji.common.util.CommonCallbacks.CompletionCallback", "callback", Null)
        myLog.RunMethod("logoutOfDJIUserAccount", Array(cc))
        Wait For (myLog) Callback_Event (MethodName As String, Args() As Object)
        If Args(0) <> Null Then
            Dim tt As String
            tt = Args(0)
            Log(tt)
            
            'NOT_LOGGED_IN          User is not logged in. User needs to be logged in to retrieve currently unlocked, and unlock authorization zones.
            'NOT_AUTHORIZED       User is logged in but has not been authorized to unlock authorization zones.
            'AUTHORIZED   User is logged in and has been authorized to unlock authorization zones.
            'TOKEN_OUT_OF_DATE The token of the user account is out of date.
            'UNKNOWN       Unknown.
        End If
    Catch
        Log(LastException)
    End Try
End Sub


Private Sub btLogin_Click
    logging (True)
End Sub
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
It did work to login. Opened nice screens. I received an activation code via SMS....
Login-required.jpg


After relaunch, LOGIN-REQUIRED has disappeared but connection doesn't work

As you say @Erel, I am considered as a chineese having to request permission to fly outside China... Same problem for @aeropic and @schimanski :)

And everything is fine with both DJIFly and Litchi. So that why I suspect a mismatch with DJI library into the authentication protocol, library which is by the way excellent !

B4X:
**************************** BaseApplication2 **************************
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
sdk version: 4.15
Registered successfully!
activation state: UNKNOWN
binding state: UNKNOWN
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
onComponentChange: REMOTE_CONTROLLER
Product connected
AfterAircraftConnected
simulator: false
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
onComponentChange: REMOTE_CONTROLLER
Product connected
AfterAircraftConnected
simulator: false
Activation state changed: ACTIVATED
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: UNBOUND
Aircraft disconnected!
 
Last edited:
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
not a lot more with unfiltered logs.

B4X:
**************************** BaseApplication2 **************************
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
sdk version: 4.15
Registered successfully!
activation state: UNKNOWN
binding state: UNKNOWN
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
onComponentChange: REMOTE_CONTROLLER
Product connected
AfterAircraftConnected
simulator: false
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
onComponentChange: REMOTE_CONTROLLER
Product connected
AfterAircraftConnected
simulator: false
Activation state changed: ACTIVATED
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: NOT_REQUIRED
AfterAircraftConnected
simulator: false
SDK_BindingStateChanged: UNBOUND
Aircraft disconnected!
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
Activation state changed: UNKNOWN
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
Product disconnected
** Activity (main) Pause, UserClosed = true **
Ignoring event: aircraft_batterystate
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I made the same experiences yesterday and today. My app doesn not work, so i tested all with the example code. Perhaps, we could enclose the problem:

I' tested it with an DJI Mavic 2 Zoom Enterprise-Edition.
My location is germany.

I have mentioned, that sometimes even if the SDK-Binding state is "NOT_REQUIRED", the restriction of the drone are enabled (max 30m altitude and 50m range).
But most of the times, I got "UNBOUND" or "UNBOUND_BUT_CANNOT_SYNC".
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I'm using the DJI smartcontroller. It is not possible to delete the dji-app. I try to use the normal controller without an dji-app and call back.

This issue might be related to an unknown device location. Make some tests outside. Start Google Maps, make sure that the location is valid and then start the example app
I'm sure, that in all my tests the location was valid, because I made all my tests outside without the simulator and all locations are shown in a map (in my own application). I think, that is not the problem.

Thank you for your efforts...
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
I now take my DJI Mavic Pro with the standard-controller and a samsung galaxy s9 without any dji-app and tested the unchanged drone-example:

After connection, the app shows the camera, but always tells: disconnected. After relaunching the app the drone ist connected, but the whole time 'UNBOUND'.
I have checked the location and it is always fixed.
The following lines are the unfiltered logs after turning on the drone:

B4X:
getMobileDataEnabled()+ subId=1
getMobileDataEnabled()- subId=1 retVal=true
post DataCameraEvent.ConnectOK RC
****resetSwitchFromWifiFlag
setCodecState state : 1
onProductChanged: FoldingDrone
Thread-3186(ApacheHTTPLog):isSBSettingEnabled false
Thread-3212(ApacheHTTPLog):isSBSettingEnabled false
Thread-3186(ApacheHTTPLog):isShipBuild true
Thread-3212(ApacheHTTPLog):isShipBuild true
Thread-3186(ApacheHTTPLog):getDebugLevel 0x4f4c
Thread-3212(ApacheHTTPLog):getDebugLevel 0x4f4c
Thread-3186(ApacheHTTPLog):Smart Bonding Setting is false
Thread-3212(ApacheHTTPLog):Smart Bonding Setting is false
Thread-3186(ApacheHTTPLog):SmartBonding Setting is false, SHIP_BUILD is true, log to file is false, DBG is false, DEBUG_LEVEL (1-LOW, 2-MID, 3-HIGH) is 1
Thread-3212(ApacheHTTPLog):SmartBonding Setting is false, SHIP_BUILD is true, log to file is false, DBG is false, DEBUG_LEVEL (1-LOW, 2-MID, 3-HIGH) is 1
FinalHttp #5 calls detatch()
verified, return
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
Activation state changed: ACTIVATED
onComponentChange: AIR_LINK
FinalHttp #1 calls detatch()
Activation state changed: LOGIN_REQUIRED
Activation state changed: ACTIVATED
SDK_BindingStateChanged: UNBOUND
Aircraft disconnected!                                                 <= State after starting the app, then I relaunch the app:
ViewPostIme key 0
ViewPostIme key 1
** Activity (main) Pause, UserClosed = true **
releaseDecoder() start
[OMX.Exynos.avc.dec] signalFlush
[OMX.Exynos.avc.dec] ExecutingState flushing now (codec owns 1/5 input, 8/13 output).
[OMX.Exynos.avc.dec] Now Flushing
[OMX.Exynos.avc.dec] FlushingState onOMXEvent(0,1,0)
[OMX.Exynos.avc.dec] FlushingState onOMXEvent(0,1,1)
[OMX.Exynos.avc.dec] Now Executing
[OMX.Exynos.avc.dec] Now Executing->Idle
[OMX.Exynos.avc.dec] Now Idle->Loaded
[OMX.Exynos.avc.dec] Now Loaded
ShutDownSmartFitting!!
Destroy SmartFitting!!
 [OMX.Exynos.avc.dec] Now uninitialized
 [] Now kWhatShutdownCompleted event : 8610
disconnecting from surface 0x78a166c010, reason disconnectFromSurface
Codec shutdown complete
releaseDecoder() end
eglDestroySurface() in
delete_surface() [1810x1080] return
eglDestroySurface() out
[SurfaceTexture-0-29692-16] disconnect: not connected (req=1)
EGLNativeWindowType 0x7950b1d010 disconnect failed
call to OpenGL ES API with no current context (logged once per thread)
OpenGL destoryed
OpenGL destoryed
MSG_WINDOW_FOCUS_CHANGED 0 1
prepareNavigationBarInfo() DecorView@e73a6b6[main]
getNavigationBarColor() -855310
Ignoring event: aircraft_batterystate
stopped(true) old=false
eglDestroySurface() in
delete_surface() [2220x1080] return
eglDestroySurface() out
EGLNativeWindowType 0x7a411e3ad0 disconnect failed
dispatchDetachedFromWindow
Input channel destroyed: 'c200c9b', fd=72
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Input channel destroyed: 'ClientS', fd=81
Ignoring event: controller_imustatechanged
uid=10375(de.sekutor.eisdrone) identical 5 lines
Ignoring event: controller_imustatechanged
Ignoring event: controller_imustatechanged
Ignoring event: controller_imustatechanged
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: controller_imustatechanged
Ignoring event: controller_imustatechanged
Ignoring event: controller_imustatechanged
uid=10375(de.sekutor.eisdrone) identical 5 lines
Ignoring event: controller_imustatechanged
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
Ignoring event: aircraft_batterystate
handleWindowVisibility: no activity for token android.os.BinderProxy@4124be0
forceLight changed to true [] from com.android.internal.policy.PhoneWindow.updateForceLightNavigationBar:4274 com.android.internal.policy.DecorView.updateColorViews:1547 com.android.internal.policy.PhoneWindow.dispatchWindowAttributesChanged:3252 android.view.Window.setFlags:1153 com.android.internal.policy.PhoneWindow.generateLayout:2474
[INFO] isPopOver = false
updateCaptionType >> DecorView@40c4d3f[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
setCaptionType = 0, DecorView = DecorView@40c4d3f[]
setView = com.android.internal.policy.DecorView@40c4d3f TM=true MM=false
Reposting event: aircraft_batterystate
Relayout returned: old=(0,0,2220,1080) new=(0,0,2220,1080) req=(2220,1080)0 dur=14 res=0x7 s={true 521044865024} ch=true
new_window_surface() [2220x1080] return: 0x3000
Reposting event: aircraft_batterystate
Reposting event: aircraft_batterystate
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
Relayout returned: old=(0,0,2220,1080) new=(0,0,2220,1080) req=(2220,1080)0 dur=16 res=0x1 s={true 521044865024} ch=false
MSG_RESIZED: frame=(0,0,2220,1080) ci=(0,0,144,0) vi=(0,72,144,0) or=2
Product connected
AfterAircraftConnected
simulator: false
OpenGL init Surface/pBuffer/Context successful!
OpenGL init Surface/pBuffer/Context successful!
new_window_surface() [1810x1080] return: 0x3000
glTexParameter: glError 1280
Not RM500 !
DJIDecodeInoutHandlerThread STARTED.
start DJIDecodeInoutThread() create
 [] Now uninitialized
[] onAllocateComponent
IOmx service obtained
MSG_WINDOW_FOCUS_CHANGED 1 1
prepareNavigationBarInfo() DecorView@40c4d3f[main]
getNavigationBarColor() -855310
prepareNavigationBarInfo() DecorView@40c4d3f[main]
getNavigationBarColor() -855310
Starting input: tba=de.sekutor.eisdrone ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
startInputInner - Id : 0
startInputInner - mService.startInputOrWindowGainedFocus
[OMX.Exynos.avc.dec] Now Loaded
initVideoDecoder create format video/avc Camera
connecting to surface 0x79a3c6d010, reason connectToSurface
[OMX.Exynos.avc.dec] setting surface generation to 30404618
disconnecting from surface 0x79a3c6d010, reason connectToSurface(reconnect)
connecting to surface 0x79a3c6d010, reason connectToSurface(reconnect)
app-pid(29692)
can't find wfdsink-exynos-enable
[OMX.Exynos.avc.dec] does not support color format 2130708361
[OMX.Exynos.avc.dec] setting HDRStaticInfo failed even though codec advertises support
Create SmartFitting Version 2.0
Init, [State:UNINITIALIZED] pid: 29692
[OMX.Exynos.avc.dec] getting HDRStaticInfo failed even though codec advertises support
initVideoDecoder configure width : 1280 height : 720
MediaCodec will operate in async mode
InitialCheck()
[OMX.Exynos.avc.dec] Now Loaded->Idle
set up nativeWindow 0x79a3c6d010 for 1280x720, color 0x105, rotation 0, usage 0x602900
[OMX.Exynos.avc.dec] configureOutputBuffersFromNativeWindow setBufferCount : 9, minUndequeuedBuffers : 5
setCodecState state : 0
[OMX.Exynos.avc.dec] Now Idle->Executing
[OMX.Exynos.avc.dec] Now Executing
InitialCheck, WhiteListStatus returned from CodecSolution : 0
InitialCheck, [State:FINISHED] SmartFitting has not been activated by App. Shut Down SmartFitting.
MSG_RESIZED: frame=(0,0,2220,1080) ci=(0,0,144,0) vi=(0,0,144,0) or=2
buffer descriptor with invalid usage bits 0x200000
[OMX.Exynos.avc.dec] getting HDRStaticInfo failed even though codec advertises support
[OMX.Exynos.avc.dec] Now handling output port settings change
set up nativeWindow 0x79a3c6d010 for 1280x720, color 0x105, rotation 0, usage 0x602900
[OMX.Exynos.avc.dec] configureOutputBuffersFromNativeWindow setBufferCount : 13, minUndequeuedBuffers : 5
[OMX.Exynos.avc.dec] Now Executing
buffer descriptor with invalid usage bits 0x200000
[OMX.Exynos.avc.dec] getting HDRStaticInfo failed even though codec advertises support
[OMX.Exynos.avc.dec] OMX_EventPortSettingsChanged 0x7f030010
dequeueOutputBuffer INFO_OUTPUT_FORMAT_CHANGED
setCodecState state : 1
buffer descriptor with invalid usage bits 0x200000
fb : 1
tx : 2
fb : 2
buffer descriptor with invalid usage bits 0x200000
tx : 3
fb : 3
tx : 4
fb : 4
tx : 5
fb : 5
tx : 6
fb : 6
tx : 7
fb : 7
tx : 8
buffer descriptor with invalid usage bits 0x200000
buffer descriptor with invalid usage bits 0x200000
uid=10375(de.sekutor.eisdrone) JNISurfaceTextu identical 1 line
buffer descriptor with invalid usage bits 0x200000
buffer descriptor with invalid usage bits 0x200000
buffer descriptor with invalid usage bits 0x200000

Drone Example.png


The drone is now limited to 30m alt and 50m range.

I can do much more testflights, if there is a scenario which could help to find the problem.
 
Upvote 0
Top