diff options
author | CoprDistGit <infra@openeuler.org> | 2025-03-17 15:29:27 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2025-03-17 15:29:27 +0000 |
commit | 28bf837ff2700e2c52e24bbf7c521df28ddfdaeb (patch) | |
tree | 9a21f08865172343f8a639c85de178564bd26524 /btattach-bcm-service.sh | |
parent | 515163e96cbfe54f91a2cd9c7352a1b0b78f3350 (diff) |
automatic import of bluezopeneuler24.03_LTS_SP1
Diffstat (limited to 'btattach-bcm-service.sh')
-rw-r--r-- | btattach-bcm-service.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/btattach-bcm-service.sh b/btattach-bcm-service.sh new file mode 100644 index 0000000..c7f8b17 --- /dev/null +++ b/btattach-bcm-service.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Simple shell script to wait for the tty for an uart using BT HCI to show up +# and then invoke btattach with the right parameters, this is intended to be +# invoked from a hardware-activated systemd service +# +# For now this only suports ACPI enumerated Broadcom BT HCIs. +# This has been tested on Bay and Cherry Trail devices with both ACPI and +# PCI enumerated UARTs. +# +# Note the kernel bt developers are working on solving this entirely in the +# kernel, so it is not worth the trouble to write something better then this. + +BT_DEV="/sys/bus/platform/devices/$1" +BT_DEV="$(readlink -f $BT_DEV)" +UART_DEV="$(dirname $BT_DEV)" + +# Stupid GPD-pocket has USB BT with id 0000:0000, but still claims to have +# an uart attached bt +if [ "$1" = "BCM2E7E:00" ] && lsusb | grep -q "ID 0000:0000"; then + exit 0 +fi + +while [ ! -d "$UART_DEV/tty" ]; do + sleep .2 +done + +TTY="$(ls $UART_DEV/tty)" + +exec btattach --bredr "/dev/$TTY" -P bcm |