Search code examples
bluetoothraspbianraspberry-pi3bluezpairing

Bluetooth pairing using fixed PIN on bluez 5


I am trying to connect 2 or more Raspberry Pi 3 boards over bluetooth. I am looking for options to set security while pairing. I am using Raspian-stretch(Latest one available). Bluez version available on RPI-3 is 5.23(as shown from bluetoothd -v command).

I am using headless version. I want the pairing to be secured(meaing there should be some kind of authentication i can set like PIN(4 digits) or Passkey(6 digits)) without the user logged into it. So if i have to connect my phone to the RPI, i dont have to login to RPI inorder to enter the PIN/Passkey. Then i would like to set up bluetooth PAN network so that i can communicate to between devices connected to PAN network.

I want pair the device/s using a PIN which is available in a file in the system or somewhere i can point it to. Say for example, pin.txt file in /temp/ directory or by running an agent to set the PIN. I read from other posts that bluez5.x got rid of the bluetooth-agent which was used in earlier version of bluez to do the things i could acomplish.

Agents in bluetoothctl such as DisplayOnly, KeyboardDisplay,NoInputNoOutput, DisplayYesNo,KeyboardOnly,on either sets a dynamic passkey which has to be entered manually or confirmation the passkey or just lets any device to pair and connect without any authntication in case of NoInputNoOutput.

Here is the link which i found of this forum stating that the agent is no longer available: https://www.raspberrypi.org/forums/viewtopic.php?t=133961 I also refers to some examples that shows pairing of devices but doesnt address what i am looking for.

There is no info available on manpage too. https://manpages.debian.org/stretch/bluez/bluetoothctl.1.en.html

Here is something i found about the commands but still not what i am looking for. https://wiki.archlinux.org/index.php/Bluetooth

I have also posted this Raspberry Pi forum. Here is the link: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=195090

Any help or suggestion to get around this or links to documnets i could refer to is appreciated.

Thanks in advance.


Solution

  • I was able to get this working with the test scripts.

    For anyone who is interested to know the details, please refer to my post on Raspberry Pi forum. Below is the link.

    https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=195090&p=1221455#p1221455