It appears possible to pair and communicate with the module without using a pin, but so far only using gatttool. I am still learning about BLE, and it is unclear to me whether this is a normal feature (e.g. a low-security default mode), or whether the modules I am using (JDY-08 / BT05 / HM-10 style BLE serial) might be non-compliant and simply not using the pin as set.

Via the default connection tool in Ubuntu Mate

I am running Ubuntu Mate on a Lenovo P50. I am exploring a BT05 BLE module, but I cannot connect to the device due to what I think might be a bug in Ubuntu. The steps I am taking to connect the device are:

  1. From the bluetooth menu, I select "Setup new device".
  2. I select the device from the list
  3. and then proceed, selecting "pair device"
  4. A screen saying "Pairing in progress..." appears.
  5. After some minutes, the message changes to "Failed to add device".
  6. At no point in time am I prompted to enter the 6-digit pin code needed for pairing.

The pin is customized and cannot be inferred by the operating system (short of forcing 10^6 possibilities), so I need to be able to enter it when connecting to the device. This issue might be related. The commands found here are a possible solution, but to this date there remains no method of communicating with bluetooth devices through the graphical user interface.

Via bluetoothctl

bluetoothctl claims to connect (without using the custom pin). (this question is helpful for understanding what bluetoothctl is doing). However, it does not seem possible to read/write characteristics once the device is paired?

φ bluetoothctl
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
[NEW] Device [address] [name]
[bluetooth]# scan off
[bluetooth]# pair [address]
Attempting to pair with [address]
[CHG] Device [address] Paired: yes
Pairing successful
[name]# info [address]
Device [address]
    Name: [name]
    Alias: [name]
    Paired: yes
    Trusted: yes
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Generic Access Profile    ([ID1])
    UUID: Generic Attribute Profile ([ID2])
    UUID: Device Information        ([ID3])
    UUID: Unknown                   ([ID4])
    Modalias: bluetooth:[number]
[name]# list-attributes
[no attributes]

Based on, for example, this tutorial, I would expect Characteristics and Attributes to become available after pairing.

Via hcitool and gatttool

I am able to connect to the modules and access the relevant properties using the commands hcitool and gatttool. This is also without a pin.

φ sudo hcitool -i hci0 lescan --duplicates | grep 'earlybird'
φ gatttool -i hci0 -b [ADDRESS] -I
[ADDRESS][LE]> connect
Attempting to connect to [ADDRESS]
Connection successful
[ADDRESS][LE]> primary
attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0022 uuid: 0000180a-0000-1000-8000-00805f9b34fb
attr handle: 0x0023, end grp handle: 0xffff uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
[ADDRESS][LE]> included
No included services found for this range
[ADDRESS][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0024, char properties: 0x1e, char value handle: 0x0025, uuid: 0000ffe1-0000-1000-8000-00805f9b34fb

Actually the post you linked to is identical as they never had a PIN option either, the second picture was from someone else. I would try in terminal, with your BT05 device in pairing mode

echo -e "power on\n scan on" |bluetoothctl
Then you should see a reference to a new device with a MAC address and a name, use the MAC exactly as displayed in terminal or you can enter the first couple digits and use the TAB key to autocomplete
pair {MAC}
trust {MAC}
connect {MAC}
With any luck it will pair or ask you for the PIN to enter. If that doesn't work install Blueman
sudo apt install blueman
See if it will allow you to use the 6 digit PIN as this was a bug with gnome-bluetooth in 16.04

  • Do we mark the question as a duplicate and close it then? Thanks for all your help! Will try it tomorrow. – MRule Dec 8 '17 at 23:46
  • So bluetoothctl appears to "pair" without ever asking for the pin, but then the "paired" device will not provide any information on attributes or characteristics. Contrast this to the behavior on Android, which /does/ ask for a pin, and /does/ reveal bluetooth characteristics. Experimenting with blueman now. – MRule Feb 10 '18 at 13:51
  • No luck with blueman either. I'm quite surprised: bluetoothctl does not ask for a pin, even if I set one on the modules. Does this make sense? I cannot see anything in the bluetoothctl menu that would indicate a way to specify a pin when pairing. – MRule Feb 11 '18 at 10:46
  • Hi @MRule ! Did you manage to solve this ? I’m facing a very similar problem here :) thanks ! – Vincent Monteil Sep 6 at 18:13
  • Sorta. I used gatttool via the Python bindings. Connections were unstable, and I had to tweak how things behaved to avoid kernel panics. I ended up using a solution where both the BLE module and the computer polled at regular intervals, to try to synchronize their states. I also did some funny things to reboot the BLE chip and reset the connection from the computer periodically, since the pairing would be lost at random. But it in the end, it more or less worked. – MRule Sep 7 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.