Bluetooth for Slacko 5.6 - Stream audio from PC.
Posted: Sat 14 Jul 2018, 07:26
I needed to get a bluetooth speaker connected to my Slacko 5.6 derivative in order to improve the quality of sound output from my laptop speakers.
Google searches and murga forum searches convinced me that there are potentially many pitfalls with getting bluetooth running, and that it is very easy to load too little, or too much software, or to load completely the wrong software.
I had a chuckle when I found this post from "Richard Cranium":
- "Bluetooth is a wonderful rat hole where you can spend lots of hours learning about it that could be used for other things, such as drinking wine or beer. The version of bluez in slackware is kinda old. (Don't try to use it to connect to a heart rate monitor, for instance.) See https://www.bluetooth.org/en-us/spec...specifications for the various things that are supported by various versions of bluetooth"
If you want to know lots about bluetooth devices the reference he directs you to is worth a look:
https://www.bluetooth.com/specifications
On the other hand - getting bluetooth running for the purposes of streaming your music directory to a BT speaker or BT headset - can be quite easy. I quickly decided I did not want to learn everything about bluetooth - I just wanted to find a quick and easy way to get sound from my bluetooth speaker.
I have posted below a .pet which I use on my Slacko 5.6 derivative to connect to a variety of devices for the purposes of streaming audio from my PC. It is not my intention at this point to connect to a bluetooth phone, or other bi-directional device.
PLEASE NOTE : All of my testing is done on a CD booted Slacko 5.6 with no savefile. There is a risk that my pet could overwrite existing files in your save file. If you want to try my pet I recommend that you boot with pfix=ram or hide your savefile (or have a good backup of it somewhere) so that you don't get any weird results. Especially - you don't want to end up with multiple BT packages lying around your system. You really only need the basics.
This pet is based on the puppyBT_2.1 package (I don't remember where I got that or who wrote it) combined with parts of rcrsn51's bt4stretch pet and also combined with a small amount of my own code. I have called my pet "slackstream" to ensure there is no confusion with the official packages.
Here is what to do:
1) Load the slackstreamBT pet available here:
http://www.mediafire.com/file/uoy6pnk6r ... BT-0.1.pet
2) Turn on your bluetooth device (make sure you have no other PCs or phones that automatically connect to that device!)
3) Run "slackstream" from the network menu
4) Work your way down the list of functions:
- scan for devices
- pair with the device you want.
- click the "btheadset" button
- choose the directory that contains the test files you wish to play
- click "play"
Before you shut down click the "Remove a pairing" button to let your device become available to other phones and PCs.
Any problems let me know...
Troubleshooting and extending your bluetooth knowledge:
The scan function only detects your device if the device is currently unpaired.
My pet only tries to play your media files with mplayer in "alsa" mode. Other software may or may not be able to access the alsa interface that is set up for bluetooth. Be prepared to try all sorts of things if you want to get more fancy with what/how you want to stream.
Once you have loaded the apropriate bluetooth software for your puppy check out the files currently in /etc/bluetooth - these rules will determine the behaviour of your BT adapter.
In weird cases may need to turn on then load firmware (Arch wiki has lots of info):
Note: Before using the bluetooth device adapter that is inbuilt in (or plugged into) your PC, make sure that it is not blocked by rfkill. Enter the following command into a terminal:
rfkill list
- For a better understanding of what is happening under the hood you can use this alternative method rather than relying totally on the slackstream gui started from the menu:
1) Install slackstreamBT.pet-0.1
2) Make a new directory in /root and call it /music. Copy one or more music files into that directory (just for the purposes of this test)
3) Turn BT external device on (making sure it does not get grabbed and paired by some other phone or PC)
4) Type the following command in a terminal:
hcitool scan
(and then record the BT address for your external device).
5) Type the following command in a terminal:
bluetooth-agent \PPPP \XX:XX:XX:XX:XX:XX
(where PPPP is the pin code for your device and XX:XX:XX:XX:XX:XX is the BT address for your external device as discovered in the scan).
6) Start the slackstreamBT gui from the network menu and click "btheadset" button (this writes a new .asoundrc file into /root (make a copy of this file somewhere in case you want to use it some other day without starting slackstream - this file is the key to getting alsa to drive the BT stream to BT heaphones or speaker))
7) Type the following command:
mplayer -ao alsa /root/music/*.*
(Which will use mplayer to sequentially play through every file in that directory)
8.) When mplayer has finished playing the /root/music directory you will probably want to release the pairing so that the external device is available to other devices. Simply type the following command in terminal:
bt-device -r \XX:XX:XX:XX:XX:XX
.
Google searches and murga forum searches convinced me that there are potentially many pitfalls with getting bluetooth running, and that it is very easy to load too little, or too much software, or to load completely the wrong software.
I had a chuckle when I found this post from "Richard Cranium":
- "Bluetooth is a wonderful rat hole where you can spend lots of hours learning about it that could be used for other things, such as drinking wine or beer. The version of bluez in slackware is kinda old. (Don't try to use it to connect to a heart rate monitor, for instance.) See https://www.bluetooth.org/en-us/spec...specifications for the various things that are supported by various versions of bluetooth"
If you want to know lots about bluetooth devices the reference he directs you to is worth a look:
https://www.bluetooth.com/specifications
On the other hand - getting bluetooth running for the purposes of streaming your music directory to a BT speaker or BT headset - can be quite easy. I quickly decided I did not want to learn everything about bluetooth - I just wanted to find a quick and easy way to get sound from my bluetooth speaker.
I have posted below a .pet which I use on my Slacko 5.6 derivative to connect to a variety of devices for the purposes of streaming audio from my PC. It is not my intention at this point to connect to a bluetooth phone, or other bi-directional device.
PLEASE NOTE : All of my testing is done on a CD booted Slacko 5.6 with no savefile. There is a risk that my pet could overwrite existing files in your save file. If you want to try my pet I recommend that you boot with pfix=ram or hide your savefile (or have a good backup of it somewhere) so that you don't get any weird results. Especially - you don't want to end up with multiple BT packages lying around your system. You really only need the basics.
This pet is based on the puppyBT_2.1 package (I don't remember where I got that or who wrote it) combined with parts of rcrsn51's bt4stretch pet and also combined with a small amount of my own code. I have called my pet "slackstream" to ensure there is no confusion with the official packages.
Here is what to do:
1) Load the slackstreamBT pet available here:
http://www.mediafire.com/file/uoy6pnk6r ... BT-0.1.pet
2) Turn on your bluetooth device (make sure you have no other PCs or phones that automatically connect to that device!)
3) Run "slackstream" from the network menu
4) Work your way down the list of functions:
- scan for devices
- pair with the device you want.
- click the "btheadset" button
- choose the directory that contains the test files you wish to play
- click "play"
Before you shut down click the "Remove a pairing" button to let your device become available to other phones and PCs.
Any problems let me know...
Troubleshooting and extending your bluetooth knowledge:
The scan function only detects your device if the device is currently unpaired.
My pet only tries to play your media files with mplayer in "alsa" mode. Other software may or may not be able to access the alsa interface that is set up for bluetooth. Be prepared to try all sorts of things if you want to get more fancy with what/how you want to stream.
Once you have loaded the apropriate bluetooth software for your puppy check out the files currently in /etc/bluetooth - these rules will determine the behaviour of your BT adapter.
In weird cases may need to turn on then load firmware (Arch wiki has lots of info):
Note: Before using the bluetooth device adapter that is inbuilt in (or plugged into) your PC, make sure that it is not blocked by rfkill. Enter the following command into a terminal:
rfkill list
- For a better understanding of what is happening under the hood you can use this alternative method rather than relying totally on the slackstream gui started from the menu:
1) Install slackstreamBT.pet-0.1
2) Make a new directory in /root and call it /music. Copy one or more music files into that directory (just for the purposes of this test)
3) Turn BT external device on (making sure it does not get grabbed and paired by some other phone or PC)
4) Type the following command in a terminal:
hcitool scan
(and then record the BT address for your external device).
5) Type the following command in a terminal:
bluetooth-agent \PPPP \XX:XX:XX:XX:XX:XX
(where PPPP is the pin code for your device and XX:XX:XX:XX:XX:XX is the BT address for your external device as discovered in the scan).
6) Start the slackstreamBT gui from the network menu and click "btheadset" button (this writes a new .asoundrc file into /root (make a copy of this file somewhere in case you want to use it some other day without starting slackstream - this file is the key to getting alsa to drive the BT stream to BT heaphones or speaker))
7) Type the following command:
mplayer -ao alsa /root/music/*.*
(Which will use mplayer to sequentially play through every file in that directory)
8.) When mplayer has finished playing the /root/music directory you will probably want to release the pairing so that the external device is available to other devices. Simply type the following command in terminal:
bt-device -r \XX:XX:XX:XX:XX:XX
.