summaryrefslogtreecommitdiff
path: root/scripts/bt-dev-start.sh
blob: 863c00d78050c04dfee3113cfb75aba80b0c6603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin

GREP="/bin/grep"
HCI_CONFIG=/usr/bin/hciconfig

echo "Check for Bluetooth device status"
if (${HCI_CONFIG} | ${GREP} hci); then
	echo "Up the bluetooth device"
	${HCI_CONFIG} hci0 up
	exit 0
fi

/usr/sbin/rfkill unblock 0
/usr/bin/hciattach -n -s 115200 /dev/ttyS1 bcm43xx 2000000 &
/bin/sleep 0.1

TIMEOUT=20

for (( i=1; i<=$TIMEOUT; i++))
do
	if [ $i -eq $TIMEOUT ]
	then
		echo "time expired happen $i"
		exit 2
	fi

	echo "Check for Bluetooth device status"
	if (${HCI_CONFIG} | ${GREP} hci); then
		echo "Up the bluetooth device"
		${HCI_CONFIG} hci0 up

		if (${HCI_CONFIG} | ${GREP} UP); then
			echo "Bluetooth device is made"
			break
		fi
	fi

	/bin/sleep 0.1
	echo "Continue...$i"
done
exit 0