Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

2020. 7. 3.

Setup Minidlna omxplayer bluetooth on RPi | My Blog

My Blog
Home
Archives

2017-01-19

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
2 db_dir=/var/lib/minidlna (allow minidlna to index files)

Restart minidlna,

1. sudo systemctl restart minidlna


2. sudo service minidlna start
3. sudo /etc/init.d/minidlna start
4. sudo service minidlna status -l
5. 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
2 hciconfig - show BD address of Pi
3 hciconfig -a hci0
4 rfkill unblock bluetooth or rfkill unblock all // If bluetoothctl cannot find any controller, the bluetooth device may be blocked. Try to unbloc
5 sudo bluetoothctl
6 # scan on (find the BD address)
7 # scan off
8 # agent on
9 # default-agent
10 # pair A0:E4:53:20:77:79
11 # trust A0:E4:53:20:77:79
12 # connect A0:E4:53:20:77:79
13 # list
14 # devices
15 # show
16 # disconnect A0:E4:53:20:77:79

Play music with the bluetooth speaker(Phillips BT3000) using A2DP profile
1. 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 ps aux | grep pulseaudio


2 =>
3 /usr/bin/start-pulseaudio-X11
4 pulseaudio --start
5 (PulseAudio would run along with X11 desktop startup)

2. List the sound cards pacmd list-cards . Test audio output of left and right channal speaker-test -c 2

3. List the audio output pacmd list-sinks or pactl list sinks short . Check the default audio sink aplay -L
4. List the audio input pacmd list-sources or pactl list sources short
5. Set the Bluetooth speaker becomes default sink pacmd set-default-sink 1 (index 1 is like bluez_sink.xx_xx_xx_xx_xx_xx)
6. Turn up the PulseAudio volume pacmd set-sink-volume 0 65537 Or turn up the ALSA volume amixer set Master 100% or amixer cset numid=3 100%
Reference:

https://l1z2g9.github.io/2017/01/19/Setup-Minidlna-omxplayer-bluetooth-on-RPi/ 1/4
2020. 7. 3. Setup Minidlna omxplayer bluetooth on RPi | My Blog
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi
http://www.crazy-audio.com/2014/09/pulseaudio-on-the-raspbery-pi/
7. Show soundcard information aplay -L or aplay -l , play a music aplay -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
1. Install bridge-utils sudo apt install bridge-utils
2. Install python-dbus sudo apt install python-dbus
3. Download bt-pan script wget https://raw.githubusercontent.com/mk-fg/fgtk/master/bt-pan

4. Setup bpen bridge

1 sdptool add NAP # advertise NAP service, but found sdptool does not work in bluez 5
2 brctl show bnep
3 sudo brctl addbr bnep
4 sudo brctl setfd bnep 0
5 sudo brctl stp bnep off
6 sudo ip addr add 192.168.12.3/24 dev bnep
7 sudo ip link set bnep up

5. Setup server via dbus

1 dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/hci0 org.bluez.NetworkServer1.Unregister string:'nap'


2 dbus-send --system --dest=org.bluez --print-reply --type=method_call /org/bluez/hci0 org.bluez.NetworkServer1.Register string:'nap' string:

Reference

1
2
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.freedesktop.DBus.Introspectable.Introspect
3
dbus-send --system --dest=org.bluez --type=method_call --print-reply /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
4
dbus-send --system --type=method_call --print-reply=literal --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Properties.Set string:org.blue
5
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Properties.Get string:org.bluez.Adapte
6
dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.ListNames
7
//below script is from http://rrbluetoothx.blogspot.hk/2016/06/rr-bluetooth-list-dbus-services-buses.html
8
dbus-send --system \
9
--dest=org.freedesktop.DBus \
10
--type=method_call \
11
--print-reply \
12
/org/freedesktop/DBus \
13
org.freedesktop.DBus.ListNames
14
//below script is from https://gist.github.com/studiofuga/5262efb95968b02a365d
15
* Making an adapter discoverable (check that rfkill is enabled, otherwise /org/bluez/hci0 will not be available)
16
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 \
17
org.freedesktop.DBus.Properties.Set \
18
string:org.bluez.Adapter1 string:Discoverable variant:boolean:true
19
20
* Changing the discoverable timeout. Default is 180s.
21
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 \
22
org.freedesktop.DBus.Properties.Set \
23
string:org.bluez.Adapter1 string:DiscoverableTimeout variant:uint32:0
24
25

Or Run bt server ./bt-pan --debug server bnep

https://l1z2g9.github.io/2017/01/19/Setup-Minidlna-omxplayer-bluetooth-on-RPi/ 2/4
2020. 7. 3. Setup Minidlna omxplayer bluetooth on RPi | My Blog
© 2019 Forrest Wan

https://l1z2g9.github.io/2017/01/19/Setup-Minidlna-omxplayer-bluetooth-on-RPi/ 4/4
2020. 7. 3. Setup Minidlna omxplayer bluetooth on RPi | My Blog
1. 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
1. Install sshfs sudo apt-get install sshfs

2. Mount the directory by

1 sshfs -o allow_other -o kernel_cache -o auto_cache -o reconnect \


2 -o compression=no -o cache_timeout=600 -o ServerAliveInterval=15 \
3 support@192.168.42.1:/tmp/song /home/pi/minidlna

3. Refresh the list to load new songs from sshfs directory by minidlnad -R

4. Reload minidlna service sudo service minidlna force-reload


5. Unmount directory fusermount -u ~/minidlna

tinyproxy and iptables

1 sudo apt-get install tinyproxy


2 sudo service tinyproxy start

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,

1. Save the rules sudo iptables-save > iptables.rules


2. Add the rule for proxy working sudo iptables -A INPUT -s 192.168.42.0/24 -i wlan0 -p tcp -dport 8888 -j ACCEPT
3. 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
2 lsb_release -a
3 vcgencmd version
4 cat /etc/os-release
5 cat /etc/rpi-issue
6 cat /etc/debian_version
7 cat /proc/cpuinfo
8 cat /proc/meminfo
9 cat /proc/version
10

Show various hardware information to RPi

1
2
vcgencmd commands
3
vcgencmd measure_clock arm
4
vcgencmd measure_clock core
5
vcgencmd get_config int
6
vcgencmd get_mem arm
7
vcgencmd get_mem gpu
8
9

Raspberry Pi
Like 0 Tweet Share

Buscar

Etiquetas

AIX29
MySQL2
Oracle14
Problem Solve8
Raspberry Pi12
工作日志68
日常记录23

https://l1z2g9.github.io/2017/01/19/Setup-Minidlna-omxplayer-bluetooth-on-RPi/ 3/4

You might also like