From what I have seen it looks like bluetooth-agent is in fact not available in Jessie. However, this might work to automate bluetoothctl
:
#!/bin/bash
# enable bluetooth
sudo systemctl start bluetooth
sleep 1
# run the program bluez
echo -e 'power on\nconnect \t \nquit' | bluetoothctl
Quoting from the site linked above, "You have to pass with echo (with option -e) the commands you want to execute. Every command you have to terminate it with a new line (\n). When I do connect I use the tab (\t) so that I do not need to update the script with the MAC of my keyboard."
The options for bluetoothctl
are:
Available commands:
list List available controllers
show [ctrl] Controller information
select <ctrl> Select default controller
devices List available devices
paired-devices List paired devices
power <on/off> Set controller power
pairable <on/off> Set controller pairable mode
discoverable <on/off> Set controller discoverable mode
agent <on/off/capability> Enable/disable agent with given capability
default-agent Set agent as the default one
set-scan-filter-uuids [uuid1 uuid2 ...] Set scan filter uuids
set-scan-filter-rssi [rssi] Set scan filter rssi, and clears pathloss
set-scan-filter-pathloss [pathloss] Set scan filter pathloss, and clears rssi
set-scan-filter-transport [transport] Set scan filter transport
set-scan-filter-clear Clears discovery filter.
scan <on/off> Scan for devices
info [dev] Device information
pair [dev] Pair with device
trust [dev] Trust device
untrust [dev] Untrust device
block [dev] Block device
unblock [dev] Unblock device
remove <dev> Remove device
connect <dev> Connect device
disconnect [dev] Disconnect device
list-attributes [dev] List attributes
select-attribute <attribute> Select attribute
attribute-info [attribute] Select attribute
read Read attribute value
write <data=[xx xx ...]> Write attribute value
notify <on/off> Notify attribute value
register-profile <UUID ...> Register profile to connect
unregister-profile Unregister profile
version Display version
quit Quit program
You could use discoverable on
and pairable on
. I have never done much with bluetooth but I don't believe you need much more to get a basic connection.
To get this running at boot, put the line with the path to the script in /etc/rc.local
with a & to fork it to the background, e.g
sudo /home/pi/Desktop/StartServer.sh &
You might also be able to use the tool hciconfig
instead of bluetoothctl
. This might be a more streamlined approach.