Max2Play Home 2016 (en) › Forums › Max2Play on Raspberry PI › [SOLVED] Pi3 Bluetooth Auto-Reconnect option / script? › Reply To: [SOLVED] Pi3 Bluetooth Auto-Reconnect option / script?
In case anyone is interested, I managed to solve this myself.
I had to:
1) Via Max2Play web UI, Update to Beta, then Update Squeezelite
– this was necessary to get the GPIO squeezelite build option that -S command line option depends on.
2) In Squeezelite advanced options, set Command Line Options to -B -S /opt/squeezelite/btrecon.sh
– this tells squeezelite to run my btrecon.sh script passing a 1 or 0 command line arg when player is switched on or off via iPeng / OrangeSqueeze.
3) Create the script below (and make executable) at /opt/squeezelite/btrecon.sh
– the script just runs bluetoothctl and either issues a connect or disconnect command to my BT speaker.
if [ „$power_state“ = „1“ ]
# echo $(date) “ $power_state Power switch on “ >> /opt/squeezelite/log/btrecon.log
# echo $(date) “ $power_state Power switch off “ >> /opt/squeezelite/log/btrecon.log
Works a treat!