Skip to content

Commit

Permalink
converted bt install script to configure.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahshader authored and linknum23 committed Mar 20, 2023
1 parent 7ec3d2c commit d168e61
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Most of these digital streaming services are provided by other open-source proje
|Google Cast|No||||Need to investigate|
|Offline Music|No||||See [#66](http://github.com/micro-nova/AmpliPi/issues/66)|
|TIDAL|No||||See [#87](http://github.com/micro-nova/AmpliPi/issues/87)|
|Bluetooth|No||||See [#150](http://github.com/micro-nova/AmpliPi/issues/150)|
|Bluetooth|Yes||||See [#150](http://github.com/micro-nova/AmpliPi/issues/150)|

In the future we plan to integrate with several home automation systems. Below is their current status.

Expand Down
Binary file added bin/arm/rtl8761b_config
Binary file not shown.
Binary file added bin/arm/rtl8761b_fw
Binary file not shown.
9 changes: 9 additions & 0 deletions config/bluetooth/bluealsa.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=BluezALSA proxy
Requires=bluetooth.service
After=bluetooth.service

[Service]
Type=simple
User=root
ExecStart=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink
16 changes: 16 additions & 0 deletions config/bluetooth/bluetooth_agent.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=A2DP Bluetooth Agent
After=bluetooth.service
Wants=bluetooth.service

[Service]
ExecStartPre=/bin/sh -c "echo discoverable on | bluetoothctl"
ExecStart=/usr/bin/python -u /usr/local/bin/bluetooth_agent
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=bluetooth_agent
RestartSec=1
Restart=always

[Install]
WantedBy=bluetooth.service
6 changes: 6 additions & 0 deletions config/bluetooth/main.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[General]
Name = AmpliPi Bluetooth
Class = 0x200400
DiscoverableTimeout = 0
[Policy]
AutoEnable=true
3 changes: 1 addition & 2 deletions install_bluetooth_for_amplipi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Run as: sudo .\install_bluetooth_for_amplipi.sh

apt-get install -y libsndfile1 libsndfile1-dev libbluetooth-dev bluealsa python-dbus libasound2-dev git autotools-dev automake libtool m4
apt-get install -y libsndfile1 libsndfile1-dev libbluetooth-dev bluealsa dbus-python libasound2-dev git autotools-dev automake libtool m4

# For better audio quality, build bluealsa manually after installing fdk-aac and the latest version of bluez 5.58
# Install aacplus decoder
Expand Down Expand Up @@ -52,7 +52,6 @@ After=bluetooth.service
Type=simple
User=root
ExecStart=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink
EOF

#---------------------------------------------------------------------------------------------------------------#
Expand Down
30 changes: 30 additions & 0 deletions scripts/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,36 @@
},
'spotify' : {
'copy' : [{'from': 'bin/ARCH/spotifyd', 'to': 'streams/spotifyd'}],
},
'bluetooth' : {
'copy' : [{'from': 'bin/ARCH/rtl8761b_fw', 'to': '/lib/firmware/rtl_bt/rtl8761b_fw.bin'},
{'from': 'bin/ARCH/rtl8761b_config', 'to': '/lib/firmware/rtl_bt/rtl8761b_config.bin'},
{'from': 'config/bluetooth/main.conf', 'to': '/etc/bluetooth/main.conf'},
{'from': 'config/bluetooth/bluealsa.service', 'to': '/lib/systemd/system/bluealsa.service'},
{'from': 'streams/bluetooth_agent', 'to': '/usr/local/bin'},
{'from': 'config/bluetooth/bluetooth_agent.service', 'to': '/etc/systemd/system'}],
'apt' : [ 'libsndfile1', 'libsndfile1-dev', 'libbluetooth-dev', 'bluealsa', 'dbus-python',
'libasound2-dev', 'git', 'autotools-dev', 'automake', 'libtool', 'm4' ],
'script' : [
# Install SBC
'pushd $(mktemp --directory)',
'git clone https://git.kernel.org/pub/scm/bluetooth/sbc.git',
'cd sbc',
'./bootstrap-configure',
'./configure',
'make',
'make install',
'popd',

# Add pi user to bluetooth group so we don't need to run sudo
'usermod -G bluetooth -a pi',

'chmod +x /usr/local/bin/bluetooth_agent',

'systemctl enable bluetooth',
'systemctl enable bluealsa',
'systemctl enable bluetooth_agent.service',
]
}
}

Expand Down
File renamed without changes.

0 comments on commit d168e61

Please sign in to comment.