5

I want to connect my computer to a bluetooth headset. My computer has ubuntu 12.04 64 bits server operating system with no gui. So I must connect my computer via command line. But at internet documentation has no working example.

I have used hciconfig, hcitool, btsco etc and I was not successful.

My command line output is:

hciconfig -a

hci0:   Type: BR/EDR  Bus: USB

    BD Address: 00:15:83:2E:2F:70  ACL MTU: 384:8  SCO MTU: 64:8
    UP RUNNING
    RX bytes:2309 acl:0 sco:0 events:118 errors:0
    TX bytes:299 acl:0 sco:0 commands:48 errors:0
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
    Link policy: RSWITCH HOLD SNIFF PARK 
    Link mode: SLAVE ACCEPT 
    Name: 'EDRClassone'
    Class: 0x280404
    Service Classes: Capturing, Audio
    Device Class: Audio/Video, Device conforms to the Headset profile
    HCI Version: 2.0 (0x3)  Revision: 0xc5c
    LMP Version: 2.0 (0x3)  Subversion: 0xc5c
    Manufacturer: Cambridge Silicon Radio (10)


hcitool scan

Scanning ...
    00:11:67:00:25:02   BH025C

hcitool cc 00:11:67:00:25:02

Can't create connection: Connection timed out

I have bluetooth daemon at /etc/init.d/bluetooth and just work fine.

How to connect via command line?

5 Answers 5

9

these listed commands here didn't help me much. But I found a good list for the use of bluetoothctl here: https://wiki.archlinux.org/index.php/Bluetooth_headset

# bluetoothctl

to be greeted by its internal command prompt. Then enter:

# power on
# agent on
# default-agent
# scan on

Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,

[NEW] Device 00:1D:43:6D:03:26 Lasmex LBT10

shows a device that calls itself "Lasmex LBT10" and has MAC address 00:1D:43:6D:03:26. We will now use that MAC address to initiate the pairing:

# pair 00:1D:43:6D:03:26

After pairing, you also need to explicitly connect the device (every time?):

# connect 00:1D:43:6D:03:26

If everything works correctly, you now have a separate output device in PulseAudio. Note: The device may be off by default. Select its audio profile (OFF, A2DP, HFP) in the "Configuration" tab of pavucontrol.

You can now redirect any audio through that device using the "Playback" and "Recording" tabs of pavucontrol.

You can now disable scanning again and exit the program:

# scan off
# exit

so, kudos to archlinux for that (after the 'connect' command, the sound over my bt speakers worked with pulseaudio pavucontrol)

4

here is an step-by-step instruction! Bluetooth Setup via commandline

and for your connection timed out, do you reset the adapter?? if not you can do this with this command. sudo hciconfig hci0 reset

I recommend you to read the instructions in the given link.

And to use it in commandline, here are some commands Some Bluetooth send/get commands

1

hcitool cc 00:11:67:00:25:02 is not enough to connect to your device. You will need an authentication procedure after creating connection. The full command is hcitool cc 00:11:67:00:25:02; hcitool auth 00:11:67:00:25:02

0

hcitoll scan if your device is there put its mac adress instead of one i used sudo hcitool cc 01:07:81:93:66:BC when prompted search for input pin button and insert your pin

-2

list the blue-tooth device using bt-device -l

then connect device using mac address using command. bluetoothctl connect #mac_address

example :bluetoothctl connect 28:44:A9:E6:E7:95

1
  • 2
    Could you please edit your answer to give an explanation of why this code answers the question? Code-only answers are discouraged, because they don't teach the solution.
    – DavidPostill
    Apr 11, 2020 at 16:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .