Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: auto connect to a bluetooth speaker
#1
hi, 

i searched the forum, and maybe i overlooked. but how do i auto-connect to my bluetooth speaker on startup. 

i have moode 6.6 running and my speaker is already paired with moode. when i restart moode there is an alsa error and i have to reconnect the speaker with bluez. there is only one speaker paired. (pairing agent is on)

for the rest only praises and a lot of credits for moode..  keep on going Tim..
Reply
#2
@Ikke4

I thought this reconnection "just worked" but I was able just now to repro your issue. However, it seemed to be only momentary.

System - moOde 6.6.0 on an RPi3A.. Bluetooth renderer enabled and Bluez Config screen used to scan for, pair with, and connect to a JBL Flip 2 Bluetooth speaker. The Config screen shows the connection and the JBL emits its annoying beep sequence to indicate something has connected to it. [Note, the Pairing agent is not germane here. It deals with incoming pairing, not outgoing.] 

Radio station is playing over the JBL.

Now reboot moOde. (I left the JBL powered on; I suppose switching it off and on again should be another test.)

After moOde has restarted, the JBL once again beeps as if something has connected to it. The Bluez screen shows it's still in MPD audio output -> Bluetooth mode but now doesn't show any Bluetooth devices (which leads to the error message you mentioned.) There's no audio output and various command line queries show no Bluetooth connection.

However, in the process of opening the moOdeUI in a new browser instance, the JBL beeped yet again and now it really is connected. I can again play a radio station over the JBL without having made any manual adjustment in the Bluez config screen.

I'm not sure what's going on here. I'm thinking the next step is to modify the bluealsa.service file to enable logging. This may turn up something useful (or may just confuse me further Tongue ).

Meanwhile, how about trying the same hack of closing the existing moOdeUI instance in your browser and opening another. Does it lead to the same auto-magical reconnection?

Regards,
Kent
Reply
#3
Theres no explicit reconnect code in moOde for Bluetooth so whatever is happening is prolly due to some reconnect code in the BT speaker ???

To do a reconnect after reboot in moOde it would be something like below.

Code:
/var/www/command/bt.sh -C MAC_ADDRESS
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
(07-15-2020, 04:47 PM)Tim Curtis Wrote: Theres no explicit reconnect code in moOde for Bluetooth so whatever is happening is prolly due to some reconnect code in the BT speaker ???

Oof. If that's what the speaker is doing, no wonder I was thinking somehow moOde could reconnect without intervention after reboot. Yet another way to go wrong with confidence. Naturally, JBL sees no reason to publish the internals of its consumer-grade gear so I'm flying blind.

Quote:To do a reconnect after reboot in moOde it would be something like below.

Code:
/var/www/command/bt.sh -C MAC_ADDRESS


Maybe, but my head hurts when I think about how the code should gracefully handle the case where the speaker is off at the time.

@Ikke4

I think for the present the answer to your original question has to be "you can't". Sorry.

Regards,
Kent
Reply
#5
Correct, there's no way for moOde to know whether the Bluetooth device is on or off.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#6
(07-15-2020, 06:27 PM)Tim Curtis Wrote: Correct, there's no way for moOde to know whether the Bluetooth device is on or off.

Hi Kent and Tim, thanks for the fast reply. 

If the bluetooth speaker is alway on/standbye and paired the last time moOde was used (mine HK omni 20 is). after startup i always have to go into the BlueZ config menu and submit the List paired command and click connect (Omni is the only one paired) . those two steps could be automated. there must be an option to run them in a script.

If there is no connection the human, me, has to manual switch on the speaker and rerun those commands. 

just my two cents..   Cool

MoOde is running smoothly on a rasp 3B+ and replaced our home audio set for the last couple of weeks.
Reply
#7
(07-15-2020, 04:47 PM)Tim Curtis Wrote: Theres no explicit reconnect code in moOde for Bluetooth so whatever is happening is prolly due to some reconnect code in the BT speaker ???

To do a reconnect after reboot in moOde it would be something like below.

Code:
/var/www/command/bt.sh -C MAC_ADDRESS



Help please,

i put the following command in RC.local
 
Code:
/var/www/command/bt.sh -C 0C:A6:94:51:02:C3

but that didn't work

on the command line 

Code:
pi@moode:~ $ sudo /var/www/command/bt.sh -C 0C:A6:94:51:02:C3
** Connecting to device 0C:A6:94:51:02:C3
** Device 0C:A6:94:51:02:C3 connected
did work..  

where can i put the code (on my own risk) Angel
Reply
#8
Try adding your code to /var/www/command/worker.php just after the "worker: Ready' code block which is around line 750

Code:
//
workerLog('worker: Ready');
$result = sdbquery("UPDATE cfg_system SET value='1' WHERE param='wrkready'", $dbh);
//

sysCmd('/var/www/command/bt.sh -C 0C:A6:94:51:02:C3');
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#9
(07-17-2020, 06:28 PM)Tim Curtis Wrote: Try adding your code to /var/www/command/worker.php just after the "worker: Ready' code block which is around line 750

Code:
//
workerLog('worker: Ready');
$result = sdbquery("UPDATE cfg_system SET value='1' WHERE param='wrkready'", $dbh);
//

sysCmd('/var/www/command/bt.sh -C 0C:A6:94:51:02:C3');

Me Happy; It works!!!!

next phase:  auto start KinK FM - radio station!

[i'm a very lazy person, so i'll only have to press one button to hear my favourite radio station: KINK FM ]
Reply


Forum Jump: