bluez4: Added support for bluez4
yocto-2.0 (jethro) does not support bluez4 by default, it has been set deprecated, but there is some functionality that does not work with bluez5 like bluetooth audio with alsa and some previous scripts like hdp.py are not API compatible. In order to compile a project with bluez4, just remove bluez5 from distro features from your local.conf project. DISTRO_FEATURES_remove = "bluez5" https://jira.digi.com/browse/DEL-1943 https://jira.digi.com/browse/DEL-995 Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
parent
3b3a8effa6
commit
be39d77093
|
|
@ -0,0 +1,101 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# bluez
|
||||
#
|
||||
# Copyright (C) 2015 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: Configure Bluetooth
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
if [ "${1}" != "start" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPTNAME="$(basename "${0}")"
|
||||
MACHINENAME="$(cat /proc/device-tree/digi,machine,name 2>/dev/null)"
|
||||
|
||||
bt_init() {
|
||||
if [ "${MACHINENAME}" = "ccardimx28" ]; then
|
||||
BT_PWR_GPIO_NR="21"
|
||||
elif [ "${MACHINENAME}" = "ccimx6sbc" ]; then
|
||||
BT_PWR_GPIO_NR="244"
|
||||
fi
|
||||
|
||||
# Use a sub-shell here to change to firmware directory
|
||||
(
|
||||
cd /lib/firmware/ar3k/1020200
|
||||
|
||||
# Get MAC address from device tree or NVRAM. Use a default value it it has not been set.
|
||||
if [ -f "/proc/device-tree/bluetooth/mac-address" ]; then
|
||||
BTADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address | sed 's/:$//g')"
|
||||
else
|
||||
BTADDR="$(sed -ne 's,^.*btaddr1=\([^[:blank:]]\+\)[:blank:]*.*,\1,g;T;p' /proc/cmdline)"
|
||||
fi
|
||||
if [ -z "${BTADDR}" ] || [ "${BTADDR}" = "00:00:00:00:00:00" ]; then
|
||||
BTADDR="00:04:F3:FF:FF:BB"
|
||||
fi
|
||||
|
||||
# Update the MAC address file only if it has changed.
|
||||
FW_MAC="ar3kbdaddr.pst"
|
||||
[ -f "${FW_MAC}" ] && [ "$(cat ${FW_MAC})" = "${BTADDR}" ] || echo ${BTADDR} > ${FW_MAC}
|
||||
|
||||
JPN_REGCODE="0x2"
|
||||
REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null)"
|
||||
BT_CLASS_LINK="PS_ASIC.pst"
|
||||
BT_CLASS_FILE="PS_ASIC_class_1.pst"
|
||||
if [ -n "${REGCODE}" ] && [ "${JPN_REGCODE}" = "${REGCODE}" ]; then
|
||||
BT_CLASS_FILE="PS_ASIC_class_2.pst"
|
||||
fi
|
||||
|
||||
# Replace the configuration file if different
|
||||
if ! cmp -s ${BT_CLASS_FILE} ${BT_CLASS_LINK}; then
|
||||
ln -sf ${BT_CLASS_FILE} ${BT_CLASS_LINK}
|
||||
fi
|
||||
# Remove not used configuration and readme files
|
||||
# -- Do not quote the subcommand to avoid leading/trailing whitespace
|
||||
# -- being part of the file name.
|
||||
rm -f $(echo PS_ASIC_class_?.pst | sed -e "s,${BT_CLASS_FILE},,g") readme.txt
|
||||
)
|
||||
|
||||
# Start the Bluetooth driver and daemon (D-BUS must already be running)
|
||||
RETRIES="5"
|
||||
while [ "${RETRIES}" -gt "0" ]; do
|
||||
hciattach ttyBt ath3k 4000000 1>/dev/null && break
|
||||
#
|
||||
# If hciattach fails try to recover it by toggling the GPIO
|
||||
#
|
||||
BT_PWR_L="/sys/class/gpio/gpio${BT_PWR_GPIO_NR}"
|
||||
[ -d "${BT_PWR_L}" ] || printf "%s" ${BT_PWR_GPIO_NR} > /sys/class/gpio/export
|
||||
printf out > ${BT_PWR_L}/direction && sleep .2
|
||||
printf 0 > ${BT_PWR_L}/value && sleep .2
|
||||
printf 1 > ${BT_PWR_L}/value && sleep .2
|
||||
[ -d "${BT_PWR_L}" ] && printf "%s" ${BT_PWR_GPIO_NR} > /sys/class/gpio/unexport
|
||||
RETRIES="$((RETRIES - 1))"
|
||||
done
|
||||
if [ "${RETRIES}" -eq "0" ]; then
|
||||
echo "${SCRIPTNAME}: FAILED (hciattach)"
|
||||
exit
|
||||
fi
|
||||
if hciconfig hci0 up; then
|
||||
: # No-op
|
||||
else
|
||||
echo "${SCRIPTNAME}: FAILED"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Starting bluetooth services."
|
||||
bluetoothd
|
||||
|
||||
# Check if this hardware does support Bluetooth
|
||||
[ -d "/proc/device-tree/bluetooth" ] && bt_init
|
||||
|
|
@ -12,8 +12,18 @@ EXTRA_OECONF_append = " --enable-health --enable-static"
|
|||
#
|
||||
INSANE_SKIP_${PN} = "installed-vs-shipped"
|
||||
|
||||
SRC_URI += "file://audio.conf"
|
||||
inherit update-rc.d
|
||||
|
||||
SRC_URI += " \
|
||||
file://audio.conf \
|
||||
file://bluez-init \
|
||||
"
|
||||
|
||||
do_install_append() {
|
||||
install -m 0644 ${WORKDIR}/audio.conf ${D}/${sysconfdir}/bluetooth/
|
||||
install -m 0644 ${WORKDIR}/audio.conf ${D}/${sysconfdir}/bluetooth/
|
||||
install -d ${D}${sysconfdir}/init.d/
|
||||
install -m 0755 ${WORKDIR}/bluez-init ${D}${sysconfdir}/init.d/bluez
|
||||
}
|
||||
|
||||
INITSCRIPT_NAME = "bluez"
|
||||
INITSCRIPT_PARAMS = "start 10 5 ."
|
||||
|
|
|
|||
Loading…
Reference in New Issue