2013년 8월 15일 목요일


In this page, I write an instrument to build bluez 5.8 on raspberry pi board. 
I think bluetooth 4.0 and raspberry pi are very good materials for ad-hoc researchers.
I hope this page for helping to visitors.
In this page, I assume that user account is root mode (sudo su).

1. Install


You can get recent raspberrypi OS based on debian on follow site.
  • http://www.raspberrypi.org/downloads

In that site, you can download Raspbian “wheezy”.

After download, you write img file (it appers, when you unzip the downloaded file) 
to sdcard.

You can write img file using follow command. /dev/disk4 is sdcard mount position.
It can find using "df" command. In mac, unmount partition "diskutil unmount /dev/disk4s1", first.

  • sudo dd bs=1m if=~/Desktop/2013-07-26-wheezy-raspbian.img of=/dev/disk4

In first boot, you can change original password. Default user ID is pi.

2. Setting WIFI


If you install wifi usb device to raspberry pi, you should set some flags for using it.

First, you can check wifi device works properly using "iwlist scan" command or "iwconfig" command.
If it shows nearby wifi devices, it works properly, otherwise you need other other wifi device.

You can set IP as manually change "/etc/network/interfaces" file as follow. 
SSID is your ap's ssid and password is your password. In this example, password type is psk2.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.33
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameserver 168.126.63.1
wpa-ssid "SSID"
wpa-psk password

3. Building bluez

I use bluetooth 4.0 usb device using Broadcom chipset. It is recommended using Broadcom chipset device. It works properly for using bluetooth low energy. 

You can download blues tar file in http://www.bluez.org. You can upload tar file using sftp. 
After upload file, you can find the file on /home/pi. 
You can unarchive using follow command, after login ssh shell.
  • tar xvfz bluez-5.8.tar.xz 

You need glib ,dbus, libudev,libical and readline library. Run following commands. 
  • apt-get install libglib2.0
  • apt-get install libdbus-1-dev
  • apt-get install libudev-dev
  • apt-get install libical-dev
  • apt-get install libreadline-dev

You can build using follow command. Default prefix maybe /usr/local.
If you want to install, run "make install" after following command.
  • ./configure --disable-usb --disable-systemd --prefix=/usr
  • make
Next is "make install" log text.


root@raspberrypi:/home/pi/bluez-5.8# make install
make --no-print-directory install-am
 /bin/mkdir -p '/usr/bin'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c client/bluetoothctl monitor/btmon tools/hciattach tools/hciconfig tools/hcitool tools/hcidump tools/rfcomm tools/rctest tools/l2test tools/l2ping tools/sdptool tools/ciptool tools/bccmd '/usr/bin'
libtool: install: /usr/bin/install -c client/bluetoothctl /usr/bin/bluetoothctl
libtool: install: /usr/bin/install -c monitor/btmon /usr/bin/btmon
libtool: install: /usr/bin/install -c tools/hciattach /usr/bin/hciattach
libtool: install: /usr/bin/install -c tools/hciconfig /usr/bin/hciconfig
libtool: install: /usr/bin/install -c tools/hcitool /usr/bin/hcitool
libtool: install: /usr/bin/install -c tools/hcidump /usr/bin/hcidump
libtool: install: /usr/bin/install -c tools/rfcomm /usr/bin/rfcomm
libtool: install: /usr/bin/install -c tools/rctest /usr/bin/rctest
libtool: install: /usr/bin/install -c tools/l2test /usr/bin/l2test
libtool: install: /usr/bin/install -c tools/l2ping /usr/bin/l2ping
libtool: install: /usr/bin/install -c tools/sdptool /usr/bin/sdptool
libtool: install: /usr/bin/install -c tools/ciptool /usr/bin/ciptool
libtool: install: /usr/bin/install -c tools/bccmd /usr/bin/bccmd
 /bin/mkdir -p '/usr/libexec/bluetooth'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c src/bluetoothd obexd/src/obexd '/usr/libexec/bluetooth'
libtool: install: /usr/bin/install -c src/bluetoothd /usr/libexec/bluetooth/bluetoothd
libtool: install: /usr/bin/install -c obexd/src/obexd /usr/libexec/bluetooth/obexd
 /bin/mkdir -p '/usr/lib/cups/backend'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c profiles/cups/bluetooth '/usr/lib/cups/backend'
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/man/man1'
 /usr/bin/install -c -m 644 tools/hciattach.1 tools/hciconfig.1 tools/hcitool.1 tools/hcidump.1 tools/rfcomm.1 tools/rctest.1 tools/l2ping.1 tools/sdptool.1 tools/ciptool.1 tools/bccmd.1 '/usr/share/man/man1'
 /bin/mkdir -p '/usr/share/man/man8'
 /usr/bin/install -c -m 644 src/bluetoothd.8 '/usr/share/man/man8'


Building needs a lot of time. (It takes almost one hour on my board.
Make a tar file after building. It will help to save time when needing to install again. 
Following command is moving to home directory and making tar file.

  • cd ~&& tar cvfz bluez_builded.tar ./bluez-5.8 3. Building bluez

4. Turn on bluez and bluetooth

 After finish "make install", you can run hciconfig command. If your bluetooth device works properly, following similar message will show up.

hci0: Type: BR/EDR  Bus: USB
BD Address: 00:19:0E:11:D6:29  ACL MTU: 1021:8  SCO MTU: 64:1
DOWN 
RX bytes:1520 acl:0 sco:0 events:57 errors:0
TX bytes:1946 acl:0 sco:0 commands:57 errors:0

You can turn on the device using following command.
  • hciconfig hci0 up
You can check your device MAC address using following command.
  • hcitool dev

You also needs dbus demon and obex demon for bluetooth. These demons in "/usr/libexec/" folder.
You can run deamon using following command.

  • /usr/libexec/bluetoothd&
  • /usr/libexec/obexd&

5. Conclusion

Nowadays, bluez has big changes. It seems that bluetooth low energy support. 

Any comments is ok. 

Next, I will post some sensor application on raspberry pi using BLE technology. 
If anyone knows working sensors (degree, humidity, etc) on raspberry pi, 
please recommend it to me.


Thank you visit my blog.

References


[1] http://www.bluez.org/
[2] http://www.raspberrypi.org
[3] http://i-miss-erin.blogspot.kr/2010/12/gatttool-in-bluez-over-bredr.html
[4] http://linux.die.net/man/8/hciconfig
[5] Gareth Halfacree, Eben Upton. "Raspberry Pi User Guide", John Wiley & Sons Ltd, 2012

댓글 없음:

댓글 쓰기

RPI is not good handling DHT11

Hello? This is failure story about converting c code to python. There is GPIO controlling library on Python such as RPI, wiringPI. But...