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 <hector.palacios@digi.com>
This commit is contained in:
parent
84e152f1ca
commit
ee27c907d1
|
|
@ -70,8 +70,9 @@ bt_init() {
|
||||||
RETRIES="5"
|
RETRIES="5"
|
||||||
while [ "${RETRIES}" -gt "0" ]; do
|
while [ "${RETRIES}" -gt "0" ]; do
|
||||||
hciattach ttyBt ath3k 4000000 1>/dev/null && break
|
hciattach ttyBt ath3k 4000000 1>/dev/null && break
|
||||||
|
if [ -n "${BT_PWR_GPIO_NR}" ]; then
|
||||||
#
|
#
|
||||||
# If hciattach fails try to recover it by toggling the GPIO
|
# If hciattach fails try to recover it by toggling the BT power GPIO
|
||||||
#
|
#
|
||||||
BT_PWR_L="/sys/class/gpio/gpio${BT_PWR_GPIO_NR}"
|
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
|
[ -d "${BT_PWR_L}" ] || printf "%s" ${BT_PWR_GPIO_NR} > /sys/class/gpio/export
|
||||||
|
|
@ -79,6 +80,9 @@ bt_init() {
|
||||||
printf 0 > ${BT_PWR_L}/value && sleep .2
|
printf 0 > ${BT_PWR_L}/value && sleep .2
|
||||||
printf 1 > ${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
|
[ -d "${BT_PWR_L}" ] && printf "%s" ${BT_PWR_GPIO_NR} > /sys/class/gpio/unexport
|
||||||
|
else
|
||||||
|
sleep .5
|
||||||
|
fi
|
||||||
RETRIES="$((RETRIES - 1))"
|
RETRIES="$((RETRIES - 1))"
|
||||||
done
|
done
|
||||||
if [ "${RETRIES}" -eq "0" ]; then
|
if [ "${RETRIES}" -eq "0" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue