Python Bluez RFCOMM Server (Bluetooth communication)Sending the Raspberry Pi's IP to a client (Mobile phone) over bluetooth
sudo nano /etc/rc.local
Added this before the exit line (bottom of the script)
sudo bash -c 'python /YOUR-PATH/rfcomm-server.py > /YOUR-PATH/rfcomm-server.log 2>&1' &
Making the bluetooth pairing Raspberry - Phone and sending the Raspberry IP to phone
-
Install the newest Raspbian Stretch image and mount it to Pi
- https://www.raspberrypi.org/downloads/raspbian/
- Version I used was released on 2019-04-08
- Balena Etcher used to flash the SD card and mount the image
-
Boot up the Raspberry with HDMI connected
-
Follow the tutorial to setup and make sure to update the software on last step
-
Restart the device
-
Click the Raspberry Logo in upper left toolbar - Preferences > Raspberry Pi Configuration > Interfaces > Enable SSH
-
On your computer open the terminal and ssh to your raspberry device: ssh pi@192.168.0.120
-
Setting up bluetooth settings
-
sudo apt-get install pulseaudio bluez pulseaudio-module-bluetooth python-gobject python-gobject-2
-
In /etc/bluetooth/input.conf file, add Enable=Source,Sink,Media,Socket.
-
In /etc/pulse/daemon.conf file, add ; resample-method = trivial.
-
In /etc/bluetooth/main.conf file, add Class = 0x00041C.
-
sudo reboot
-
-
Making bluetooth auto accept pairing from other devices
- sudo nano /etc/systemd/system/dbus-org.bluez.service
- change ExecStart=/usr/lib/bluetooth/bluetoothd into ExecStart=/usr/lib/bluetooth/bluetoothd -C
- sudo sdptool add SP
-
Clone RFCOMM server into some folder git clone https://github.com/dinohorvat/pybluez--rfcomm-server.git
-
Install Pybluez
- sudo apt-get install bluetooth libbluetooth-dev
- sudo pip install pybluez
-
Making the script run on boot
- sudo nano /etc/rc.local
- Added this before the exit line (bottom of the script) sudo bash -c 'python /YOUR-PATH/rfcomm-server.py > /YOUR-PATH/rfcomm-server.log 2>&1' &
-
sudo reboot