diff options
Diffstat (limited to 'scripts/bt-dev-start-c210.sh')
-rwxr-xr-x | scripts/bt-dev-start-c210.sh | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/scripts/bt-dev-start-c210.sh b/scripts/bt-dev-start-c210.sh index 386fd24..1be1b62 100755 --- a/scripts/bt-dev-start-c210.sh +++ b/scripts/bt-dev-start-c210.sh @@ -4,6 +4,7 @@ BT_UART_DEVICE=/dev/ttySAC0 BT_CHIP_TYPE=bcm2035 BCM_TOOL=/usr/bin/bcmtool_4330b1 +BT_ADDR=/csa/bluetooth/.bd_addr BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile" UART_SPEED=3000000 @@ -22,10 +23,13 @@ then mknod $BT_UART_DEVICE c 204 64 fi -if [ ! -e /csa/bluetooth/.bd_addr ] +# Set BT address: This will internally check for the file presence +/usr/bin/setbd + +#if the setbd return non 0, which means incorrect bd address file, then exit +if [ $? -ne 0 ] then - # Set BT address - /usr/bin/setbd + exit 1 fi # Trun-on Bluetooth Chip @@ -39,14 +43,38 @@ else echo "Bluetooth device is DOWN" echo "Registering Bluetooth device" - $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=/csa/bluetooth/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1 + $BCM_TOOL $BT_UART_DEVICE -FILE=/usr/etc/bluetooth/$BCM_FIRMWARE -BAUD=$UART_SPEED -ADDR=$BT_ADDR -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1 & + bcmtool_pid=$! + #Check next 2.4 seconds for bcmtool success + for (( i=1; i<=24; i++)) + do + sleep 0.1 + kill -0 $bcmtool_pid + bcmtool_alive=$? + + if [ $i -eq 24 ] + then + echo "time expired happen $i" + kill -TERM $bcmtool_pid + rfkill block bluetooth + exit 1 + fi + + if [ $bcmtool_alive -eq 0 ] + then + echo "Continue....$i" + continue + else + echo "Break.......$i" + break + fi + done # Attaching Broadcom device if (/usr/sbin/hciattach $BT_UART_DEVICE -s $UART_SPEED $BT_CHIP_TYPE $UART_SPEED flow); then sleep 0.1 - /usr/sbin/hciconfig hci0 up - /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME - /usr/sbin/hciconfig hci0 sspmode 1 + /usr/sbin/hciconfig hci0 name $BT_PLATFORM_DEFAULT_HCI_NAME + /usr/sbin/hciconfig hci0 sspmode 1 echo "HCIATTACH success" else echo "HCIATTACH failed" |