Skip to content

How to use manually with GATTTool

Benjamin Piouffle edited this page Sep 23, 2017 · 1 revision

For this you'll need Bluez with GATTTool (normally installed with Bluez). Run GATTTool --help to assert it is installed.

  1. Run hciconfig
$ hciconfig
hci1: Type: BR/EDR  Bus: USB
	BD Address: CC:52:AF:09:EC:60  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING PSCAN 
	RX bytes:1050 acl:0 sco:0 events:52 errors:0
	TX bytes:1423 acl:0 sco:0 commands:52 errors:0

hci0:	Type: BR/EDR  Bus: USB
	BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
	UP RUNNING PSCAN ISCAN 
	RX bytes:1238 acl:0 sco:0 events:71 errors:0
	TX bytes:1556 acl:0 sco:0 commands:69 errors:0
  1. Run sudo hciconfig hciX up with X being the number of the interface you want to use
  2. [Only if you have multiple interfaces] Run sudo hciconfig hciX down for each interface you don't want to use with X being the number of the interface
  3. List Bluetooth LE devices: sudo hcitool lescan. If your device isn't here, try to disconnect from it on others Apps / Devices. Bluetooth LE will stop broadcast its presence as soon as a device is paired.
$ sudo hcitool lescan
LE Scan ...
5C:31:3E:42:25:3C XXXXXX
C7:17:1D:43:39:03 LEDBLE-1D433903
  1. Magic Blue light name should look like this LEDBLE-XXXXXXXX. Keep the MAC address (C7:17:1D:43:39:03 in my case)

  2. Launch GATTTool...

    • If your version is 6, 9 or 10: sudo GATTTool -t public -b MAC_ADDRESS -I
    • If your version is 7 or 8: sudo GATTTool -t random -b MAC_ADDRESS -I
  3. In the newly opened GATTTool shell type connect

sudo gatttool -t random -b C7:17:1D:43:39:03 -I
[   ][C7:17:1D:43:39:03][LE]> connect
[CON][C7:17:1D:43:39:03][LE]> 

You'll then be able to send manual commands to Magic Blue bulb from here.

Example: To change color : char-write-req 0x000c 56FFFFFF00f0aa (replace FFFFFF by any hexadecimal color)

For a list of commands, see the characteristics list and functions

Clone this wiki locally