Gatttool and Parrot minidrone on Raspberry Pi (update)


#1

Product: [Mambo/Swing/Rolling Spider/Airborne Cargo/Airborne Night/Hydrofoil]
Product version: [X.X.X]
SDK version: [X.X.X]
Use of libARController: [YES/NO] (Only for ARSDK)
SDK platform: [iOS/Android/Unix/Python…]
Reproductible with the official app: [YES/NO/Not tried]

Hello,
I am struggling since a couple of days to make my Cargo MacLane drone to take off using gatttool on Raspberry Pi.
I had to dig deep into BLE official specifications in order to understand what’s going on and I have discovered that it seems that the characteristics used to send commands to my drone
are not available for “Write”, ie. gatttool shows that their “Characteristic Properties” flag (according to the BLE specification here https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.attribute.gatt.characteristic_declaration.xml) seems to be set to 4 (instead of 8 for example).
So, is this a known issue or am I missing something ? (as I am a complete newbie to BLE and maybe my question is irrelevant).
Thanks.
Thierry


#2

Hi,
after hours struggling with the various docs found on the internet and digging into the code of the minidrone.js library, I finally succeded in making my drone to take off using gatttool on Raspberry Pi.
So it’s time to give back to the community and here below are the commands/actions I had to perform to achieve that. Hope it helps !
Thierry

Connect to the drone
First, turn on your drone (obvious but don’t forget it :-))
Let’s assume the MAC address of your drone is “E0:BB:E0:BB:E0”.
In order to connect to your drone with your gatttool, you have to start :

sudo gatttool -b "E0:BB:E0:BB:E0" -t random -I (don't forget the "-t random" part).

Enable notifications
In order to take off, it seems that you have to enable notifications on some characteristics prior sending any command.
These characteristics are the following : “fb0e”, “fb0f”, “fb1b”, “fb1c” (**).
In order to achieve this, you have to write 0100 to their CCC descriptor (https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml).
To find these descriptors with gatttool, type : char-desc
You should have something like this:

	...
	handle: 0x00bc, uuid: 9a66fb0e-0800-9191-11e4-012d1540cb8e
	handle: 0x00bd, uuid: 00002902-0000-1000-8000-00805f9b34fb
	handle: 0x00be, uuid: 00002803-0000-1000-8000-00805f9b34fb
	handle: 0x00bf, uuid: 9a66fb0f-0800-9191-11e4-012d1540cb8e
	handle: 0x00c0, uuid: 00002902-0000-1000-8000-00805f9b34fb
	handle: 0x00c1, uuid: 00002803-0000-1000-8000-00805f9b34fb
	...

For the characteristic fb0e, the CCC descriptor is the handle with uuid containing 2902 right after the handle of uuid 9a66fb0e-0800-9191-11e4-012d1540cb8e, ie. the handle : 0x00bd.
For fb0f, it is the handle 0x00c0, etc…
Once you have the handles of the CCC descriptors for each characteristic mentioned in (**) you have to subscribe to, in gatttool type :

char-write-req 0x00bd 0100
char-write-req 0x00c0 0100
...

Take off
The “take off” command has to be sent to the “fa0b” characteristic.
To get its handle, in gatttool type: characteristics.
You then have a list containing a line like this;

handle: 0x0042, char properties: 0x04, char value handle: 0x0043, uuid: 9a66fa0b-0800-9191-11e4-012d1540cb8e

The characteristic handle you have to use here is the value handle : 0x0043
So, in gatttool , send the take off command to your drone:

char-write-cmd 0x0043 040102000100

If everything is ok, it should now take off .

Resources
Here are some resources that help me a lot:
https://www.oreilly.com/library/view/getting-started-with/9781491900550/ch04.html
https://www.bluetooth.com/specifications/gatt/