Title:          bluez.tcz
Description:    bluetooth stack
Version:        5.66
Author:         see list of sites below
Original-site:  see list of sites below
Copying-policy: see list of sites below
Size:           1.7MB
Extension_by:   juanito
Tags:           bluetooth
Comments:       official linux bluetooth protocol stack
                ----------
                use blueman to pair
                use libbluetooth for apps requiring bluez-4 compatibility

                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



                ----------
                This extension contains:
                bluez-5.66 - GPLv2 - https://www.kernel.org/pub/linux/bluetooth/bluez-5.66.tar.xz
                ----------
Change-log:     2017/03/12 first version
                2020/04/20 updated 5.43 -> 5.54
                2020/08/29 Rebuilt with rpi patches, 5.54 (paul-123)
                2020/11/29 Upraded to 5.55 (added midi and gatttool support) (paul-123)
                2021/06/02 Downgrade to 5.50 with all rpiOS patches (paul-123)
                2021/07/24 Upgrade back to 5.55 with all rpiOS patches (paul-123)
Current:        2023/06/04 Upgrade to 5.66 with all Debian + rpi firmware patch (paul-123)