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

aeropic

Active Member
Licensed User
Longtime User
It looks like your drone is not properly registered. Might be some caching issue.

The bounding step is only needed once and it is usually done with the official DJI app.

Thanks Erel, yes my drone is somewhat weird for this. The problem is that binding is OK with DJI fly app and with Litchi and does not pass with any application developped with B4A.
If only I could stop the registering process once the NOT REQUIRED status is reached, this would be an acceptable work around.
Manually switching to plane mode before GPS fix is done is a pain, I wish I could do this by software...
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
I have now exactly the same problem than @aeropic ...

After two or three months without any issue, my Spark required "LOGIN_REQUIRED".

So I started to look through the DJI API and found this explaination : https://developer.dji.com/api-refer...ctivationManager/DJIAppActivationManager.html
"
DJI aircraft firmware require mobile applications that control DJI aircraft to be activated with the user's DJI account, if that application is being used in China. This will ensure operators use the correct set of geospatial information and flight functions for their aircraft, as determined by their geographical location and user profile.

A summary of the activation system is:

- Users in China are required to activate their application by logging into their DJI account at least once every three months within the application
- Activation will be persistent in the application until the user logs out
- A data connection will be required to log into a DJI account
- Outside of China, the SDK will automatically activate the application without requiring the user to log in
- Additionally, users in china are required to bind their aircraft to their user account in DJI Go. This is required only once.

If an application is not activated, the aircraft not bound (if required), or a legacy version of the SDK (<4.1) is being used, all camera live streams will be disabled, and flight will be limited to a cylinder of 100m diameter and 30m height to ensure the aircraft stays within line of sight. "

Well I started to open the @Erel xml file for DJI library and discovered that a wrap of " UserManager As DJIUserManager" was already existing

The .login method was exposed but didn't produce any effect.

I finally used javaobject to test this method :

B4X:
Sub  logIntoDJIUserAccount
    Try
        UserManager.Initialize("user")
        Dim myLog As JavaObject = UserManager
        Dim context As JavaObject
        context.initializeContext
        myLog.RunMethod("logIntoDJIUserAccount", Array(context, Null))
    Catch
        Log(LastException)
    End Try
End Sub

And ... It works !
A dialog is opened requiring the login and the password + a captcha
Afterwhat a token is generated and sent to your phone via SMS. You can enter it into another popup dialog
[DJI]Your verification code is 519341, valid within 5 minutes.

And it worked, it unlocked my spark during the current flight.

BUT next time I opened the App the situation was even worse... I don't have the "LOGIN_REQUIRED" message but instead a persistant " SDK_BindingStateChanged: UNBOUND "
And my App is locked... and even for my Mavic Mini which was working fine...

I don't understand what is DJI doing... but it's really a shame
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
But both my Spark and my Mavic Mini still work with DJIGo and DJIFly Apps...

I don't understand what is the problem...
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
It looks like your drone is not properly registered. Might be some caching issue.

I had the same problems and it seems, that ist is like Erel said, it's an caching issue.

First, it is possible to use then login-function of the usermanager without the workaround by using UserManager.Login. Each time before connecting to product, i use the login-function:
B4X:
Wait For (RequestPermissions) Complete (Result As Boolean)
    If Result Then
        sdk.Initialize("sdk")
        timer1.Initialize("timer1", 200)
        UserManager.Initialize("UserManager")
        Wait For SDK_RegisteredResult (Success As Boolean, ErrorMessage As String)
        If Success Then
            Log("Registered successfully!")
            UserManager.Login
            Log("activation state: " & sdk.ActivationState)
            Log("binding state: " & sdk.AircraftBindingState)
            sdk.StartConnectionToProduct
        Else
            Log(ErrorMessage)
        End If
    Else
        ToastMessageShow("No permission granted!", True)
    End If

If there is no saved activated account in the cache, the system opens the window to login.

BUT next time I opened the App the situation was even worse... I don't have the "LOGIN_REQUIRED" message but instead a persistant " SDK_BindingStateChanged: UNBOUND "

For me, it works if i delete my application and make a complete reinstall. Than login with your account if you have once an internet-connection. After that, it works all the time, until you make an update over the b4-bridge. That seems to be the problem. Each update with the b4a-bridge seems to break the account-informations.
For developing, i changed the SDK-bindingstatechanged-sub from

B4X:
If (State = "BOUND" Or State = "NOT_REQUIRED") And aircraft <> Null And aircraft.Connected Then

to

B4X:
Sub SDK_BindingStateChanged (State As String)
    Log($"SDK_BindingStateChanged: ${State}"$)
    SDKBindingState=State
    If aircraft.IsInitialized And aircraft <> Null And aircraft.Connected Then
        AfterAircraftConnected
    Else
        Fluggeraet_getrennt
    End If
End Sub

So it is possible to have complete drone-data without veryfied account-informations during developing. After developing, uninstall your app, make a reinstall and login again. Than it should work.
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Bad news! It seems to have been pure coincidence, that i don't have any binding problems after new installation of my app.
The more I tested, the more often I had the binding-problems again.
First time after newinstallation, there is always no problem, but after the second or third battery pack, the SDK-state is UNKNOWN or UNBOUND_BUT_CANNOT_SYNC with the limits of 30m high and 50m expanse.
Are there in the meantime other solutions found?

Thanks for reply.....
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
yep I forgot to say that I tried your setup and it never worked for me :)

I enter into contact with DJI support, nice guy but unable to help me.

Currently working in "unbound" limited in altitude at 30m --> that's a hell.
We found a "solution" with @aeropic to move the Home Point dynamically when you approach the 50m boundary. It does work, no more limit in range !
But there is a drawback... you loose the return to home function as it will return to your last home point...

I suspect a mismatch somewhere in B4A implementation as Litchy does work without "unbound"... But this is far beyond my competences to find where is this mismatch
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Thank you for your efforts!

I tried it with updating the homelocation dynamically. The limit of 30m altitude is always the same and for example hotspot-missions doesn't work too. So it is not really usefull for me. If it is a good solution for your app, you could try to update the homelocation manually with the following code. It works in normal mode, but i did not tried it after using setHomeLocationUsingAircraftCurrentLocation and set the homepoint to my location when the drone is more than 50m away and UNBOUND:

B4X:
   ....
    Dim FlightControllerInstance As JavaObject
    FlightControllerInstance=aircraft.RunMethod("getFlightController", Null)
  ....
  ....
    Dim PilotLocation As DJILocation2D = CreateLocation2D(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude)
    Dim callback As Object = FlightControllerInstance.CreateEventFromUI("dji.common.util.CommonCallbacks$CompletionCallback", "sethomelocationcallback", Null)
    FlightControllerInstance.RunMethod("setHomeLocation", Array(PilotLocation, callback))

    Wait For (FlightControllerInstance) sethomelocationcallback_Event (MethodName As String, Args() As Object)
    If Args(0) <> Null Then
        Log("Error SetHomelocation: " & Args(0))
    End If

B4X:
Sub CreateLocation2D(Latitude As Double, Longitude As Double) As DJILocation2D
 Dim jo As JavaObject
 jo.InitializeNewInstance("dji.common.model.LocationCoordinate2D", Array(Latitude, Longitude))
 Return jo
End Sub

I tried the bounding with different accounts, so i think that it is not a login-problem. It seems to be only a problem with the developer-account from dji.
 
Last edited:
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
My DJI-App is completely finished now, and the possible features are awesome. Thank you very much for that great library...

But with the binding-problems, the application is so far unfortunately useless.
I made endless tests with countless batteries and different accounts, but it is not possible for me to isolate the problem.

I suspect a mismatch somewhere in B4A implementation as Litchy does work without "unbound"...

It seems, that the problem could be the b4a-implementaion or perhaps a bug in the DJI SDK v4.14-trial1.

I would like to ask, if there is maybe someone who has no problems. Maybe i missed something.
I'm also not able to evaluate, if the problem was present in the first version of the library because I'm only now intensively concerned with the topic.

Thank you for all efforts...
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Wow, that are very good news.

DJI v4.61 is attached. It includes a FollowMeMission. Similar to the HotspotMission API.

Can I ask carefully for the later implemented followme-function? It is one of our most wanted features and runs perfectly:p...
 
Upvote 0

freedom2000

Well-Known Member
Licensed User
Longtime User
I have just tested the latest V4.15 library and the "UNBOUND" bug seems to have disappeared

NotRequired.jpg


If it is really the case (lasts more than one month) then it is really a good news ? ? ?
 
Upvote 0

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
Top