Matsemann / mDjiController

Connect your DJI Remote Controller to your computer and use it to play simulators
Apache License 2.0
87 stars 30 forks source link

Mavic Mini controller support #7

Closed hjstn closed 4 years ago

hjstn commented 4 years ago

I have a Mavic Mini and would love to be able to use this.

I'm not entirely sure how to spot the writes to initiate the controller, but I've already gathered some serial dumps. I'm willing to send more if required. Any help with how I could figure it out would be appreciated as well (I've read through the other two issues here)

If it's at all useful, the controller appears to send two messages at regular intervals, they are (in hex): 55130403060a010020061e3f10ff7f6400fc88: Every time the light flashes ON on the controller, seems to be a keep-alive 55130403060a010020061e3e10ff7f6400d78: Almost identical hex, maybe also for keep-alive, but sent less frequently.

I've attached logs here: mm-rc.zip In plaintext, if it's easier: mm-rc-export.txt

These were captured using Device Monitoring Studio, recording the communication as the DJI Flight Simulator started (the FS supports the controller). Until GMT+0800 5:43:03 PM, the controller was at idle. After that, the left stick was moved downwards.

Matsemann commented 4 years ago

Hi!

I haven't worked on this in years, and unfortunately don't have the time to dive deep into it again, but hopefully some tips here may help.

If you were to try and update it to make it work, take a look here: https://github.com/slaterbbx/mDjiController He has updated the code and made it better since I did this many years ago, so that's a better starting point!

As for the read/writes: If I remember correctly, the exact data sent didn't really matter. It just expected to be pinged with 55 aa 55 aa <random bytes every time you wanted some data. From your dump it looks like you cold just spam one of the lines beginning with 55 0d 04 33 0a 0e over and over again, unless they've actually started to use the data for something. Or whatever line it is that corresponds to your first hex.

As for reading, compare a few reads when the stick is down vs neutral, and see which bytes that changes. At least when I did it last time the pattern was easy to spot. Some data just changed randomly, but two of the bytes were always equal when down, but different from when neutral.

Good luck!

hjstn commented 4 years ago

Thank you so much, that worked.

But now I'm not sure how to compile mDjiController now. image (if I don't include lib/ and inc/ from the project)

image (if I do, like so:) image

You've helped me a lot already but I really couldn't find a way to solve this.

Matsemann commented 4 years ago

Sounds like the same issue as https://github.com/Matsemann/mDjiController/issues/1 If so, you need to download vJoy sdk and include that.

I don't have a dev environment for C/C++/Windows, so won't be able to reproduce it here.

hjstn commented 4 years ago

Tried again by making a new project, and it now works (strange) when I include the VJoy SDK. Unfortunately, I cannot submit a pull request because the data format seems to differ pretty significantly, and I rewrote a new VJoy interface using Python.

For anyone else wishing to attempt adding support for the Mavic Mini controller, feel free to reference justin97530/miniDjiController.

Thank you so much for your help.

Matsemann commented 4 years ago

Very cool, good job! Added a link to it in my readme, it will be useful for others both because they may have the Mavic Mini, but also because your Python code is probably much easier to get working than this old C/C++ I have here. :)