Setup Minidlna omxplayer bluetooth on RPi
Install minidlna by sudo apt-get install minidlna
Changes in /etc/minidlna.conf
1 | media_dir=/home/pi/minidlna |
Restart minidlna,
sudo systemctl restart minidlna
sudo service minidlna start
sudo /etc/init.d/minidlna start
sudo service minidlna status -l
sudo systemctl status minidlna -l
http://mkitby.com/2015/11/09/raspberry-pi-nas-upnp-dlna/
http://cheng-min-i-taiwan.blogspot.hk/2013/02/raspberry-pi-dlna.html
Install the command line media player by sudo apt-get install omxplayer
, then play the music from ssh command line.
Control the playback via such app “OMX Remote” or “Raspicast” which can be download from google play.
https://codeyarns.com/2016/09/09/how-to-cast-to-raspberry-pi-using-raspicast/
https://codeyarns.com/2016/03/20/omxplayer/
https://codeyarns.com/2016/09/09/omx-remote/
Connect to bluetooth speaker
1 | hcitool dev |
Play music with the bluetooth speaker(Phillips BT3000) using A2DP profile
Check if pulseaudio is running (Reference https://wiki.archlinux.org/index.php/PulseAudio_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87))
1
2
3
4
5ps aux | grep pulseaudio
=>
/usr/bin/start-pulseaudio-X11
pulseaudio --start
(PulseAudio would run along with X11 desktop startup)List the sound cards
pacmd list-cards
. Test audio output of left and right channalspeaker-test -c 2
List the audio output
pacmd list-sinks
orpactl list sinks short
. Check the default audio sinkaplay -L
List the audio input
pacmd list-sources
orpactl list sources short
Set the Bluetooth speaker becomes default sink
pacmd set-default-sink 1
(index 1 is like bluez_sink.xx_xx_xx_xx_xx_xx)Turn up the PulseAudio volume
pacmd set-sink-volume 0 65537
Or turn up the ALSA volumeamixer set Master 100%
oramixer cset numid=3 100%
Reference:
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi
http://www.crazy-audio.com/2014/09/pulseaudio-on-the-raspbery-pi/Show soundcard information
aplay -L
oraplay -l
, play a musicaplay -v -V stereo HANA.mp3
Stream music to RPi from mobile phone connecting with bluetooth (Optional, maybe RPi can automatically detect the audio source (bluetooth) and sink(3.5mm audio jack)
pactl load-module module-loopback source=bluez_source.B8_C6_8E_52_E8_CA sink=alsa_output.platform-bcm2835_AUD0.0.analog-stereo
Reference:
http://kmonkey711.blogspot.hk/2012/12/a2dp-audio-on-raspberry-pi.html
http://www.dreamincode.net/forums/blog/62/entry-4272-sound-on-an-arch-linux-arm-raspberry-pi/
Bluetooth stack
Controller stack
HCI(Host Controller Interface)
Protocol stack
- L2CAP (Logical Link Control and Adaptation Protocol) -
- SDP (Service Discovery protocol) - scan devices
- RFCOMM (Radio frequency communication) - on top of L2CAP, providing emulated RS-232 serial ports
- BNEP (Bluetooth network encapsulation protocol) - on top of L2CAP, for personal area networking (PAN) profile
Profiles
- A2DP (Advanced Audio Distribution Profile) - for headset
- DUN (Dial-up Networking Profile) - for accessing internet by dialing up on a modem
https://en.wikipedia.org/wiki/List_of_Bluetooth_protocols
https://en.wikipedia.org/wiki/List_of_Bluetooth_profiles
Setup PAN
Install bridge-utils
sudo apt install bridge-utils
Install python-dbus
sudo apt install python-dbus
Download bt-pan script
wget https://raw.githubusercontent.com/mk-fg/fgtk/master/bt-pan
Setup bpen bridge
1
2
3
4
5
6
7sdptool add NAP # advertise NAP service, but found sdptool does not work in bluez 5
brctl show bnep
sudo brctl addbr bnep
sudo brctl setfd bnep 0
sudo brctl stp bnep off
sudo ip addr add 192.168.12.3/24 dev bnep
sudo ip link set bnep upSetup server via dbus
1
2dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/hci0 org.bluez.NetworkServer1.Unregister string:'nap'
dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/hci0 org.bluez.NetworkServer1.Register string:'nap' string:'bnep'Reference
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.freedesktop.DBus.Introspectable.Introspect
dbus-send --system --dest=org.bluez --type=method_call --print-reply /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
dbus-send --system --type=method_call --print-reply=literal --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Properties.Set string:org.bluez.Adapter1 string:Powered variant:boolean:false
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Properties.Get string:org.bluez.Adapter1 string:Address
dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.ListNames
//below script is from http://rrbluetoothx.blogspot.hk/2016/06/rr-bluetooth-list-dbus-services-buses.html
dbus-send --system \
--dest=org.freedesktop.DBus \
--type=method_call \
--print-reply \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames
//below script is from https://gist.github.com/studiofuga/5262efb95968b02a365d
* Making an adapter discoverable (check that rfkill is enabled, otherwise /org/bluez/hci0 will not be available)
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 \
org.freedesktop.DBus.Properties.Set \
string:org.bluez.Adapter1 string:Discoverable variant:boolean:true
* Changing the discoverable timeout. Default is 180s.
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 \
org.freedesktop.DBus.Properties.Set \
string:org.bluez.Adapter1 string:DiscoverableTimeout variant:uint32:0Or Run bt server
./bt-pan --debug server bnep
Run bt client
./bt-pan --debug client 00:11:67:55:8F:69
https://blind.guru/tag/bluetooth-pan.html
http://blog.fraggod.net/2015/03/28/bluetooth-pan-network-setup-with-bluez-5x.html (provide the bt-pan script)
http://www.agouros.de/Elwood/Bluetooth.html
http://trac.gateworks.com/wiki/wireless/bluetooth (very detail)
http://wiki.openmoko.org/wiki/Manually_using_Bluetooth#Bluetooth_networking_with_a_Linux_system_-_More_secure_way
sshfs
- Install sshfs
sudo apt-get install sshfs
- Mount the directory by
1
2
3sshfs -o allow_other -o kernel_cache -o auto_cache -o reconnect \
-o compression=no -o cache_timeout=600 -o ServerAliveInterval=15 \
support@192.168.42.1:/tmp/song /home/pi/minidlna - Refresh the list to load new songs from sshfs directory by
minidlnad -R
- Reload minidlna service
sudo service minidlna force-reload
- Unmount directory
fusermount -u ~/minidlna
tinyproxy and iptables
1 | sudo apt-get install tinyproxy |
After install tinyproxy in my chromebook, found RPi cannot connect to 8888 port of tinyproxy(nc -l 8888
in chromebook and fail to connect by nc 192.168.42.9 8888
in RPi), which is caused by iptables rule. Then add it,
- Save the rules
sudo iptables-save > iptables.rules
- Add the rule for proxy working
sudo iptables -A INPUT -s 192.168.42.0/24 -i wlan0 -p tcp -dport 8888 -j ACCEPT
- Restore the rules
sudo iptables-restore < iptables.rules
mpg321, mpg123, speedtest-cli (just mark this, this is nothing)
Check the release or other useful information
1 | lsb_release -a |
Show various hardware information to RPi
1 | vcgencmd commands |