lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

how to automatically pairing of bluetooth devices

Thu Nov 27, 2014 10:27 pm

right now on pi, the pairing of bluetooth requires typing in passphrase like 0000 or 1234 between pi and other bluetooth system.

but at times pi has no keyboard and monitor, so how to automate the pairing without typing and viewing on monitor?

or write a script chart auto detect pairing message from system and programmatically enable the pairing. how to do that on pi?

User avatar
ulysess
Posts: 310
Joined: Thu Aug 02, 2012 6:35 am
Location: Spain
Contact: Website

Re: how to automatically pairing of bluetooth devices

Fri Nov 28, 2014 10:13 am

Maybe this help: https://github.com/jmcerrejon/PiKISS/bl ... plekeyb.sh

;)
lilzz wrote:right now on pi, the pairing of bluetooth requires typing in passphrase like 0000 or 1234 between pi and other bluetooth system.

but at times pi has no keyboard and monitor, so how to automate the pairing without typing and viewing on monitor?

or write a script chart auto detect pairing message from system and programmatically enable the pairing. how to do that on pi?
  • PiKISS for Raspberry Pi: https://github.com/jmcerrejon/PiKISS
  • Blog: https://misapuntesde.com/
  • Patreon: https://www.patreon.com/cerrejon?fan_landing=true
  • Twitter: https://twitter.com/ulysess10
  • Discord: https://discord.gg/Y7WFeC5

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27030
Joined: Sat Jul 30, 2011 7:41 pm

Re: how to automatically pairing of bluetooth devices

Fri Nov 28, 2014 11:47 am

To the OP - please read you PM's and try to keep all the bluetooth related questions in one thread please.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
Douglas6
Posts: 4918
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: how to automatically pairing of bluetooth devices

Fri Nov 28, 2014 2:12 pm

lilzz wrote:but at times pi has no keyboard and monitor, so how to automate the pairing without typing and viewing on monitor?
The PIN code is there for a reason; security. I wouldn't want just anybody pairing their computer with mine. SSH is one option for pairing to a Pi with no keyboard or monitor (a network connection is of course required).

If you REALLY want to pair without a PIN code, you can have bluez-simple-agent running in the background with the 'NoInputNoOutput' flag set

Code: Select all

sudo bluez-simple-agent -c NoInputNoOutput &
for example. The pi will still need to be 'discoverable'. You can set the discoverable timeout to '0' (no timeout) in /etc/bluetooth/main.conf, and run 'sudo hciconfig piscan' at boot time. But again, this means that anybody can pair to the Pi at any time. Better, have a button that runs the 'sudo hciconfig piscan', and leave the timeout at the default 180 seconds. That at least limits the window for unauthorized access.

lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

Re: how to automatically pairing of bluetooth devices

Fri Nov 28, 2014 6:38 pm

Douglas6 wrote:
lilzz wrote:but at times pi has no keyboard and monitor, so how to automate the pairing without typing and viewing on monitor?
The PIN code is there for a reason; security. I wouldn't want just anybody pairing their computer with mine. SSH is one option for pairing to a Pi with no keyboard or monitor (a network connection is of course required).

If you REALLY want to pair without a PIN code, you can have bluez-simple-agent running in the background with the 'NoInputNoOutput' flag set

Code: Select all

sudo bluez-simple-agent -c NoInputNoOutput &
for example. The pi will still need to be 'discoverable'. You can set the discoverable timeout to '0' (no timeout) in /etc/bluetooth/main.conf, and run 'sudo hciconfig piscan' at boot time. But again, this means that anybody can pair to the Pi at any time. Better, have a button that runs the 'sudo hciconfig piscan', and leave the timeout at the default 180 seconds. That at least limits the window for unauthorized access.

OK, how about a tradeoff, how can I hardwire the PIN code 0000 with blues-simple-agent? I want to automated with commands not have to get prompted.

Return to “General discussion”