I've been playing with Bluetooth and have had some success.
I started with Debian snapshot 132. If flashed the boot partition with boot-fat.img and the system partition with hikey-jessie_developer_20150319-132.img. This gave me a Debian Jessie console image. The Debian Jessie image uses BlueZ 5.23 on the HiKey, and there are not a lot of instructions on the internet for using BlueZ5. BlueZ4 and BlueZ5 are quite different, many of the utilities in BlueZ4 no longer exist.
Snapshot 132 allows you to power on the BT radio and discover devices. You can also pair the HiKey with most devices. However the kernel in snapshot 132 does not support BT HID devices. We need to alter the kernel configuration to build BT HID support as a module, and install it on the images (see the attached patch). I rebuilt the kernel, and the boot-fat.image with it and flashed. I also had to rebuild the system partition with modules to match my kernel and flash it into the system partition.
Once I did that the following works:
Setup Bluetooth Keyboard ------------------------------------------
$ sudo su # bluetoothctl -a [bluetooth]# power on [bluetooth]# agent KeyboardOnly [bluetooth]# default-agent [bluetooth]# pairable on [bluetooth]# scan on [bluetooth]# pair 01:02:03:04:05:06 [bluetooth]# trust 01:02:03:04:05:06 [bluetooth]# connect 01:02:03:04:05:06 [bluetooth]# quit
After this I can type and see characters on the HDMI console. If the keyboard disconnects due to power off I had to run bluetoothctl and connect again. To fix this:
Create file: /etc/bluetooth-keyboard.conf with the following contents # Config file for bluetooth-keyboard.service # Set BTKBDMAC to the Bluetooth address of your keyboard. # Using built in TI WiLink Bluetooth, device is hci0 BTKBDMAC = 00:1F:20:24:B2:EF HCIDEVICE = hci0
Create file: /etc/systemd/system/bluetooth-keyboard.service with the following contents [Unit] Description=Automatically connect to a Bluetooth keyboard Documentation=https://wiki.archlinux.org/index.php/Bluetooth_Keyboard Requires=dbus-org.bluez.service After=dbus-bluez.org.service ConditionPathExists=/etc/bluetooth-keyboard.conf ConditionPathExists=/usr/bin/hcitool ConditionPathExists=/usr/bin/hciconfig
[Service] Type=oneshot EnvironmentFile=/etc/bluetooth-keyboard.conf ExecStart= ExecStart=/usr/bin/hciconfig ${HCIDEVICE} up # Ignore errors on connect, spurious problems seem to occur with Bluetooth? Start next command with - to ignore the errors. ExecStart=-/usr/bin/hcitool cc ${BTKBDMAC}
After this I did the following: # systemctl daemon-reload # systemctl start pulseaudio.service
Now the keyboard connects when disconnected and a key is pressed reliably. After a reboot, I can login on the HDMI console using the Bluetooth keyboard.
References: https://wiki.archlinux.org/index.php/bluetooth_keyboard
Setup Bluetooth Audio --------------------------------------------------
As I said before Debian Jessie uses BlueZ 5.23. Unfortunately BlueZ5 dropped support for ALSA. This means we have to use PulseAudio for Bluetooth audio support. Debian Jessie uses PulseAudio 5 on the HiKey. At present, PulseAudio 5 only supports the A2DP Bluetooth profile and not the HSP/HFP Bluetooth profiles (at least according to the reference). The latter profiles are apparently under development. To get Bluetooth audio working on my HiKey I did the following:
$ sudo su # apt-get install --no-install-recommends pulseaudio pulseaudio-module-bluetooth
Create file: /etc/systemd/system/pulseaudio.service with the following contents [Unit] Description=Pulse Audio
[Service] Type=simple ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm
[Install] WantedBy=multi-user.target
Create file: /etc/dbus-1/system.d/pulseaudio-bluetooth.conf with the following contents <busconfig> <policy user="pulse"> <allow send_destination="org.bluez"/> </policy> </busconfig>
Append to file: /etc/pulse/system.pa ### Automatically load driver modules for Bluetooth hardware .ifexists module-bluetooth-policy.so load-module module-bluetooth-policy .endif
.ifexists module-bluetooth-discover.so load-module module-bluetooth-discover .endif
Add user linaro to pulse-access group #id linaro uid=1000(linaro) gid=1000(linaro) groups=1000(linaro),4(adm),20(dialout),24(cdrom),29(audio),30(dip),44(video),46(plugdev),1001(admin) # usermod -a -G pulse-access # id linaro uid=1000(linaro) gid=1000(linaro) groups=1000(linaro),4(adm),20(dialout),24(cdrom),29(audio),30(dip),44(video),46(plugdev),1001(admin),115(pulse-access)
Now need to start up PulseAudio # systemctl daemon-reload # systemctl start pulseaudio.service
Now need to pair and connect to the Bluetooth speaker. Pairing only needs to be done once.
# bluetoothctl [bluetooth]# agent on [bluetooth]# default-agent [bluetooth]# scan on [bluetooth]# pair A0:E9:DB:5C:FA:67 [bluetooth]# trust A0:E9:DB:5C:FA:67 [bluetooth]# connect A0:E9:DB:5C:FA:67 [bluetooth]# quit # exit
Now connected to Bluetooth speaker, and user linaro should be able to use PulseAudio. Now list devices in PulseAudio.
$ pactl list
The output for me near the end looks like this.
Card #0 Name: bluez_card.A0_E9_DB_5C_FA_67 Driver: module-bluez5-device.c Owner Module: 14 Properties: device.description = "Nude Super-M" device.string = "A0:E9:DB:5C:FA:67" device.api = "bluez" device.class = "sound" device.bus = "bluetooth" device.form_factor = "headset" bluez.path = "/org/bluez/hci0/dev_A0_E9_DB_5C_FA_67" bluez.class = "0x240404" bluez.alias = "Nude Super-M" device.icon_name = "audio-headset-bluetooth" device.intended_roles = "phone" Profiles: a2dp: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes) off: Off (sinks: 0, sources: 0, priority: 0, available: yes) Active Profile: a2dp Ports: headset-output: Headset (priority: 0, latency offset: 0 usec) Part of profile(s): a2dp headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
If the active profile isn't A2DP, then set it
$ pactl set-card-profile 0 a2dp
Should now be able to play a sound and hear it on speaker.
$ paplay -d bluez_sink.A0_E9_DB_5C_FA_67 /usr/share/sounds/alsa/Front_Center.wav
References: https://github.com/ev3dev/ev3dev/issues/198