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.šŸ‘

freedom2000

Well-Known Member
Licensed User
Longtime User
bad news...

I am "banned" again ...

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
onComponentChange: REMOTE_CONTROLLER
Product connected
onProductChanged: WM160
Activation state changed: LOGIN_REQUIRED
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
onComponentChange: CAMERA
onComponentChange: GIMBAL
onComponentChange: FLIGHT_CONTROLLER
onComponentChange: BATTERY
onComponentChange: AIR_LINK
Activation state changed: ACTIVATED
SDK_BindingStateChanged: UNBOUND
Aircraft disconnected!
Activation state changed: UNKNOWN
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
SDK_BindingStateChanged: UNKNOWN
Aircraft disconnected!
Product disconnected

So it seems that the UNBOUND problem is still there with vers 4.15
 
Last edited:
Upvote 0

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
Top