I have had the same problem for a while now (5 months), and I stumbled upon this page yesterday
The first few comments will show you how to implement a PIN code for the bluetooth on the Pi.
It worked for me once I had installed this (I installed this before changing some files to implement the PIN code.
Basically the procedure is the following :
in /etc/apt/sources.list, uncomment the line beginning with "deb-src"
After that, do a
sudo apt-get update and a
cd /usr/src; sudo apt-get source bluez
In the file
/usr/src/bluez-5.23/test/simple-agent change this part :
return ask("Enter PIN Code: ")
Into the following
return "1234" where 1234 is the pin code you want to use.
After that you create the following script in /usr/bin, let's call it btscript.sh :
result=`ps aux | grep -i "simple-agent" | grep -v "grep" | wc -l`
if [ $result -ge 0 ]; then
sudo hciconfig hci0 piscan
sudo hciconfig hci0 sspmode 0
sudo /usr/bin/python /usr/src/bluez-5.23/test/simple-agent &
echo "BT Agent already started"
Make this script executable with a
sudo chmod +x
Add this line before
exit 0 in the file
After that, reboot your machine :
You should be able to connect to your Pi using a PIN code.
Although, as mentionned here, you will be able to see your Pi with an iOS device, but only once, so do not make your device forget your Pi, otherwise you will not be able to connect to it anymore.
To counter that, create a script called for example bt_iphone.sh, and put that code in it :
sudo hciconfig hci0 sspmode 1 # Activate SSP which is the current standard
# for bluetooth pairing, this will make the RPi discoverable again but
# with a passkey instead of a PIN code
echo -e 'power off\n quit ' | bluetoothctl # Make the RPi undiscoverable
echo -e 'power on\n quit ' | bluetoothctl # Make the RPi discoverable again
sudo hciconfig hci0 sspmode 0 # Deactivate SSP and activate PIN code authentication
Make it executable with
sudo chmod +x bt_iphone.sh & execute this script every minute with a crontab :
crontab -e and at the end of the file :
* * * * * sudo bash /path/to/bt_iphone.sh
This is not elegant but it seems to work.
If anyone has a better solution for this last problem, I'm open to suggestions.
A problem still persists (again with iDevices only), there is a timeout on the PIN code, which makes it impossible to connect if you have not typed and confirmed the PIN code within 3 seconds of the display of the PIN code screen.
I have not found any workaround for this yet.