|
|
|
# Raspberry Pi Setup for Bluetooth
|
|
|
|
|
|
|
|
Hint: This installation guide is based on the following image version:
|
|
|
|
- fredosarpi_image_1.0.0.zip from 12-Dec-2017 13:33
|
|
|
|
|
|
|
|
**Step 1: Install required bluetooth packages**
|
|
|
|
|
|
|
|
```shell
|
|
|
|
sudo apt-get install pi-bluetooth bluez-tools libbluetooth-dev
|
|
|
|
```
|
|
|
|
|
|
|
|
**Step 2: Check Status of Bluetooth and HCI UART**
|
|
|
|
|
|
|
|
```shell
|
|
|
|
systemctl status bluetooth
|
|
|
|
systemctl status hciuart.service
|
|
|
|
```
|
|
|
|
|
|
|
|
The result is probably the following:
|
|
|
|

|
|
|
|
|
|
|
|
**Step 3: Change boot config**
|
|
|
|
|
|
|
|
```shell
|
|
|
|
sudo nano /boot/config.txt
|
|
|
|
sudo reboot
|
|
|
|
```
|
|
|
|
Uncomment the line ``dtoverlay=pi3-disable-bt`` --> ``#dtoverlay=pi3-disable-bt`` and save it.
|
|
|
|
Reboot after changing the boot config.
|
|
|
|
|
|
|
|
**Step 4: Enable Bluetooth and HCI UART**
|
|
|
|
|
|
|
|
```shell
|
|
|
|
sudo systemctl enable hciuart
|
|
|
|
sudo systemctl start hciuart.service
|
|
|
|
sudo systemctl start bluetooth
|
|
|
|
```
|
|
|
|
Check the status again:
|
|
|
|
```shell
|
|
|
|
systemctl status bluetooth
|
|
|
|
systemctl status hciuart.service
|
|
|
|
```
|
|
|
|
|
|
|
|
With the result:
|
|
|
|

|
|
|
|
|
|
|
|
**Step 5: Enabling Serial Port by editing the `dbus-org.bluez.servive`**
|
|
|
|
|
|
|
|
To communicate with serial over Bluetooth, we need to setup both RPis in Bluetooth compatibility mode and add the Serial Port Protocol as discussed [here on the raspberrypi.org forums](https://www.raspberrypi.org/forums/viewtopic.php?p=919420#p919420).
|
|
|
|
|
|
|
|
From a terminal: `sudo nano /etc/systemd/system/dbus-org.bluez.service`. Then add a -C to the end of the ExecStart line, and add an ExecStartPost line such that your file reads:
|
|
|
|
```
|
|
|
|
...
|
|
|
|
ExecStart=/usr/lib/bluetooth/bluetoothd -C
|
|
|
|
ExecStartPost=/usr/bin/sdptool add SP
|
|
|
|
...
|
|
|
|
```
|
|
|
|
Save the changes, and then reboot your RPi.
|
|
|
|
|
|
|
|
**Step 6: Trusting and Pairing the RPis using `bluetoothctl` (on each RPi if you want to connect them)**
|
|
|
|
|
|
|
|
The next step is to make the Bluetooth connections detectable using `hciconfig` to enable page and inquiry scans.
|
|
|
|
```shell
|
|
|
|
sudo hciconfig hci0 piscan && hciconfig
|
|
|
|
```
|
|
|
|
|
|
|
|
<b>Your Raspberry Pi is now ready to use the Bluetooth Communication Service of FREDOSAR. Be sure that the native `libbluecove_arm.so` is placed in the right directory on your Pi, otherwise an error will occur.</b>
|
|
|
|
|
|
|
|
## Bidirectional Bluetooth Communication FREDOSAR example (1st Step)
|
|
|
|

|
|
|
|
|
|
|
|
## Prepairing BlueCove for a Bluetooth OSGi Listener Bundle
|
|
|
|
At this point of time it doesn't seem to be possible to only use the BlueCove library by only by only including the dependency. The problem that couldn't be solved in this case is an ``osgi.wiring`` problem for embedding the functionallity of ``com.ibm.oti.connection`` to the bundles build via the pom-files embedded dependencies. This would be the usual way, but as mentioned, it couldn't be solved right now.
|
|
|
|
|
|
|
|
### Using BlueCove Code
|
|
|
|
To solve this problem, the code from ``bluecove-gpl-2.1.1-SNAPSHOT`` has been downloaded and the packages ``javax`` and ``com`` have been added to the code. The code then through some exceptions while loading the native code file ``libbluecove_arm.so``. Therefore the path for this native code is set hardcoded (for now) as follows:
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
That obvioselly means that this directory has to include this file to make the Bundle runnable without errors.
|
|
|
|
|
|
|
|
## Additional useful links:
|
|
|
|
- [BlueCove](http://www.bluecove.org/)
|
|
|
|
- [Serial Bluetooth Connection at startup](http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/bluetooth/serial-over-bluetooth)
|
|
|
|
- [BlueCove Programming Problem](https://www.raspberrypi.org/forums/viewtopic.php?f=81&t=58758)
|
|
|
|
- [Pi2Pi using Serial Port Profile](https://github.com/engn1931z/lab4/blob/master/README.md)
|
|
|
|
- [RFCOMM Python Server Example](https://www.youtube.com/watch?v=DmtJBc229Rg)
|
|
|
|
- [Bluetooth Wiki Ubuntu Users](https://wiki.ubuntuusers.de/Bluetooth/Einrichtung/)
|
|
|
|
- [Bluetooth Wiki Debian Users](https://wiki.debian.org/BluetoothUser)
|
|
|
|
- [Server Client Example BlueCove](https://khanmubeen.wordpress.com/2010/03/21/rfcomm-client-server-in-java/) |
|
|
|
\ No newline at end of file |