[Raspberry Pi 3]Bluetoothを使う
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $ sudo apt-get update #Bluetoothのパッケージをインストール $ sudo apt-get install bluetooth pi-bluetooth #関連パッケージのインストール $ sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libdbus-glib-1-dev libbluetooth-dev python-dev #BlueZのインストール $ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.45.tar.xz $ xz -dv bluez-5.45.tar.xz $ tar -xf bluez-5.45.tar $ cd bluez-5.45/ $ ./configure --enable-experimental $ make -j4 $ sudo make install $ sudo pip install pybluez #BlueZのサービスを開始 $ sudo systemctl start bluetooth #起動時からこのサービスを開始させたい時は以下のコマンドを走らせておく。 $ sudo systemctl enable bluetooth |
再起動して、起動しているか確認して、起動していればおっけー
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $ sudo systemctl status bluetooth ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: inactive (dead) since Wed 2018-11-14 12:29:46 JST; 13s ago Docs: man:bluetoothd(8) Main PID: 441 (code=exited, status=0/SUCCESS) Status: "Quitting" 11月 14 12:19:35 rpi-i2c bluetoothd[441]: Bluetooth daemon 5.43 11月 14 12:19:35 rpi-i2c bluetoothd[441]: Starting SDP server 11月 14 12:19:35 rpi-i2c systemd[1]: Started Bluetooth service. 11月 14 12:19:36 rpi-i2c bluetoothd[441]: Bluetooth management interface 1.14 initialized 11月 14 12:19:36 rpi-i2c bluetoothd[441]: Failed to obtain handles for "Service Changed" characteristic 11月 14 12:19:36 rpi-i2c bluetoothd[441]: Sap driver initialization failed. 11月 14 12:19:36 rpi-i2c bluetoothd[441]: sap-server: Operation not permitted (1) 11月 14 12:29:46 rpi-i2c bluetoothd[441]: Terminating 11月 14 12:29:46 rpi-i2c systemd[1]: Stopping Bluetooth service... 11月 14 12:29:46 rpi-i2c systemd[1]: Stopped Bluetooth service. |
今回はこういうエラーが出て停止していたので、
「/lib/systemd/system/bluetooth.service」の、「ExecStart=/usr/lib/bluetooth/bluetoothd」というところを、「ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap」と書き換え、サービスを立ち上げ直す。
1 2 | $ sudo systemctl daemon-reload $ systemctl status bluetooth |
これで今度は動いた。
まだ「Failed to obtain handles for "Service Changed" characteristic」のエラーが消えないっぽいけど、無視しても動いている…(汗)
この記事へのコメントはこちら