meta-digi-dey: bluez5-5.41: ccimx6ul: Rewrite bluetooth-init

The following changes have been made to the bluetooth-init script:

* Remove "hciconfig hci0 up/down" and this is now deprecated and likely
to fail. We use the AutoEnable feature of bluetoothd for this now.
* Move setting the MAC address to hciattach instead of using hcitool.
* Remove resets performed by hcitool and hciconfig. The hciattach
application already performs a reset and that should suffice.
* Remove hciattach retries.

https://jira.digi.com/browse/DEL-3711
https://jira.digi.com/browse/DEL-3436
https://jira.digi.com/browse/DEL-3636
https://jira.digi.com/browse/DEL-3955

Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
Alex Gonzalez 2017-04-06 13:27:19 +02:00
parent ae8e695cf7
commit d776c9c282
1 changed files with 9 additions and 63 deletions

View File

@ -67,66 +67,13 @@ bluetooth_init() {
# Start the Bluetooth driver and bring up the interface # Start the Bluetooth driver and bring up the interface
HCIATTACH_LOG="/var/log/hciattach.log" HCIATTACH_LOG="/var/log/hciattach.log"
BT_CMD="HCIATTACH" killproc hciattach
RETRIES="5" powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
while [ "${RETRIES}" -gt "0" ]; do if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
case "${BT_CMD}" in echo "[OK]"
HCIATTACH) else
# Reset BT echo "[FAIL]"
killproc hciattach fi
powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if hciattach ttyBt qca ${BT_RATE:-3000000} ${BT_FLOW:-flow} >${HCIATTACH_LOG} 2>&1; then
BT_CMD="HCICONFIG_UP"
else
BT_ERROR="FAILED (hciattach)"
BT_CMD="BT_INIT_FAIL"
fi
;;
HCICONFIG_UP)
if hciconfig hci0 up; then
BT_CMD="HCITOOL_SETMAC"
else
BT_ERROR="FAILED (hciconfig up)"
BT_CMD="BT_INIT_FAIL"
fi
;;
HCITOOL_SETMAC)
#
# Set the MAC address (the interface needs to be up to send HCI commands)
#
# Convert it to the format accepted by 'hcitool' ("00:04:F3:11:22:33" -> "33 22 11 F3 04 00")
#
HCI_MACADDR="$(echo ${BT_MACADDR} | tr ':' '\n' | tac | tr '\n' ' ' | sed -e 's/ $//g')"
if hcitool -i hci0 cmd 3F 000B 01 02 06 ${HCI_MACADDR} >/dev/null; then
BT_CMD="HCITOOL_RESET"
else
BT_ERROR="FAILED (hcitool set MAC)"
BT_CMD="BT_INIT_FAIL"
fi
;;
HCITOOL_RESET)
if hcitool -i hci0 cmd 03 0003 00 >/dev/null; then
BT_CMD="HCICONFIG_RESET"
else
BT_ERROR="FAILED (hcitool reset)"
BT_CMD="BT_INIT_FAIL"
fi
;;
HCICONFIG_RESET)
if hciconfig hci0 reset; then
break
else
BT_ERROR="FAILED (hciconfig reset)"
BT_CMD="BT_INIT_FAIL"
fi
;;
BT_INIT_FAIL)
RETRIES="$((RETRIES - 1))"
BT_CMD="HCIATTACH"
;;
esac
done
[ "${RETRIES}" = "0" ] && error "${BT_ERROR}"
} }
# Source function library # Source function library
@ -137,17 +84,16 @@ case "$1" in
if [ -d "/proc/device-tree/bluetooth" ]; then if [ -d "/proc/device-tree/bluetooth" ]; then
echo -n "Starting bluetooth hardware: " echo -n "Starting bluetooth hardware: "
bluetooth_init bluetooth_init
echo "done." echo "${BT_ERROR:-done.}"
fi fi
;; ;;
stop) stop)
if [ -d "/sys/class/bluetooth/hci0" ]; then if [ -d "/sys/class/bluetooth/hci0" ]; then
echo -n "Stopping bluetooth hardware: " echo -n "Stopping bluetooth hardware: "
hciconfig hci0 down || BT_ERROR="FAILED (hciconfig down)"
killproc hciattach killproc hciattach
# Power down bluetooth # Power down bluetooth
set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0 set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0
echo "${BT_ERROR:-done.}" echo "done."
fi fi
;; ;;
restart) restart)