Install Bluez host stack from source code for linux

Install Bluez host stack from source code for Linux


Table of Contents

  • 1 Why install Bluez5.8+?
  • 2 Install Bluez5.8 into Linux distribution
  • 3 How to start the newest Bluez stack daemon?

1 Why install Bluez5.8+?

Bluez is the host part stack running in Linux. Install the Bluetooth LE feature supported Bluez was really important during develop the Bluetooth le apps, it can run your test case on your Linux PC at least. But Why Bluez 5.8 and later version? The Bluez stack was developed so quickly during the past one years from 4.100 to 5.9, its source code's quality was really promoted a lot after those frequent releases. What's more, Bluetooth LE was officially supported after Bluez 5.0 release not just experimental features in the older version. 

The mainly Linux distribution's Bluez version, like Ubuntu13.2 or Fedora 19, still remained in 4.101, which means Bluetooth LE still in the experimental stage at the latest Linux distribution system.

2 Install Bluez5.8 into Linux distribution

Requirement: 

Kernel > 3.5
libusb-dev 
libdbus-1-dev
libglib2.0-dev
libudev-dev
libical-dev
libreadline-dev

Compile and install from the latest source code: 

./configure --prefix=/home/zxsu/software/bluez \
--exec-prefix=/home/zxsu/software/bluez --enable-debug \
--enable-library --enable-test --enable-experimental --disable-systemd \
--with-dbusconfdir=/home/zxsu/software/bluez/dbus/  --with-udevdir=/home/zxsu/software/bluez/udev/

make

make install

3 How to start the newest Bluez stack daemon?

  • stop the system's default bluez daemon.
# for ubuntu's traditional init services management system
sudo /etc/init.d/bluetooth stop

# for Fedora's latest systemd serverces management system
sudo systemctl stop bluetooth
  • start your latest bluez daemon
cd $(install_path)/libexec/bluetooth/
sudo ./bluetoothd -n -d
  • enable and test your bluez's ble feature
cd $(install_path)/bin/
# power up your hci0 device, if your have the only one 
# bluetooth adapter in your pc
./hciconfig hci0 up
./hciconfig hci0

### here is what you get.
#hci0:  Type: BR/EDR  Bus: USB
#   BD Address: 00:1A:7D:DA:71:07  ACL MTU: 310:10  SCO MTU: 64:8
#   UP RUNNING PSCAN 
#   RX bytes:1073 acl:0 sco:0 events:54 errors:0
#   TX bytes:1068 acl:0 sco:0 commands:53 errors:0

./hciconfig hci0 leadv 0

 Now, you can scan Bluetooth le devices from your Bluetooth smart ready phones like Google Nexus 4 with android 4.3 system which has an app source code located in its sdk-18's sample code -- $(SDK)/samples/android-18/legacy/BluetoothLeGatt
or, you can search Bluetooth low energy keywords in google play markets, and install one. I installed both apps into my Google Nexus 4. 

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp