「Bluez4」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(Pkg/AUR テンプレートの更新)
(文字列「http://wiki.gentoo.org/」を「https://wiki.gentoo.org/」に置換)
366行目: 366行目:
 
Pair again your device, and you should find it in the pulseaudio settings (advanced settings for the sound)
 
Pair again your device, and you should find it in the pulseaudio settings (advanced settings for the sound)
   
[http://wiki.gentoo.org/index.php?title=Bluetooth_Headset&redirect=no More information on Gentoo Wiki]
+
[https://wiki.gentoo.org/index.php?title=Bluetooth_Headset&redirect=no More information on Gentoo Wiki]
   
 
If after fixing this you still can't get sound, try using blueman (this is the only one that works for me), make sure that notify-osd is installed or it might show you weird error messages like this one: "Stream setup failed"
 
If after fixing this you still can't get sound, try using blueman (this is the only one that works for me), make sure that notify-osd is installed or it might show you weird error messages like this one: "Stream setup failed"

2018年2月6日 (火) 23:08時点における版

関連記事

Bluez4 は Linux の bluetooth スタックの旧バージョンです。bluetooth スタックの最新バージョン (Bluez5) の情報は Bluetooth の記事を見て下さい。

インストール

警告: Bluez4 はメンテナンスされていません。Bluez5 によって置き換えられているからです。可能であれば、Bluez5 を使うようにしてください。

Bluez4 は AUR の bluez4AUR[リンク切れ: アーカイブ: aur-mirror] パッケージでインストールできます。bluetooth デーモンを起動してください:

# systemctl start bluetooth

起動時にデーモンを実行するには次のコマンドを使用:

# systemctl enable bluetooth

bluez4 でペアリング

携帯端末とペアリングする手順は以下の通りです:

  • コンピュータから携帯端末に接続リクエストを送信します。
  • コンピュータによって決定された PIN を携帯端末で入力します。
  • 同じキーをコンピュータでも、もう一度入力します。

gnome-bluez パッケージを使わずにデバイスをペアリングしたい場合、bluez パッケージに付属している bluez-simple-agent ユーティリティを使うことができます。このユーティリティを使うには公式リポジトリから以下の3つのパッケージをインストールする必要があります: python2-dbus python2-gobject2 dbus-glib

まず、外部のデバイスをスキャン:

$ hcitool scan

root でスクリプトを実行:

# bluez-simple-agent

"Agent registered" というメッセージが返ってくるので、Ctrl+c を押して終了してください。

以下は特定のデバイスとペアリングする例です。パスコードが要求されるので、コードを入力してエンターを押して下さい。

# bluez-simple-agent hci0 00:11:22:33:AA:BB
ノート: bluez-simple-agent が必要なのはデバイスをペアリングするときだけで、接続するたびに実行する必要はありません。

様々なデバイスのペアリング例が以下のサンプルセクションにあります。

サンプル

Siemens S55

ノート: It has not yet been determined whether the connection can be initiated from the phone.
  • The steps under installation
$ hcitool scan
Scanning ...
        XX:XX:XX:XX:XX:XX  NAME
$ B=XX:XX:XX:XX:XX:XX

Start the simple-agent in a second terminal:

$ su -c bluez-simple-agent
Password: 
Agent registered

Back to the first console:

$ obexftp -b $B -l "Address book"
# Phone ask for pin, I enter it and answer yes when asked if I want to save the device
...
<file name="5F07.adr" size="78712" modified="20030101T001858" user-perm="WD" group-perm="" />
...
$ obexftp -b 00:01:E3:6B:FF:D7 -g "Address book/5F07.adr"
Browsing 00:01:E3:6B:FF:D7 ...
Channel: 5
Connecting...done
Receiving "Address book/5F07.adr"... Sending "Address book"... done
Disconnecting...done
$ obexftp -b 00:01:E3:6B:FF:D7 -p a
...
Sending "a"... done
Disconnecting...done

Motorola V900

After installing Blueman and running blueman-applet, click "find me" under connections > bluetooth in Motorola device. In blueman-applet, scan devices, find the Motorola, click "add". Click "bond" in blueman-applet, enter some PIN, enter the same PIN in Motorola when it asks. In terminal:

$ mkdir ~/bluetooth-temp
$ obexfs -n XX:XX:XX:XX:XX:XX ~/bluetooth-temp
$ cd ~/bluetooth-temp

and browse... Only audio, video, and pictures are available when you do this.

Motorola RAZ

obextoolAUR obexfsAUR obexftpAUR openobexAUR bluez をインストールしてください。

# lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 03f0:171d Hewlett-Packard Wireless (Bluetooth + WLAN) Interface [Integrated Module]
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
# hciconfig hci0 up
# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:16:41:97:BA:5E  ACL MTU: 1017:8  SCO MTU: 64:8
        UP RUNNING
        RX bytes:348 acl:0 sco:0 events:11 errors:0
        TX bytes:38 acl:0 sco:0 commands:11 errors:0
# hcitool dev
Devices:
        hci0    00:16:41:97:BA:5E

Make sure that bluetooth on your phone is enabled and your phone is visible!

# hcitool scan
Scanning ...
        00:1A:1B:82:9B:6D       [quirxi]
# hcitool inq
Inquiring ...
        00:1A:1B:82:9B:6D       clock offset: 0x1ee4    class: 0x522204
# l2ping 00:1A:1B:82:9B:6D
Ping: 00:1A:1B:82:9B:6D from 00:16:41:97:BA:5E (data size 44) ...
44 bytes from 00:1A:1B:82:9B:6D id 0 time 23.94ms
44 bytes from 00:1A:1B:82:9B:6D id 1 time 18.85ms
44 bytes from 00:1A:1B:82:9B:6D id 2 time 30.88ms
44 bytes from 00:1A:1B:82:9B:6D id 3 time 18.88ms
44 bytes from 00:1A:1B:82:9B:6D id 4 time 17.88ms
44 bytes from 00:1A:1B:82:9B:6D id 5 time 17.88ms
6 sent, 6 received, 0% loss
# hcitool name 00:1A:1B:82:9B:6D
[quirxi]
# hciconfig -a hci0
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:16:41:97:BA:5E  ACL MTU: 1017:8  SCO MTU: 64:8
        UP RUNNING
        RX bytes:9740 acl:122 sco:0 events:170 errors:0
        TX bytes:2920 acl:125 sco:0 commands:53 errors:0
        Features: 0xff 0xff 0x8d 0xfe 0x9b 0xf9 0x00 0x80
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
        Link policy:
        Link mode: SLAVE ACCEPT
        Name: 'BCM2045'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous,
        HCI Version: 2.0 (0x3)  Revision: 0x204a
        LMP Version: 2.0 (0x3)  Subversion: 0x4176
        Manufacturer: Broadcoml / Corporation (15)
# hcitool info 00:1A:1B:82:9B:6D
Requesting information ...
        BD Address:  00:1A:1B:82:9B:6D
        Device Name: [quirxi]
        LMP Version: 1.2 (0x2) LMP Subversion: 0x309
        Manufacturer: Broadcom Corporation (15)
        Features: 0xff 0xfe 0x0d 0x00 0x08 0x08 0x00 0x00
                <3-slot packets> <5-slot packets> <encryption> <slot offset>
                <timing accuracy> <role switch> <hold mode> <sniff mode>
                <RSSI> <channel quality> <SCO link> <HV2 packets>
                <HV3 packets> <A-law log> <CVSD> <power control>
                <transparent SCO> <AFH cap. slave> <AFH cap. master>

Edit your /etc/bluetooth/main.conf and enter the proper class for your phone ( Class = 0x100100 ):

# Default device class. Only the major and minor device class bits are
# considered.
#Class = 0x000100
Class =  0x100100
# systemctl start bluetooth
:: Stopping bluetooth subsystem:  pand dund rfcomm hidd  bluetoothd
[DONE]
:: Starting bluetooth subsystem:  bluetoothd

Pairing with bluez-simple-agent only has to be done once. On your Motorola phone give 0000 in as your PIN when phone asks for it!

/usr/bin/bluez-simple-agent hci0 00:1A:1B:82:9B:6D
RequestPinCode (/org/bluez/10768/hci0/dev_00_1A_1B_82_9B_6D)
Enter PIN Code: 0000
Release
New device (/org/bluez/10768/hci0/dev_00_1A_1B_82_9B_6D)

Now you can browse the filesystem of your phone with obexftp:

obexftp -v -b 00:1A:1B:82:9B:6D -B 9 -l
Connecting..\done
Tried to connect for 448ms
Receiving "(null)"...-<?xml version="1.0" ?>
<!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd">
<folder-listing>
<parent-folder />
<folder name="audio" size="0" type="folder" modified="20101010T132323Z" user-perm="RW" />
<folder name="video" size="0" type="folder" modified="20101010T132323Z" user-perm="RW" />
<folder name="picture" size="0" type="folder" modified="20101010T132323Z" user-perm="RW" />
</folder-listing>
done
Disconnecting..\done

Or you can mount your phone into a directory on your computer and treat it like a normal file system:

# groupadd bluetooth
# mkdir /mnt/bluetooth
# chown root:bluetooth /mnt/bluetooth
# chmod 775 /mnt/bluetooth
# usermod -a -G bluetooth arno
# obexfs -b 00:1A:1B:82:9B:6D /mnt/bluetooth/

bluez-simple-agent を使って iPhone とペアリング

Assuming a bluetooth device called hci0 and an iPhone that showed up in a hcitool scan as '00:00:DE:AD:BE:EF':

# bluez-simple-agent hci0 00:00:DE:AD:BE:EF
Passcode:

Logitech mouse MX Laser / M555b

接続をテストするには:

$ hidd --connect XX:XX:XX:XX:XX:XX

自動で再接続されるようにするには、デスクトップウィザードを使って bluetooth マウスを設定します。あなたの使っているデスクトップ環境が bluetooth マウスをサポートしていない場合は、Bluetooth マウスの記事を読んで下さい。

ヘッドセットと ALSA デバイス

asound.conf に bluetooth デバイスを記述

1. デバイスをスキャン:

$ hcitool (-i optional hci#***) scan

2. ヘッドセットとデバイスをペアリング:

$ bluez-simple-agent (optional hci# ***) XX:XX:XX:XX:XX:XX
  and put in your PIN (0000 or 1234, etc)

3. 以下を /etc/asound.conf ファイルに追加:

pcm.btheadset {
   type plug
   slave {
       pcm {
           type bluetooth
           device XX:XX:XX:XX:XX:XX
           profile "auto"
       }
   }
   hint {
       show on
       description "BT Headset"
   }
}
ctl.btheadset {
  type bluetooth
}

4. ALSA デバイスに追加されたことを確認:

$ aplay -L

5. aplay で再生:

$ aplay -D btheadset /path/to/audio/file

または MPlayer を使って:

$ mplayer -ao alsa:device=btheadset /path/to/audio/or/video/file

USB ドングルの hci# を確認するには、次を実行:

$ hcitool dev

AUR の bluez-tools を使う

You can use bluez-toolsAUR from the AUR with PulseAudio to stream audio to a bluetooth headset. Find the MAC of the headset:

$ hcitool scan

Connect to the headset:

$ bt-audio -c XX:XX:XX:XX:XX:XX

Open pulseaudio volume control:

$ pavucontrol

The headset should show up in the Configuration tab.

Microsoft Bluetooth Mobile Keyboard 6000

1. Scan for your device

$ hcitool (-i optional_hci#***) scan
Scanning ...
       00:11:22:33:44:55       Microsoft Bluetooth Mobile Keyboard 6000

2. On second console run as root (do not terminate):

# bluez-simple-agent
Agent registered

3. Back on first console run:

$ bluez-simple-agent hci0 00:11:22:33:44:55
Enter PIN Code: 1234
(now enter that PIN on the keyboard and press enter)
Release
New device (/org/bluez/5373/hci0/dev_00_11_22_33_44_55)

4.

$ bluez-test-device trusted 00:11:22:33:44:55

5.

$ bluez-test-input connect 00:11:22:33:44:55

No your keyboard should work. You can terminate bluez-simple-agent on second console with Ctrl+C

トラブルシューティング

passkey-agent

$ passkey-agent --default 1234
Can't register passkey agent
The name org.bluez was not provided by any .service files

and

$ hciconfig dev
# (no listing)

Try running hciconfig hc0 up

Sennheiser MM400 ヘッドセットに接続できない

If your Sennheiser MM400 Headset immediately disconnects after connecting as Headset Service with Blueman, try to connect it as Audio Sink. Afterwards you can change the headset's Audio Profile to Telephony Duplex with a right click in Blueman. With this option headset functionality will be available although the headset was only connected as Audio Sink in first place and no disconnection will happen (tested with bluez 4.96-3, pulseaudio 1.1-1 and blueman 1.23-2).

ペアリングしても音が流れない

Try to first inspect /var/log/messages.log. If you see such messages:

Jan 12 20:08:58 localhost pulseaudio[1584]: [pulseaudio] module-bluetooth-device.c: Service not connected
Jan 12 20:08:58 localhost pulseaudio[1584]: [pulseaudio] module-bluetooth-device.c: Bluetooth audio service not available

try first:

# pactl load-module module-bluetooth-device
# pactl load-module module-bluetooth-discover

or, if those modules cannot be found:

# pactl load-module module-bluez4-device
# pactl load-module module-bluez4-discover

If the module fails to work, do this workaround: Open /etc/bluetooth/audio.conf and add after [General] (on a new line)

Enable=Socket

Then restart the bluetooth daemon. Pair again your device, and you should find it in the pulseaudio settings (advanced settings for the sound)

More information on Gentoo Wiki

If after fixing this you still can't get sound, try using blueman (this is the only one that works for me), make sure that notify-osd is installed or it might show you weird error messages like this one: "Stream setup failed"

fail (/usr/lib/python2.7/site-packages/blueman/gui/manager/ManagerDeviceMenu.py:134)
fail (DBusException(dbus.String(u'Stream setup failed'),),)

参照