Skip to content

Commit

Permalink
Allow setting custom name
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
  • Loading branch information
roman-mazur committed Jul 5, 2019
1 parent f3b8f75 commit 73acc0c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ To run this project is as simple as deploying it to a balenaCloud application; n
* Flash the downloaded OS to your SD card with [balenaEtcher](https://balena.io/etcher)
* Power up the Pi and check it's online in the dashboard

### Customize device name

By default, your device will be displayed as `balenaSound xxxx` when you search for Bluetooth devices.
You can change this using `BLUETOOTH_DEVICE_NAME` environment variable that can be set in balena dashboard
(navigate to dashboard -> app -> device -> device variables).
![Setting the device name](docs/device-name.png)

If you modify the Bluetooth device name after deploying the application, you should restart `bluetooth-audio` service
to apply the changes.

### Deploy this application

* Install the [balena CLI tools](https://github.com/balena-io/balena-cli/blob/master/INSTALL.md)
Expand All @@ -42,7 +52,7 @@ To run this project is as simple as deploying it to a balenaCloud application; n

* After the application has pushed and the device has downloaded the latest changes you're ready to go!
* Connect the audio output of your Pi to the AUX input on your Hi-Fi or speakers
* Search for the `balenaSound xxxx` device on your phone or laptop and pair. `xxxx` will be the first 4 characters of the device ID in the balenaCloud dashboard.
* Search for your device (`balenaSound xxxx` name is used by default) on your phone or laptop and pair. `xxxx` will be the first 4 characters of the device ID in the balenaCloud dashboard.
* Let the music play!

This project is in active development so if you have any feature requests or issues please submit them here on GitHub. PRs are welcome, too.
6 changes: 4 additions & 2 deletions bluetooth-audio/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

BSHOSTNAME=$(printf "balenaSound %s" $(hostname | cut -c -4))
if [[ -z "$BLUETOOTH_DEVICE_NAME" ]]; then
BLUETOOTH_DEVICE_NAME=$(printf "balenaSound %s" $(hostname | cut -c -4))
fi

# set the discoverable timeout here
dbus-send --system --dest=org.bluez --print-reply /org/bluez/hci0 org.freedesktop.DBus.Properties.Set string:'org.bluez.Adapter1' string:'DiscoverableTimeout' variant:uint32:0
Expand All @@ -19,7 +21,7 @@ rm -rf /var/run/bluealsa/
/usr/bin/bluealsa -i hci0 -p a2dp-sink &

hciconfig hci0 up
hciconfig hci0 name "$BSHOSTNAME"
hciconfig hci0 name "$BLUETOOTH_DEVICE_NAME"

sleep 2
/usr/bin/bluealsa-aplay --pcm-buffer-time=1000000 00:00:00:00:00:00
Binary file added docs/device-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73acc0c

Please sign in to comment.