3

I'm using Ubuntu 11.10 and try to connect to a Bluetooth device from the command line but I always need to enter the PIN in a graphical dialog box. The commands I use:

root@ubuntu:~# hcitool scan
Scanning ...
00:00:00:00:00:00   device
root@ubuntu:~# rfcomm connect 0 00:00:00:00:00:00 1

And after this, the enter PIN dialog appears.

Is there any way to keep the interaction in the command line? In my environment it is not allowed to use GUIs or require the user to enter PINs. Btw, the PIN is always the same but the MAC will change from time to time.

  • There is a similar question for paired devices at askubuntu.com – lumbric Jan 4 '12 at 13:22
  • That question is concerned with previously paired devices. In my case I need to control the pairing process. – allprog Jan 4 '12 at 15:34
1

What you are looking for is a bluetooth agent, which validates the PIN. You'll find a very straightforward one at here, written in python. You just have to change the end of RequestPinCode to 'return "0000"' for instance.

  • Great, thanks! What should I do if it returns this exception: dbus.exceptions.DBusException: org.bluez.Error.AlreadyExists: Already Exists. I suppose there is already an agent but how can I unregister that? – allprog Jan 4 '12 at 15:14
  • It means there already is an agent running. Should be something like blueman (blueman-manager). 'killall blueman-manager' should do the trick. – Ravachol Jan 4 '12 at 15:16
  • Beautiful! It works! I had to kill the blueman-applet and started my hacked agent. blueman-manager is useful to remove the pairings. – allprog Jan 4 '12 at 15: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.