Category Archives: Bluetooth

Raspberry Pi und RFDuino – Kommunikation über Bluetooth LE

Kompilieren der aktuellen bluez-sourcen:

git clone https://git.kernel.org/pub/scm/bluetooth/bluez.git
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-library --with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library --disable-systemd

Build und Konfiguration gemäss Linux from scratch:

git clone https://git.kernel.org/pub/scm/bluetooth/bluez.git
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library --disable-systemd
make
sudo make install
sudo ln -svf ../libexec/bluetooth/bluetoothd /usr/sbin
sudo install -v -dm755 /etc/bluetooth
sudo install -v -m644 src/main.conf /etc/bluetooth/main.conf

Den Bluetooth-Daemon automatisch starten und stoppen:

wget http://www.linuxfromscratch.org/blfs/downloads/svn/blfs-bootscripts-20140827.tar.bz2
bzip2 -d ...
tar xvf ...
sudo make install-bluetooth

Die Konfiguration liefert unter anderem folgenden Output für D-Bus:

checking for DBUS... yes
checking D-Bus configuration directory... /etc
checking D-Bus system bus services dir... /usr/share/dbus-1/system-services
checking D-Bus session bus services dir... /usr/share/dbus-1/services

Den Code Kompilieren und anschliessend installieren:

make
sudo make install
sudo ln -svf /usr/local/libexec/bluetooth/bluetoothd /usr/sbin
libtool: install: /usr/bin/install -c profiles/cups/bluetooth /usr/lib/cups/backend/bluetooth
 /bin/mkdir -p '/etc/dbus-1/system.d'
 /usr/bin/install -c -m 644 src/bluetooth.conf '/etc/dbus-1/system.d'
 /bin/mkdir -p '/usr/share/dbus-1/services'
 /usr/bin/install -c -m 644 obexd/src/org.bluez.obex.service '/usr/share/dbus-1/services'
Reloaded configuration
 /bin/mkdir -p '/usr/share/dbus-1/system-services'
 /usr/bin/install -c -m 644 src/org.bluez.service '/usr/share/dbus-1/system-services'
 /bin/mkdir -p '/usr/include/bluetooth'
sudo hciconfig hci0 up
sudo hcitool dev
sudo hcitool lescan

sudo gatttool --device=xx:xx:xx:xx:xx:xx --addr-type=random --interactive

Aufruf und Ausgabe im gatttool:

[xx:xx:xx:xx:xx:xx][LE]> char-read-uuid 2221
handle: 0x000e 	 value: fd 03 00 00 00 00 00 00 00 00 00 00

Links:

Installieren von Bluez 5.x unter Debian

Bluez ist via apt-get nur in der Version 4.x verfügbar. Damit Bluetooth LE funktioniert ist Bluez in der Version 5.x nötig. Deshalb hier eine kurze Anleitung wie Bluez 5.18 unter Debian installiert werden kann. DIese Anleitung wurde auch auf einen Raspberry Pi erfolgreich getestet.

Benötigte Libraries installieren

sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev
libudev-dev libical-dev libreadline-dev

Aktuelle Version von Bluez herunterladen

Die aktuellste Version findet man unter https://www.kernel.org/pub/linux/bluetooth/

sudo mkdir bluez
cd bluez
sudo wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.18.tar.xz

Bluez Entpacken und installieren

tar -xvf bluez-5.18.tar.xz
cd bluez-5.18
./configure --disable-systemd
sudo make
sudo make install