]>
Commit | Line | Data |
---|---|---|
477801c9 JR |
1 | #!/bin/sh |
2 | ||
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 | |
6 | # | |
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. | |
10 | # | |
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. | |
13 | ||
14 | BT_DEV="/sys/bus/platform/devices/$1" | |
15 | BT_DEV="$(readlink -f $BT_DEV)" | |
16 | UART_DEV="$(dirname $BT_DEV)" | |
17 | ||
18 | # Stupid GPD-pocket has USB BT with id 0000:0000, but still claims to have | |
19 | # an uart attached bt | |
20 | if [ "$1" = "BCM2E7E:00" ] && lsusb | grep -q "ID 0000:0000"; then | |
21 | exit 0 | |
22 | fi | |
23 | ||
24 | while [ ! -d "$UART_DEV/tty" ]; do | |
25 | sleep .2 | |
26 | done | |
27 | ||
28 | TTY="$(ls $UART_DEV/tty)" | |
29 | ||
30 | exec btattach --bredr "/dev/$TTY" -P bcm |