つれづれなるまゝに

単なる作業メモ。主に、Linux, arduino, raspberry piとか?

Bluetooth LEをつかってみるの巻 その1

2014-06-20 21:43:14 | raspberry pi
Bluetooth LEの開発キットを買ったので、使う前にBluetooth LEをいじって勉強してみようと思う。
あ、買う前に勉強するのが正しい順番かな?^^;

まずは、Rasberry piでBlueZを使って繋いでみる。

以下のページを参考にした。
Raspberry Pi で iBeacon を試してみよう!

Bluetoothのドングルはいくつかもってるが、BLEに対応したものはもってなかったのでAmazonで購入。木曜の夜注文して、金曜日の夜には届いてるAmazonプライムは毎度便利だなぁ。


何を買おうか少し悩んだが、やっぱり実績のあるものということで、PlanexのBT-Micro4を購入。

とりあえず差し込んでlsusb。

Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

CSRのもののようです。ちなみに、CSRはWindows8だとドライバ・スタックがダメダメとの噂ですが、Linuxで使うから気にしないと。



USBの上にささってるのがBLEドングル。下のはWifi。このraspberry piは出張時には持ち運んでホテルではwifiルータとしてiPad airを繋いで使っています。

BLEのサポートはバージョン5.0から。今、パッケージで入っているのは4.x系だと思うので、ソースからコンパイルする必要がある。

元記事だと、BlueZのバージョンは5.9ですが、最新は5.19なので、それを使ってみる。吉とでるか凶とでるか。。。

./configure、makeは通った。(20、30分くらいかかる)

さて、あとは入れ替えをどうするか。

ひとまず、

$apt-cache show bluez

Package: bluez
Version: 4.99-2
Architecture: armhf
Maintainer: Debian Bluetooth Maintainers <pkg-bluetooth-maintainers@lists.alioth.debian.org>
Installed-Size: 2026
Depends: libc6 (>= 2.13-28), libcap-ng0, libdbus-1-3 (>= 1.1.1), libglib2.0-0 (>= 2.30.0), libreadline6 (>= 6.0), libudev0 (>= 0.140), libusb-0.1-4 (>= 2:0.1.12), kmod, udev (>= 170-1), lsb-base, dbus, python-gi, python-dbus
Conflicts: bluez-audio (<= 3.36-3), bluez-utils (<= 3.36-3)
Breaks: udev (<< 170-1)
Replaces: bluez-audio (<= 3.36-3), bluez-input, bluez-network, bluez-serial, bluez-utils (<= 3.36-3), udev (<< 170-1)
・・・


おそらく、インストール時は、
sudo apt-get install bluetooth
sudo apt-get install bluez-utils
で2つのパッケージを入れていると思う。(インストール時のことをブログに書きわすれているorz)

$apt-cache showpkg bluez-utils
Package: bluez-utils
Versions:
4.99-2 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages) (/var/lib/dpkg/status)
Description Language:
File: /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages
MD5: 6ef88753dc2a3bf4dc73772736476091


Reverse Depends:
obexpushd,bluez-utils
education-laptop,bluez-utils
bluez,bluez-utils 3.36-3
bluez,bluez-utils 3.36-3
Dependencies:
4.99-2 - bluetooth (0 (null))
Provides:
4.99-2 -
Reverse Provides:


$ apt-cache showpkg bluez
Package: bluez
Versions:
4.99-2 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages) (/var/lib/dpkg/status)
Description Language:
File: /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages
MD5: ef25d6a9f4a57e78f32faa7b58ef4e59


Reverse Depends:
syncevolution,bluez
sync-ui,bluez
pulseaudio-module-bluetooth,bluez 4.40
libpam-blue,bluez
kanyremote,bluez
gnome-bluetooth,bluez 4.36
connman,bluez
bluez-gstreamer,bluez
bluez-dbg,bluez 4.99-2
bluez-alsa,bluez
bluetooth,bluez
bluemon,bluez
blueman,bluez 4.25
bluedevil,bluez
Dependencies:
4.99-2 - libc6 (2 2.13-28) libcap-ng0 (0 (null)) libdbus-1-3 (2 1.1.1) libglib2.0-0 (2 2.30.0) libreadline6 (2 6.0) libudev0 (2 0.140) libusb-0.1-4 (2 2:0.1.12) kmod (0 (null)) udev (2 170-1) lsb-base (0 (null)) dbus (0 (null)) python-gi (0 (null)) python-dbus (0 (null)) bluez-audio (1 3.36-3) bluez-utils (1 3.36-3) udev (3 170-1) bluez-audio (1 3.36-3) bluez-input (0 (null)) bluez-network (0 (null)) bluez-serial (0 (null)) bluez-utils (1 3.36-3) udev (3 170-1)
Provides:
4.99-2 -
Reverse Provides:

とりあえず、bluez-utilsとbluezあたりをアンインストールしておこう。

pi@raspberrypi ~ $ sudo apt-get remove bluez-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
bluez-utils
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 72.7 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 74257 files and directories currently installed.)
Removing bluez-utils ...

pi@raspberrypi ~ $ sudo apt-get remove bluez
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
bluez-cups libcap-ng0 libpulse-mainloop-glib0 python-gconf
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
blueman bluetooth bluez bluez-alsa bluez-gstreamer
0 upgraded, 0 newly installed, 5 to remove and 1 not upgraded.
After this operation, 5,422 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 74248 files and directories currently installed.)
Removing blueman ...
Removing bluetooth ...
Removing bluez-gstreamer ...
Removing bluez-alsa:armhf ...
Removing bluez ...
[ ok ] Stopping bluetooth: rfcomm /usr/sbin/bluetoothd.
Processing triggers for man-db ...
Processing triggers for desktop-file-utils ...
Processing triggers for hicolor-icon-theme ...

$ dpkg -l | grep bluez
rc bluez 4.99-2 armhf Bluetooth tools and daemons
ii bluez-compat 4.99-2 armhf BlueZ 3.x compatibility binaries
ii bluez-cups 4.99-2 armhf Bluetooth printer driver for CUPS

ということなので、bluez-compatとbluez-cupsも削除。あと、bluezは、

$ sudo apt-get --purge remove bluez

で設定ファイルもきれいに削除。

でもってmake installと。

あとは参考記事を元に動作確認。。。ビーコンをみつけられないorz

hciscan とかでiPhoneを見つけたので、まったく動いてないわけではなさそうだが、、、

今日はここまで。