Apply next HAL architecture
[platform/hal/backend/vim3/bluetooth-vim3.git] / scripts / bt-dev-start.sh
1 #!/bin/sh
2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
3
4 GREP="/bin/grep"
5 HCI_CONFIG=/usr/bin/hciconfig
6
7 echo "Check for Bluetooth device status"
8 if (${HCI_CONFIG} | ${GREP} hci); then
9         echo "Up the bluetooth device"
10         ${HCI_CONFIG} hci0 up
11         exit 0
12 fi
13
14 /usr/sbin/rfkill unblock 0
15 /usr/bin/hciattach -n -s 115200 /dev/ttyS1 bcm43xx 2000000 &
16 /bin/sleep 0.1
17
18 TIMEOUT=20
19
20 for (( i=1; i<=$TIMEOUT; i++))
21 do
22         if [ $i -eq $TIMEOUT ]
23         then
24                 echo "time expired happen $i"
25                 exit 2
26         fi
27
28         echo "Check for Bluetooth device status"
29         if (${HCI_CONFIG} | ${GREP} hci); then
30                 echo "Up the bluetooth device"
31                 ${HCI_CONFIG} hci0 up
32
33                 if (${HCI_CONFIG} | ${GREP} UP); then
34                         echo "Bluetooth device is made"
35                         break
36                 fi
37         fi
38
39         /bin/sleep 0.1
40         echo "Continue...$i"
41 done
42 exit 0