Linux – bluetooth pairing and connection from command line

bluetoothbluetooth-lowenergyhcilinux

I want to connect and pair to available nearby bluetooth devices from command line in linux.
I have searched through internet, and found that we can pair through simple-agent, but it is not available in my device.
following commands are available in device:
hcitool, hciconfig, hcidump, sdptool, l2ping, rfcomm.
for connecting to remote device i am running the following command.
hcitool cc BD_ADDRESS
but above command is connecting the device for a while, and again the device is getting disconnected. in hcidump output , i am seeing the disconnection event. Is there anyway in linux command line through which i can test my bluetooth? What can be the reason for device is getting disconnected after a while?

Best Answer

I saw the same issue once and was able to solve it with the rfcomm command. Try the following:

# rfcomm connect /dev/rfcomm0 00:11:22:33:44:55 1 &

Additionally, it is good practice to enable secure simple pairing and enable page and inquiry scan with the following commands:

# hciconfig hci0 sspmode 1
# hciconfig hci0 piscan

Let me know if you still have problems.

Related Topic