Bluetoothを試す
ネットで人気のPlanex社の「BT-Micro4 Bluetooth Ver.4.0+EDR/LE対応 小型USBアダプタ」を購入。
Raspberry Pi • View topic - Bluetooth audio streaming
を参考にし、
最終的に、音が出るまで至ったが、あれこれ模索したため、何が本当に必要だったのかわからない。
bluetooth bluez などインストール
~# apt-get install apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2
/etc/bluetooth/audio.conf
の [General] section
に、
Enable=Source,Sink,Media,Socket
を足すらしい。
hciconfig
# hciconfig hci0: Type: BR/EDR Bus: USB BD Address: ??:??:??:??:??:?? ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:5632 acl:0 sco:0 events:138 errors:0 TX bytes:1325 acl:0 sco:0 commands:78 errors:0
hcitool
# hcitool -h hcitool - HCI Tool ver 4.99 Usage: hcitool [options] <command> [command parameters] Options: --help Display help -i dev HCI device Commands: dev Display local devices inq Inquire remote devices scan Scan for remote devices name Get name from remote device info Get information from remote device spinq Start periodic inquiry epinq Exit periodic inquiry cmd Submit arbitrary HCI commands con Display active connections cc Create connection to remote device dc Disconnect from remote device sr Switch master/slave role cpt Change connection packet type rssi Display connection RSSI lq Display link quality tpl Display transmit power level afh Display AFH channel map lp Set/display link policy settings lst Set/display link supervision timeout auth Request authentication enc Set connection encryption key Change connection link key clkoff Read clock offset clock Read local or remote clock lescan Start LE scan lewladd Add device to LE White List lewlrm Remove device from LE White List lewlsz Read size of LE White List lewlclr Clear LE White list lecc Create a LE Connection ledc Disconnect a LE Connection lecup LE Connection Update For more information on the usage of each command use: hcitool <command> --help
~# hcitool scan Scanning ... ??:??:??:??:??:?? Anker SoundCore
# vi /usr/bin/bluez-simple-agent
のコマンドでペアリング行って、 別のコマンドで trust しておいたりする。
~/.asoundrc に下記を足しておく。
pcm.bluetooth { type bluetooth device "___MACADDR___" profile "auto" }
実際に利用するには、
mplayer -ao alsa:device=bluetooth jazz_funk_01.mp3
や
date +"%I時%M分%S秒" | /usr/local/etc/aquestalkpi/AquesTalkPi -g 100 -f -| aplay -Dplug:bluetooth
音はなるのだが、鳴らしたい音の最初と最後がカットされる印象がある。
知らなかったのだが、どうも、Bluetoothで音を飛ばすと、そういうふうにされるらしい。
なので、
date +"a %I時%M分%S秒 a" | /usr/local/etc/aquestalkpi/AquesTalkPi -g 100 -f -| aplay -Dplug:bluetooth
などと、カットされる部分を最初から入れておくと、狙ったとおりに成るっちゃなる。かっこわるけど。
キーボードとマウス
無線のキーボードとマウスを試したかったのだが、どうも、自分でドングルに設定するには、初期設定には結局有線が必要だったりするので、
ロジクールの Unifyingレシーバー で最初からペアリングしておくと、楽らしい。
なるほど、と、調べてみると、最初からセットに成っている商品も有ったりして、買ってみたら、刺すだけで動いて楽ちん。
ここからさらに Bluetoothデバイスを増やすとなると、結局ドングルが登場するのだが、、、まぁ、その時考えよう。