Skip to content

Commit

Permalink
Merge pull request #5 from balena-io-projects/nicer-log-output
Browse files Browse the repository at this point in the history
Nicer log output
  • Loading branch information
zrzka authored Jul 5, 2019
2 parents 8ed93d7 + a156733 commit 71f37be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ To run this project is as simple as deploying it to a balenaCloud application; n
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](images/device-name-config.png)

If you modify the Bluetooth device name after deploying the application, you should restart `bluetooth-audio` service
to apply the changes.
![Setting the device name](images/device-name-config.png)

### Deploy this application

Expand Down
2 changes: 1 addition & 1 deletion bluetooth-audio/bluetooth-agent
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if __name__ == '__main__':
manager = dbus.Interface(obj, "org.bluez.AgentManager1")
manager.RegisterAgent(path, capability)

print("Agent registered")
print("Bluetooth agent registered")

manager.RequestDefaultAgent(path)

Expand Down
15 changes: 10 additions & 5 deletions bluetooth-audio/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ 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
# Set the discoverable timeout here
dbus-send --system --dest=org.bluez /org/bluez/hci0 org.freedesktop.DBus.Properties.Set string:'org.bluez.Adapter1' string:'DiscoverableTimeout' variant:uint32:0

printf "\nSetting volume to 100%%\n"
printf "Setting volume to 100%%\n"
amixer sset PCM,0 100% > /dev/null &

service bluetooth restart
printf "Restarting bluetooth service\n"
service bluetooth restart > /dev/null
sleep 2
printf "discoverable on\npairable on\nexit\n" | bluetoothctl

# Redirect stdout to null, because it prints the old BT device name, which
# can be confusing and it also hides those commands from the logs as well.
printf "discoverable on\npairable on\nexit\n" | bluetoothctl > /dev/null

/usr/src/bluetooth-agent &

Expand All @@ -24,4 +28,5 @@ hciconfig hci0 up
hciconfig hci0 name "$BLUETOOTH_DEVICE_NAME"

sleep 2
printf "Device is discoverable as \"%s\"\n" "$BLUETOOTH_DEVICE_NAME"
/usr/bin/bluealsa-aplay --pcm-buffer-time=1000000 00:00:00:00:00:00

0 comments on commit 71f37be

Please sign in to comment.