LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-16-2021, 12:36 PM   #1
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635
Blog Entries: 20

Rep: Reputation: 81
Using Slackware to make a Bluetooth speaker


I would like to setup a Slackware box (with a BT device and appropriate audio amp) as a Bluetooth speaker.
I know it is possible to use blueman to do that but I cant find a way to do it automatically without having to actually log into the Slackware box.
Basically I would like it to behave much like a normal Bluetooth speaker: ounce you power it up it automatically is listening for for something to bind and send audio to it.

Anyone know ho to go about it ?

I found this but not sure if it is too Debian oriented to to be any use on a Slackware system.
 
Old 01-16-2021, 02:35 PM   #2
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Appart from the systemd thing, it should work.

Tell us if ur stuck somewhere.
 
Old 01-17-2021, 02:21 AM   #3
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
I did the same things as described in that tutorial disregarding systemd stuff and also the pulseaudio start (because on slackware it is already running) but it's not working right:
on the phone I get "cannot connect" and on the slackware box's /var/log/syslog I get:
Code:
Jan 17 10:27:49 e11old bluetoothd[1833]: Authentication attempt without agent
Jan 17 10:27:49 e11old bluetoothd[1833]: Access denied: org.bluez.Error.Rejected
Not sure how to mend that.
 
Old 01-17-2021, 02:35 AM   #4
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Not at my computer today but that might be interesting :
https://stackoverflow.com/questions/...pin-on-bluez-5
 
Old 01-17-2021, 03:29 AM   #5
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Intresting ... that got the phone to connect but it still requires interaction after each boot to get the phone to connect even after initial pairing.
Looking for a fully automatic solution.
 
Old 01-17-2021, 06:17 AM   #6
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
I'm interested too :-)

What interactions do you have after reboot ?
 
Old 01-17-2021, 06:37 AM   #7
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
The pairing
Code:
root@e11old:~/bt_speaker# bluetoothctl 
[NEW] Controller 3C:77:E6:FE:19:6C E11Old [default]
[NEW] Device 6C:B7:49:CD:2A:85 HUAWEI Mate 10 lite
[NEW] Device 34:DE:34:CA:B6:F4 ZTE Blade A430
[NEW] Device 80:6A:B0:F5:DF:29 wiko davide
[NEW] Device 30:23:B5:72:B2:8A SBS BT500 RED
Agent registered
[bluetooth]# agent off
Agent unregistered
[bluetooth]# agent DisplayOnly
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 3C:77:E6:FE:19:6C Discoverable: yes
[bluetooth]# pairable on
Changing pairable on succeeded
[NEW] Device D4:11:A3:D8:2E:3C Galaxy A40
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device D4:11:A3:D8:2E:3C Class: 0x005a020c
[CHG] Device D4:11:A3:D8:2E:3C Icon: phone
[CHG] Device D4:11:A3:D8:2E:3C Connected: yes
[CHG] Device D4:11:A3:D8:2E:3C Modalias: bluetooth:v0075p0100d0201
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device D4:11:A3:D8:2E:3C ServicesResolved: yes
[CHG] Device D4:11:A3:D8:2E:3C Paired: yes
[CHG] Device D4:11:A3:D8:2E:3C ServicesResolved: no
[CHG] Device D4:11:A3:D8:2E:3C Connected: no
[bluetooth]#
And also another issue ... after some fiddling even when I pair interactively the audio is not setup properly and from the phone I do not see it as and audio device.
I think the one time I got it to work was because there was some residue from blueman pairing and setting up as audio.
I found a python script that does the pairing ... but not sure how to set it as the default agent.
And not sure how to go about stetting the Slackware box to present itself as a BT audio device all from command line.

Last edited by louigi600; 01-17-2021 at 07:01 AM. Reason: typos
 
Old 01-17-2021, 09:19 AM   #8
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
I've got some bash scripts that deal with bluetoothctl and might be adapted.
IIRC one had sticky bit to pair.
 
Old 01-17-2021, 11:00 AM   #9
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Can yo upload them here ?
I've not logged into IRC in a long time.
Maybe I just need to tell pulseaudio there is a new audio source ... since the binding works.
For the automatic binding I will try tell bluetoothctl where the new simmple-pin python script is ... it might be enough.
I will see, once I bind, if I can see the new audio source in pavucontrol ... if so I will try to figure out how to do it form command line ... if not I guess there is more to know.
 
Old 01-17-2021, 11:06 AM   #10
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
IIRC stands for "if I recall correctly" ;-)

I will post it here in the evening.
 
Old 01-17-2021, 11:31 AM   #11
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Cool ...
Here's a bit more I found out: if I do the pairing with blueman I do see this in the kernel ring buffer (which I do not see if I pair with the bluetoothctl procedure)
Code:
[ 1257.696422] input: D4:11:A3:D8:2E:3C as /devices/virtual/input/input15
and in messages
Code:
Jan 17 19:39:25 e11old kernel: [ 1257.696422] input: D4:11:A3:D8:2E:3C as /devices/virtual/input/input15
Jan 17 19:40:00 e11old bluetoothd[1227]: /org/bluez/hci0/dev_D4_11_A3_D8_2E_3C/fd0: fd(32) ready
also when I quit blueman end X I also see this in messages
Code:
Jan 17 20:00:06 e11old bluetoothd[1227]: Endpoint unregistered: sender=:1.17 path=/MediaEndpoint/A2DPSource
Jan 17 20:00:06 e11old bluetoothd[1227]: Endpoint unregistered: sender=:1.17 path=/MediaEndpoint/A2DPSink
I also noticed that if I do it when X is running I do get a slightly better result: on the phone I do get the audio device recognized (but fails to connect) : I suspect the's more dbus integration then I hoped. The target would be a headless RPI with no X at all: will I need to recompile bluez ?

Quote:
Originally Posted by Tonus View Post
IIRC stands for "if I recall correctly" ;-)

I will post it here in the evening.
I thought it was some IRC client :-D
after all if there exists mIRC why not also IIRC ;-)

Last edited by louigi600; 01-17-2021 at 12:23 PM.
 
Old 01-17-2021, 06:05 PM   #12
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
I would like to setup a Slackware box (with a BT device and appropriate audio amp) as a Bluetooth speaker.

Yeah.

So, you need something that can handle the possibilities that the BT device wasn't in range when you started OR was in range and then moved out of range while things are running and then moved back into range OR wasn't in range when you started but then later came into range.

Maybe you don't care about how those scenarios happen; maybe you don't care that someone could bring a BT device near that your box would connect to that simply looped someone stating that you were a pedophile or loved goats more than one would expect.

Please provide a better use case than that which you have given here.
  • Describe what you believe to be the normal use case.
  • Describe what you believe to be those slightly abnormal cases
  • Describe those cases that you do not ever wish to happen

If you absolutely know what BT device with which you need to pair, that will simplify things a bit.

I've gone through this with pairing a heart beat monitor against a Netbeans application running on a Slackware machine so I could watch my heart rate on a graph while exercising.

Last edited by Richard Cranium; 01-17-2021 at 06:10 PM.
 
Old 01-17-2021, 06:47 PM   #13
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,407
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
For the bluetoothctl, that's what I scripted :

Code:
echo -e "agent off\nagent DisplayOnly\ndefault-agent\ndiscoverable on\npairable on\nquit\n" | bluetoothctl
For the pulse part, this script changed to next sound card. Have to be adapted to the use case :
Code:
#! /bin/bash

# $totalsc: Number of sound cards available
totalsc=$(pacmd "list-sinks" | grep card: | wc -l) 
if [ $totalsc -le 1 ]; then 
  notify-send -u critical -t 5000 "No new sound card."
  exit
fi

# $scindex: The Pulseaudio index of the current default sound card
scindex=$(pacmd list-sinks | awk '$1 == "*" && $2 == "index:" {print $3}')

# $cards: A list of card Pulseaudio indexes
cards=$(pacmd list-sinks | sed 's|*||' | awk '$1 == "index:" {print $2}')
PICKNEXTCARD=1 # Is true when the previous card is default
count=0 # count of number of iterations

for CARD in $cards; do
  if [ $PICKNEXTCARD == 1 ]; then
# $nextsc: The pulseaudio index of the next sound card (to be switched to)
    nextsc=$CARD
    PICKNEXTCARD=0
# $nextind: The numerical index (1 to totalsc) of the next card
    nextind=$count
  fi
  if [ $CARD == $scindex ]; then # Choose the next card as default
    PICKNEXTCARD=1
  fi
  count=$((count+1))
done
pacmd "set-default-sink $nextsc" # switch default sound card to next

# $inputs: A list of currently playing inputs
inputs=$(pacmd list-sink-inputs | awk '$1 == "index:" {print $2}')
for INPUT in $inputs; do # Move all current inputs to the new default sound card
  pacmd move-sink-input $INPUT $nextsc
done
# $nextscdec: The device.description of the new default sound card
# NOTE: This is the most likely thing to break in future, the awk lines may need playing around with
nextscdesc=$(pacmd list-sinks | awk '$1 == "device.description" {print substr($0,5+length($1 $2))}' \
                         | sed 's|"||g' | awk -F"," 'NR==v1{print$0}' v1=$((nextind+1)))
notify-send "Default sound-card changed to $nextscdesc"
exit

Last edited by Tonus; 01-17-2021 at 06:51 PM.
 
Old 01-17-2021, 07:39 PM   #14
hpfeil
Member
 
Registered: Nov 2010
Location: Tucson, Arizona US
Distribution: Slackware Current
Posts: 357
Blog Entries: 1

Rep: Reputation: Disabled
Thank you for mentioning bluetoothctl.
 
Old 01-18-2021, 02:24 AM   #15
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635

Original Poster
Blog Entries: 20

Rep: Reputation: 81
Quote:
echo -e "agent off\nagent DisplayOnly\ndefault-agent\ndiscoverable on\npairable on\nquit\n" | bluetoothctl
I think this should do the same but without having to redirect the output of echo
Code:
bluetoothctl << EOF
agent off
agent DisplayOnly
default-agent
discoverable on
pairable on
quit
EOF
I will see if I can modify the pulseaudio script to work on my system ... should I run that after pairing or before pairing ?
Not sure which is the head and which the tail of the cat chasing it's tail: do I need to setup pulse before pairing so that the audio output is presented via BT or do I need to tell pulse that there is a new audio source after pairing ?
Anyway seem to have run into trouble with the very first line:
Code:
root@e11old:~/bt_speaker# pacmd "list-sinks" | grep card: | wc -l
No PulseAudio daemon running, or not running as session daemon.
0
root@e11old:~/bt_speaker#
Remember I'm on the text console ... not sure how X starts pulseaodio but I don't have rc.plulseaudio executable.
In any case even if I start it I still get much the same:
Code:
root@e11old:~/bt_speaker# . /etc/rc.d/rc.pulseaudio start
Starting system PulseAudio daemon:  /usr/bin/pulseaudio --system --disallow-module-loading &
root@e11old:~/bt_speaker# pacmd "list-sinks" | grep card: | wc -l
No PulseAudio daemon running, or not running as session daemon.
0
root@e11old:~/bt_speaker#
Quote:
So, you need something that can handle the possibilities that the BT device wasn't in range when you started OR was in range and then moved out of range while things are running and then moved back into range OR wasn't in range when you started but then later came into range.
Not really because the plan is to add analog audio out to a RPIzeroW and have it devoted just to doing BT audio playback ... so when I turn it on I know I want to stream audio to it and phone will be in range. Concerning the temporarily out of range I was thinking that a simple BT reconnect on phone would fix it. But it might be nice if the slackware box would remember pared devices across restarts.

Quote:
Please provide a better use case than that which you have given here.
Describe what you believe to be the normal use case.
Describe what you believe to be those slightly abnormal cases
Describe those cases that you do not ever wish to happen
I'm trying to find how to do something not complaining of abnormalities so not really sure what you want me to explain here.
Any information I posted is just to share my findings so people can help me.

I want to be able to have a headless slackware box (will be a RPIzeroW once I figure out how) pair automatically with let's say one and one only specific phone (maybe a list in the future) and be able to to playback music like an ordinary off the shelf BT speaker system.

Last edited by louigi600; 01-18-2021 at 02:37 AM.
 
  


Reply

Tags
audio, bluetooth, speakers



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Leap 15.2, doesn't accept Bluetooth speaker as default speaker phgruver SUSE / openSUSE 2 08-25-2020 02:45 PM
[SOLVED] Streaming from speaker using bluetooth elieobeid7 Linux - Newbie 4 07-17-2017 12:29 AM
[SOLVED] bluetooth dongle + bluetooth speaker but no sound on the bluetooth speaker vonbiber Slackware 4 05-11-2017 09:53 AM
How could I make USB speaker as default/master speaker ? czy11421 Linux - Hardware 1 09-02-2007 10:59 AM
Left speaker does not speak - not speaker issue. Hardware or software issue? Svip Linux - Hardware 3 05-03-2006 11:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration