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