From ee27c907d102e56ed52251ead25a2785a5e71af3 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 28 Dec 2015 12:25:40 +0100 Subject: [PATCH] bluez-init: skip BT power GPIO toggling if undefined The script toggles the BT power GPIO regardless of the value being undefined. Check that the GPIO is defined before trying to toggle it. Signed-off-by: Hector Palacios --- .../bluez/bluez5/bluez-init | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5/bluez-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5/bluez-init index 9d1b967a0..8e42e5b26 100755 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5/bluez-init +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5/bluez-init @@ -70,15 +70,19 @@ bt_init() { 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 + if [ -n "${BT_PWR_GPIO_NR}" ]; then + # + # If hciattach fails try to recover it by toggling the BT power 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 + else + sleep .5 + fi RETRIES="$((RETRIES - 1))" done if [ "${RETRIES}" -eq "0" ]; then