Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Connecting a Bluetooth device for serial communication on Arch Linux.

The following are instructions for connecting a Bluetooth device for serial communication on Arch Linux using BlueZ 5.31.

Prerequisites

The following packages are required:

  • bluez: bluetoothd
  • bluez-utils: bluetoothctl, rfcomm

Pair

  1. Start daemon: systemctl start bluetooth

  2. Pair using bluetoothctl:

    power on
    agent on
    scan on
    ... wait ...
    scan off
    pair <dev>
    
  3. Create serial device: rfcomm bind 0 <dev>

You should now have /dev/rfcomm0.

Unpair

  1. Remove serial device: rfcomm release 0

  2. Unpair using bluetoothctl:

    remove <dev>
    power off
    
  3. Stop daemon: systemctl stop bluetooth

Troubleshooting

Check rfkill list to make sure that the Bluetooth device is not blocked.

Awesome guide! It helped me out just perfect.

If I may add a few things for people reading it:

  • for me the bluetooth service was not enabled to start on boot, nor was the rfcomm module loaded. Surprisingly rfcomm bind... command doesn't spit errors in that case - just exits and doesn't create the serial port.
  • Once you have paired a device it will be remembered by the core bluetooth module. So after reboot (host and peripheral) you don't have to do the bluetoothctl commands - just go to step 3 (rfcomm bind...) and when you open the serial port it will connect.
  • I was surprised how well all this works. Tried bullying it around by loosing connection, restarting peripherals and etc while working and even when the serial port was kept open and commands were executing everything kept re-establishing connection and resuming just nicely. No need to re-bind the serial port again or anything (until the next host reboot that is).

Tested with debian kernel 4.10 on a Cubieboard2 using CSR8510 dongle from adafruit (product ID 1327).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment