raspberrypiからPCやAndroid端末、iphoneとペアリングすることはちっとも難しくない。
ペアリングの後で接続することができないことが問題。 プロファイルって何だっけ?
Bluetooth Service のステータスを確認。
$ sudo systemctl status bluetooth.service
Sap driver initialization failed.
sap-server: Operation not permitted (1)
赤字のエラーが出ているので、/lib/systemd/system/bluetooth.serviceを編集。
–noplugin=sapを追加してエラーを無くす。
Raspberry PiでSDPサーバが使えるか確認する。
以下のようにsdptoolコマンドでローカルのサービスを確認すればよい。
pi@raspberrypi:~ $ sdptool browse local
Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory
実行するとエラー。
同じく/lib/systemd/system/bluetooth.service(/etc/systemd/system/dbus-org.bluez.serviceはlink)を編集して –compat も追加。
[Service]
Type=dbus
BusName=org.bluez
#ExecStart=/usr/lib/bluetooth/bluetoothd
ExecStart=/usr/lib/bluetooth/bluetoothd --compat --noplugin=sap
変更後、bluetoothdを再起動。
pi@raspberrypi:~ $ sudo systemctl daemon-reload
pi@raspberrypi:~ $ sudo systemctl restart bluetooth
再実行してSDPサービスの確認
pi@raspberrypi:~ $ sdptool browse local
Browsing FF:FF:FF:00:00:00 ...
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)
Profile Descriptor List:
"PnP Information" (0x1200)
Version: 0x0103
:
:
ただし、Service Name: Serial Portというサービスがない状態であることが分かる。
そのため、SPPを追加する。
sppプロファイルの追加
pi@raspberrypi:~ $ sudo sdptool add --channel=22 SP
Serial Port service registered
もう一度確認すると、最後にService Name: Serial Portが追加されていることが分かる。
pi@raspberrypi:~ $ sdptool browse local
Browsing FF:FF:FF:00:00:00 ...
Service RecHandle: 0x10000
:
:
:
Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10007
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 22
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100