Thank you for your donation!


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


Activate Bluetooth via button
#1
I wonder if it would be possible to activate the Bluetooth via a button via GPIO and how to do it.
Reply
#2
What do you mean by "activate" Bluetooth?

Once you turn it on in Audio Config it remains running int the background waiting for incoming connections.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(08-09-2022, 05:49 PM)Tim Curtis Wrote: What do you mean by "activate" Bluetooth?

Once you turn it on in Audio Config it remains running int the background waiting for incoming connections.

That is correct, but then I would have to go to the web configuration and do a manual scan in the BlueZ configuration for pairing.
Since I run Moode exclusively headless via UPnP would be something incompfortable.
I am aware that I can enable the pairing agent to work around this.
But then anyone in the vicinity can connect to Moode via Bluetooth (unauthorized) and take control.
In both cases, devices once paired with Bluetooth would also remain connected to Moode in the future and could always reconnect.

Currently, only people who are on the (wifi) network can control Moode.
This prevents unauthorized control.
However, sometimes someone else (who does not have access to the network) wants to connect to Moode via Bluetooth. In this case, I would like to allow the connection via Bluetooth temporarily.
Since, as I said, it is a headless operation, a button that temporarily activates Bluetooth, or the Bluetooth renderer, could be an elegant solution.
Reply
#4
The challenge with this is that Bluetooth range is so limited that the "vicinity" you are referring to is basically "in the same room". You would be standing next to person that wanted to connect.

You could prolly create a script that starts/stops the pairing agent, clears all the pairings, etc and specify that for some GPIO buttons. Something like that.

Code:
# Start/stop pairing agent
sudo /var/www/daemon/blu_agent.py --agent --disable_pair_mode_switch --pair_mode --wait_for_bluez >/dev/null 2>&1 &

sudo killall -s 9 blu_agent.py

# Clear all pairings
sudo /var/www/util/blu-control.sh -R

# Help for blu-control
pi@moode:~ $ sudo /var/www/util/blu-control.sh --help
** blu-control.sh version 1.6
**
** Bluetooth has a range of around 30 feet (10 meters) but range
** will vary depending on obstacles (metal, wall, etc.), device signal
** strength and quality, and level of electromagnetic interferrence.
**
** Usage: blu-control.sh [OPTION]
**
** -i Initialize/reset controller
** -s Scan (BR/EDR only) and trust devices
** -S Scan (LE and BR/EDR) and trust devices
** -p List paired devices
** -c List connected devices
** -l List trusted devices
** -d Disconnect device <MAC addr>
** -r Remove paired device <MAC addr>
** -P Pair with device <MAC addr>
** -C Connect to device <MAC addr>
** -D Disconnect all devices
** -R Remove all devices
** -h Help
pi@moode:~ $ 
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(08-09-2022, 07:23 PM)Tim Curtis Wrote: The challenge with this is that Bluetooth range is so limited that the "vicinity" you are referring to is basically "in the same room". You would be standing next to person that wanted to connect.

Indeed, I use Moode a lot over a home-built music system at parties.

Here, potentially a whole bunch of people would be close enough to the system to connect and "take over" the music via bluetooth.



(08-09-2022, 07:23 PM)Tim Curtis Wrote: You could prolly create a script that starts/stops the pairing agent, clears all the pairings, etc and specify that for some GPIO buttons. Something like that.

Would it also be possible to enable/disable Bluetooth, or at least the Bluetooth renderer via a script?
Reply
#6
You would prolly need to create a new PHP script modeled after /var/www/util/restart-renderers.php. The new script would only have functions for starting and stopping Bluetooth. When stopping Bluetooth the last command needs to be like below so MPD/ALSA volume level is restored otherwise ALSA volume will be left at 0dB :-0

sysCmd('/var/www/vol.sh -restore');

Wouldn't it be easier to just bring up the Web UI on your Phone and turn Bluetooth On/Off? You can save the Audio Config page as a bookmark to reduce navigation.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
(08-09-2022, 09:01 PM)Tim Curtis Wrote: Wouldn't it be easier to just bring up the Web UI on your Phone and turn Bluetooth On/Off? You can save the Audio Config page as a bookmark to reduce navigation.

You're probably right.

Only often I myself am not on site when music is heard over the system to activate Bluetooth via the Webgui.
The people who control the music are all not very tech-savvy and only know how to control via BubbleUPnP.
Therefore, I thought a physical button on the system would be more ergonomic.
Reply


Forum Jump: