Blame SPECS/btattach-bcm-service.sh

Packit ed617f
#!/bin/bash
Packit ed617f
Packit ed617f
# Simple shell script to wait for the tty for an uart using BT HCI to show up
Packit ed617f
# and then invoke btattach with the right parameters, this is intended to be
Packit ed617f
# invoked from a hardware-activated systemd service
Packit ed617f
#
Packit ed617f
# For now this only suports ACPI enumerated Broadcom BT HCIs.
Packit ed617f
# This has been tested on Bay and Cherry Trail devices with both ACPI and
Packit ed617f
# PCI enumerated UARTs.
Packit ed617f
#
Packit ed617f
# Note the kernel bt developers are working on solving this entirely in the
Packit ed617f
# kernel, so it is not worth the trouble to write something better then this.
Packit ed617f
Packit ed617f
BT_DEV="/sys/bus/platform/devices/$1"
Packit ed617f
BT_DEV="$(readlink -f $BT_DEV)"
Packit ed617f
UART_DEV="$(dirname $BT_DEV)"
Packit ed617f
Packit ed617f
# Stupid GPD-pocket has USB BT with id 0000:0000, but still claims to have
Packit ed617f
# an uart attached bt
Packit ed617f
if [ "$1" = "BCM2E7E:00" ] && lsusb | grep -q "ID 0000:0000"; then
Packit ed617f
	exit 0
Packit ed617f
fi
Packit ed617f
Packit ed617f
while [ ! -d "$UART_DEV/tty" ]; do
Packit ed617f
	sleep .2
Packit ed617f
done
Packit ed617f
Packit ed617f
TTY="$(ls $UART_DEV/tty)"
Packit ed617f
Packit ed617f
exec btattach --bredr "/dev/$TTY" -P bcm