You've already forked Raspberry-Pi-Bluetooth
Initialize Git Repository: 'Raspberry-Pi-Bluetooth'
All checks were successful
Raspberry Pi Bluetooth (Bookworm) / Raspberry Pi Bluetooth [arm64] (push) Successful in 11s
All checks were successful
Raspberry Pi Bluetooth (Bookworm) / Raspberry Pi Bluetooth [arm64] (push) Successful in 11s
This commit is contained in:
33
root/usr/bin/btuart
Normal file
33
root/usr/bin/btuart
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
HCIATTACH='/usr/bin/hciattach'
|
||||
|
||||
if /usr/bin/grep --quiet 'raspberrypi,4' '/proc/device-tree/compatible'; then
|
||||
BDADDR=''
|
||||
else
|
||||
SERIAL=$(< '/proc/device-tree/serial-number' /usr/bin/cut '-c9-')
|
||||
B1=$(/usr/bin/echo "${SERIAL}" | /usr/bin/cut '-c3-4')
|
||||
B2=$(/usr/bin/echo "${SERIAL}" | /usr/bin/cut '-c5-6')
|
||||
B3=$(/usr/bin/echo "${SERIAL}" | /usr/bin/cut '-c7-8')
|
||||
BDADDR=$(/usr/bin/printf 'b8:27:eb:%02x:%02x:%02x' $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa)))
|
||||
fi
|
||||
|
||||
# Bail out if the kernel is managing the Bluetooth modem initialisation
|
||||
if ( /usr/bin/dmesg | /usr/bin/grep --extended-regexp --quiet "hci[0-9]+: BCM: chip" ); then
|
||||
# On-board bluetooth is already enabled
|
||||
exit 0
|
||||
fi
|
||||
|
||||
UART0=$(/usr/bin/cat '/proc/device-tree/aliases/uart0')
|
||||
SERIAL1=$(/usr/bin/cat '/proc/device-tree/aliases/serial1')
|
||||
|
||||
if [ "${UART0}" = "${SERIAL1}" ] ; then
|
||||
UART0_PINS=$(/usr/bin/wc --bytes '/proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins' | /usr/bin/cut --delimiter=' ' --fields='1')
|
||||
if [ "${UART0_PINS}" = "16" ] ; then
|
||||
"${HCIATTACH}" '/dev/serial1' bcm43xx 3000000 flow - "${BDADDR}"
|
||||
else
|
||||
"${HCIATTACH}" '/dev/serial1' bcm43xx 921600 noflow - "${BDADDR}"
|
||||
fi
|
||||
else
|
||||
"${HCIATTACH}" '/dev/serial1' bcm43xx 460800 noflow - "${BDADDR}"
|
||||
fi
|
||||
Reference in New Issue
Block a user