summaryrefslogtreecommitdiff
path: root/scripts/bt-dev-start.sh
blob: 7a3e70f250765a406a48de32bb0c3a6c010b03f4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh

# Script for registering Broadcom UART BT device
BT_UART_DEVICE=/dev/ttySAC0
BT_CHIP_TYPE=bcm2035
BCM_TOOL=/usr/bin/bcmtool_4330b1

BT_PLATFORM_DEFAULT_HCI_NAME="TIZEN-Mobile"
UART_SPEED=921600

#set default firmware
BCM_FIRMWARE=BCM4330B1_002.001.003.0221.0265.hcd

REVISION_NUM=`grep Revision /proc/cpuinfo | awk "{print \\$3}"`
REVISION_HIGH=`echo $REVISION_NUM| cut -c1-2`
REVISION_LOW=`echo $REVISION_NUM| cut -c3-`

HARDWARE=`grep Hardware /proc/cpuinfo | awk "{print \\$3}"`

if [ ! -e "$BT_UART_DEVICE" ]
then
	mknod $BT_UART_DEVICE c 204 64
fi

if [ ! -e /opt/etc/.bd_addr ]
then
	# Set BT address
	/usr/bin/setbd
fi

# Trun-on Bluetooth Chip
rfkill unblock bluetooth

echo "Check for Bluetooth device status"
if (/usr/sbin/hciconfig | grep hci); then
	echo "Bluetooth device is UP"
	/usr/sbin/hciconfig hci0 up
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=/opt/etc/.bd_addr -SETSCO=0,0,0,0,0,0,0,3,3,0 -LP > /dev/null 2>&1

	# 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
		echo "HCIATTACH success"
	else
		echo "HCIATTACH failed"
		rfkill block bluetooth
	fi
fi