This command works for me:
echo [PIN] | bluez-simple-agent hci0 [BT_MAC_ADDRESS]
سؤال
I need to use a USB Bluetooth dongle on a linux server.
Actually it works and I can discover other bluetooth devices, but if I try to connect with one of them (with rfcomm
) it says Can't connect RFCOMM socket: Connection refused
.
I think that the problem is the pairing, because when I type the same command on desktop systems, it asks the passkey to me, in a dialog window (not in the terminal). So the question is: how can I pair a device without a desktop environment? Thanks in advice.
المحلول
This command works for me:
echo [PIN] | bluez-simple-agent hci0 [BT_MAC_ADDRESS]
نصائح أخرى
If your device is already paired, then to request pairing again, commands as below. Or else error mesage as Creating device failed: org.bluez.Error.AlreadyExists: Already Exists
To remove pairing: bluez-test-device remove XX:XX:XX:XX:XX:XX
To pair again : bluez-simple-agent hci0 XX:XX:XX:XX:XX:XX
If you happen to have than 1 bluetooth hardware and would like to use second one, use hciconfig
to find adapter name and then use that name in place of hci#
. Command as below
bluez-simple-agent hci# XX:XX:XX:XX:XX:XX