bluetooth-init: if hciattach fails, reset the BT interface and retry

With these changes the hciattach mechanism is retried up to 5 times.
Signed-off-by: Sebastian Pastor <sebastian.pastor@digi.com>

https://jira.digi.com/browse/DEL-5343
https://jira.digi.com/browse/DEL-3711
This commit is contained in:
Sebastian Pastor 2017-11-28 15:40:39 +01:00
parent 7937aade49
commit c6b424d8cc
2 changed files with 22 additions and 10 deletions

View File

@ -48,11 +48,17 @@ 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"
for RETRY in $(seq 1 5)
do
killproc hciattach killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}" powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if ! hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
BT_ERROR="FAIL (hciattach)" return
fi fi
sleep 1
done
BT_ERROR="FAIL (hciattach)"
} }
# Source function library # Source function library

View File

@ -67,11 +67,17 @@ 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"
for RETRY in $(seq 1 5)
do
killproc hciattach killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}" powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if ! hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
BT_ERROR="FAIL (hciattach)" return
fi fi
sleep 1
done
BT_ERROR="FAIL (hciattach)"
} }
# Source function library # Source function library