B4A Library DJI-Wrapper of the Mobile SDK V5

Some time ago I had contact with Biswajit. He kindly developed a wrapper for DJI SDK version 5. In addition to the DJI Mini 3, this wrapper also supports the enterprise versions of the DJI Mavic 3. Unfortunately, I have not yet had time to create a more extensive example program. For this reason, I provide the wrapper here. Maybe there is one or the other who has the time and the desire to create and post an example. Thanks again to Biswajit for the excellent support.

Here is the documentation of DJI SDK V5:

https://sdk-forum.dji.net/hc/en-us/categories/5050636444057-Mobile-SDK-v5-8-0

The small example shows, how the wrapper and the new SDK of DJI works. It is completely different from the previous version.
On startup, this app will,

  1. Request for permission.
  2. Once all permission is accepted, it will initialize the DJI SDK
  3. Once initialization is done, it will register and connect the app to DJI server (update the DJI API key in the manifest)
  4. Once registered it will start listening for,
    1. FlightController Connection: On event it will fetch the product firmware version
    2. Product Connection: On event it will print the value
    3. Product Type Change: On event it will print the value
    4. Area Code Change: On event it will print the value
    5. Device Status: On event it will print the value

The project has an example of how can listen for some event change, and fetch the value of a specific key. You have to check the documentation to know which key you should to use for which purpose.

Check this link for all available keys: https://developer.dji.com/api-reference-v5/android-api/Components/IKeyManager/DJIKey.html
 

Attachments

  • DJI_v5_full.zip
    346.5 KB · Views: 268
  • DJIv5_example.zip
    11 KB · Views: 266

schimanski

Well-Known Member
Licensed User
Longtime User
Has anyone experimented with the wrapper? I had a bit of time and tried a few things. I managed to read data from the drone, but I haven't been able to send any information yet. I'm not sure if the wrapper is completely complete.


To send virtualStick parameters, i tried this, but there is no vsp.initialize:

B4X:
Dim vsp As VirtualStickFlightControlParam
vsp.Pitch = 0.0
vsp.Roll = 0
vsp.Yaw = 0
vsp.VerticalThrottle = 0.5   ' sanft steigen
'
'Senden
vsm.sendVirtualStickAdvancedParam(vsp)



I also tried to start the motors, but the system need an 'EmtyMsg' for that. This is not a component of the wrapper:

B4X:
Dim keyTakeoff As Object = djiKeyTool.CreateKey2(djiKeyTool.FlightControllerKey_KeyStartTakeoff)
djiKeyManager.SetValue("", keyTakeoff, True)

It seems as if all send functions fail due to initialization. Perhaps someone knows a workaround.

Thanks for any help.
 

Attachments

  • DJI Test.zip
    25.9 KB · Views: 121

PABLO2013

Well-Known Member
Licensed User
Longtime User
Hi dear, tks for your work , say tks to Biswajit , i wait for it longtime . The wrapper appears to work reasonably well for reading drone data, but the sending/action side looks incomplete in several places. The two examples you mentioned show the issue clearly:

  1. Virtual Stick
    VirtualStickFlightControlParam was exposed with properties, but there was no clear initialization path from B4A. So it was possible to write code like vsp.Pitch = ..., but not obvious how the underlying Java object was actually created first.
  2. Takeoff / action calls
    The takeoff attempt was being treated like a normal SetValue(...) operation, while in practice it behaves more like an action call. That means the wrapper needed better support for action-style methods and for parameter-less payloads such as the internal “empty message” cases.
So the main issue was not that DJI V5 itself could not do these things. The issue was that the wrapper was stronger on the read/listen side than on the write/action side.

From what I have reviewed, the weak areas were mainly:

  • parameter objects that needed explicit initialization,
  • action calls,
  • wrappers for sending values,
  • and some helper methods / signatures that were not fully mapped yet.
 
Top