記事一覧

Raspberry Pi Zero WでBluetooth経由でシリアル通信(シリアル接続)実はうまく行ってません

Raspberry Pi Zero WでBluetooth経由でシリアル通信(シリアル接続)実はうまく行ってません



RoboTakaoです。ようこそ「極力ローコスト ロボット製作 ブログ」にお越しくださいました。

前回はペアリングまで行いました。

bluetooth12.png


今回は実際にMacとRaspberry Pi Zero Wをシリアル接続したいのですが、ネットで拾って来た情報ではうまくいっていません。

環境
Raspberry Pi Zero W Raspbian Jessie
Mac OS El Capitan 10.11.6

sdptoolでの確認
まずペアリング出来ている前提でsdptoolを確認

pi@raspberrypi:~ $ sdptool browse local
Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory

予定通りエラーが出る。

以下のファイルを修正

pi@raspberrypi:~ $ nano /etc/systemd/system/dbus-org.bluez.service

下の行を変更

ExecStart=/usr/lib/bluetooth/bluetoothd

変更後

ExecStart=/usr/lib/bluetooth/bluetoothd --compat

bluetoothdの再起動
pi@raspberrypi:/ $ sudo systemctl daemon-reload
pi@raspberrypi:/ $ sudo systemctl restart bluetooth

もう一回sdptoolで確認
pi@raspberrypi:/ $ sdptool browse local
Failed to connect to SDP server on FF:FF:FF:00:00:00: Permission denied

予定通りパーミッションエラー
パーミッションを変更

pi@raspberrypi:/ $ sudo chmod 777 /var/run/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

Browsing FF:FF:FF:00:00:00 ...
Service Search failed: Invalid argument
Service Name: Generic Access Profile
Service Provider: BlueZ
Service RecHandle: 0x10001
Service Class ID List:
"Generic Access" (0x1800)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 31
"ATT" (0x0007)
uint16: 0x0001
uint16: 0x0008

Service Name: Generic Attribute Profile
Service Provider: BlueZ
Service RecHandle: 0x10002
Service Class ID List:
"Generic Attribute" (0x1801)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 31
"ATT" (0x0007)
uint16: 0x0010
uint16: 0x0010

Service Name: AVRCP CT
Service RecHandle: 0x10003
Service Class ID List:
"AV Remote" (0x110e)
"AV Remote Controller" (0x110f)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x0103
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0105

Service Name: AVRCP TG
Service RecHandle: 0x10004
Service Class ID List:
"AV Remote Target" (0x110c)
Protocol Descriptor List:
"L2CAP" (0x0100)
PSM: 23
"AVCTP" (0x0017)
uint16: 0x0103
Profile Descriptor List:
"AV Remote" (0x110e)
Version: 0x0104


シリアルポートの登録
pi@raspberrypi:/ $ sudo sdptool add --channel=22 SP
Serial Port service registered

再度確認
pi@raspberrypi:/ $ sdptool browse local

最初省略

Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10005
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

シリアルポートが登録できていることがわかった。

rfcommでlistenで待機
pi@raspberrypi:/ $ sudo rfcomm listen /dev/rfcomm0 22
Waiting for connection on channel 22

こっから先うんともすんとも行きません。

Mac側で環境設定のbluetoothで見てもペアリングは下が未接続のまま

さっぱりわかりません。誰か助けてください。

それでは今回はこの辺で失礼します!ありがとうございます。


スポンサードリンク

コメント

コメントの投稿

非公開コメント

プロフィール

RoboTakao

Author:RoboTakao
みなさんご訪問ありがとうございます。ロボット作りたいけどお小遣いそんなにないし、簡単でローコストでロボットを作るための私のプロジェクトを紹介します。

ウェブサイトもありますのでそちらもよろしくお願いします。
http://robotakao.jp/

スポンサーリンク