Title:          bluez.tcz
Description:    bluetooth stack
Version:        5.55
Author:         see Authors in tarball
Original-site:  http://www.kernel.org/pub/linux/bluetooth/bluez-5.52.tar.xz
Copying-policy: GPLv2
Size:           2.2MB
Extension_by:   paul-123
Tags:           bluetooth
Comments:       official linux bluetooth protocol stack
                ----------
For onboard Rpi bluetooth, this is needed to initialize

  sudo modprobe hci_uart
  if grep -q "Pi 4" /proc/device-tree/model; then
     BDADDR=
  else
     SERIAL=`cat /proc/device-tree/serial-number | cut -c9-`
     B1=`echo $SERIAL | cut -c3-4`
     B2=`echo $SERIAL | cut -c5-6`
     B3=`echo $SERIAL | cut -c7-8`
     BDADDR=`printf b8:27:eb:%02x:%02x:%02x $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa))`
  fi
  uart0="`cat /proc/device-tree/aliases/uart0`"
  serial1="`cat /proc/device-tree/aliases/serial1`"

  if [ "$uart0" = "$serial1" ] ; then
     uart0_pins="`wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' '`"
     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

  # For on-board BT, route SCO packets to the HCI interface (enables HFP/HSP)
  # Sound quality is horrible.....just puting this here for info
  #echo "Usage: $0 <bluetooth hci device>"
  dev="hci0"
  # Need to bring hci up before looking at MAC as it can be all zeros during init
  /usr/local/bin/hciconfig "$dev" up
  /usr/local/bin/hciconfig "$dev" | grep -qE "BD Address: (B8:27:EB|DC:A6:32):" || return 0
  /usr/local/bin/hcitool -i "$dev" cmd 0x3f 0x1c 0x01 0x02 0x00 0x01 0x01 > /dev/null

                ---------
Change-log:     2020/08/23 First version, 5.54
Current:        2020/11/29 Upgraded to 5.55 (added midi and gatttool support)
