Minimal BLE commands to send for take off


#1

Hi,
I’m trying to make a minidrone night take off using python. I’m looking for the minimal set of BLE instructions to make that happen.
I got the node.js controller working and based on the keyboard example I’m trying to reverse engineer a simple take off sequence.
This is what I have so far

  1. Scan for the drone: OK
  2. Connect to the drone: OK
  3. Read out the drone name: OK (but I suppose this is optional)
  4. Send commands to take off: FAIL
    I try to send the following commands to characteristic 9a66fa0b-0800-9191-11e4-012d1540cb8e
    "Set Time Out" [0x04, 0x01, 0x00, 0x04, 0x01, 0x00, 0x32, 0x30, 0x31, 0x34, 0x2D, 0x31, 0x30, 0x2D, 0x32, 0x38, 0x00]
    “Flat trim” [0x02, 0x02, 0x02, 0x00, 0x00, 0x00]
    “Take Off” [0x02, 0x03, 0x02, 0x00, 0x01, 0x00]

I think I’m missing something :slightly_smiling:
If anyone could provide the minimal set of commands to launch the drone in the air that would be great
Or maybe the short list of commands for take off in gatttool?

Thanks for your time!

Frost


Pure Java SDK on Windows or Linux desktop to control Airborne Night via BLE?
#2

Some more digging in rolling-spider node.js and comparison work with hcidump brought me to an answer.
Looks like the controller needs to register for some specific notifications before attempting take off. (In rolling-spider it is called handshake).

Here is a minimal working sequence:

  1. Scan for the drone: OK
  2. Connect to the drone: OK
  3. Register for notifications by writing 0100 to the following handles
    0x00c0 0100
    0x00bd 0100
    0x00e4 0100
    0x00e7 0100
    0x0113 0100
    0x0116 0100
    0x0119 0100
    0x0123 0100
    0x0126 0100
    0x0129 0100
  4. send take off command to handle 0x0043 (earlier mentioned time out and flat trim are not required)
    0x0043 020302000100

Hurray, I now have a working python example :slightly_smiling:
Any comments/thoughts on where I could have found some documentation on this handshake process are still very welcome!

-Frost


Minidrone takeoff with BLED112 dongle
#3

I think, all you need to do is notification.
After connection, you should scan all characteristics for following Uuid
"9a66fa00-0800-9191-11e4-012d1540cb8e",
“9a66fb00-0800-9191-11e4-012d1540cb8e”,
“9a66fc00-0800-9191-11e4-012d1540cb8e”,
“9a66fd21-0800-9191-11e4-012d1540cb8e”,
“9a66fd51-0800-9191-11e4-012d1540cb8e”,
“9a66fe00-0800-9191-11e4-012d1540cb8e”

then issue Notify as following simple c# code.

 chrL = svc.GetAllCharacteristics();
 foreach(var chr in chrL)  {
      if (chr.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify)) {
           var status = await chr.WriteClientCharacteristicConfigurationDescriptorAsync(
                  GattClientCharacteristicConfigurationDescriptorValue.Notify);
          if (status == GattCommunicationStatus.Unreachable)
                  Messagebox.show("Device is unreachable!");
     }
 }

One more thing:
“Set Time Out” [0x04, 0x01, 0x00, 0x04, 0x01, 0x00, 0x32, 0x30, 0x31, 0x34, 0x2D, 0x31, 0x30, 0x2D, 0x32, 0x38, 0x00] seems “Set current date of controller” with string “2014-10-28”

Good Luck!


#4

Are you willing to share this code? I’ve been working to get a python interface going and I feel like I’m going in circles. The library is built for iOS and andoid and really assumes no one wants to program non-mobile, which is frustrating.


#5

It has been a while since I touched this :slight_smile:
I believe the attached file contains my working example but I was not able to verify (drone not available). Note that you will also need bluepy which you can find here : https://github.com/IanHarvey/bluepy

Good luck!
test.py.zip (1.6 KB)


#6

Thank you! I am continuing to look into it but I didn’t realize how slow BLE was for photos until yesterday so I’m not sure our idea is possible over BLE (we really need a frame rate of at least 3-5 fps and this is more like seconds per frame). But your code will help!


#7

Frostlock, your code was very helpful as I’ve been working through my code. I finally got a Raspberry Pi 3 and now have it flying! Your code worked right away but I’m working on a Mambo class in python that will have a full interface to all of the commands and sensors. My mambo class works now too. I have two questions for you:

  1. Where did you find the magic that you had to write those 0100 bytes to the specific characteristics? I can’t find that in the documentation other than here.

  2. Why do you have a final 0 byte in your send? You send the project, the class, and the command, and then a final 0. The documentation says the command is 2 bytes but all the ints they give are just a single byte so are you just padding with a 0?

Thanks!!


#8

Hey CaptainSaavik, good to hear that you have been making progress :smile: :+1:
Looks like you are well ahead of where I got to! Good stuff!
About your questions:

  1. I used a working node.js application to send the instructions to the drone. I then sniffed the bluetooth communication using hcidump and that showed those 0100 bytes. Which I then hacked into the code. Sorry I don’t have a better explanation for this. I just stumbled on the difference and fixed it.
  2. I can’t remember exactly. Padding up to the required two bytes sounds reasonable. Maybe someone else on this forum can provide a better explanation/confirmation.

If you ever decide to put up your code somewhere please let me know, I would love to have a look :slight_smile:


#9

I’ve been reading that node.js code too. I noticed they had magic in there too on the handshake. Wish it was in the docs somewhere!

Yes, I intend to release it publicly on GitHub when I’m done. It is there now but private. I’m developing this for a K-12 competition so I need a nice interface. I’m happy with what I have so far and I’ve tried to make it general and well documented. My next task is to figure out sensor readings.


#10

Frostlock, I have now made my code publicly available!