Experiments with Bluetooth

From Heatweb Wiki
Jump to: navigation, search

https://www.raspberrypi.org/forums/viewtopic.php?p=947185#p947185

https://www.raspberrypi.org/forums/viewtopic.php?t=162689


http://bluedot.readthedocs.io/en/latest/pairpipi.html

# on device 0 - make device discoveravle
sudo hciconfig hci0 up
sudo hciconfig hci0 reset
sudo hciconfig hci0 piscan
sudo hciconfig hci0 leadv

# on device 1 - discover device 0
hcitool scan


Followed the following:
sudo apt-get install bluetooth bluez blueman
sudo reboot

wait for reboot - The current raspian image does not have native support for the inbuilt bluetooth on the RPi 3. However if you run hciconfig - It will shows the BD address of the Pi. Run hcitool scan to get the BD address of the pairable devices in range.

Then follow:
sudo bluetoothctl

in the [bluetooth]# type agent on followed by default-agent

To pair type pair xx:xx:xx:xx:xx:xx where xx:xx:xx:xx:xx:xx is your BD address of the device you want to pair
Next type trust xx:xx:xx:xx:xx:xx

I am using bluetooth to connect to serial on python so I simply run sudo rfcomm bind 0 xx:xx:xx:xx:xx:xx via subprocess.call to created a serial port. 

Make sure to run sudo rfcomm release 0 at the end of the script to release the serial port


https://raspberrypi.stackexchange.com/questions/78155/using-dev-rfcomm0-in-raspberry-pi


sudo bluetoothctl -a

discoverable on
pairable on
agent on
default-agent

trust XX:XX:XX:XX:XX:XX
sudo bluetoothctl -a

scan on
devices
pair XX:XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX:XX
quit
sudo rfcomm watch hci0
sudo rfcomm connect hci0 <bdaddr>

https://www.linuxquestions.org/questions/programming-9/control-bluetoothctl-with-scripting-4175615328/