Code sync: merged tizen 2.4 base source code
[platform/core/connectivity/bluetooth-tools.git] / scripts / bt-edutm-on.sh
1 #!/bin/sh
2
3 #
4 # Script for turning on Bluetooth EDUTM
5 #
6
7 HCIDUMP_ENABLE="true"   # Available values : true | false (default : false)
8 HCIDUMP_DIR="/opt/usr/media/.bt_dump"
9 HCIDUMP_FILENAME="bt_hcidump.log"
10 HCIDUMP_PATH="${HCIDUMP_DIR}/${HCIDUMP_FILENAME}"
11 LOGDUMP_DIR="/opt/etc/dump.d/module.d"
12 LOGDUMP_PATH="${LOGDUMP_DIR}/bt-hci-logdump.sh"
13
14 # Register BT Device
15 /usr/etc/bluetooth/bt-dev-start.sh
16
17 if !(/usr/bin/hciconfig | /bin/grep hci); then
18         echo "BT EDUTM failed. Registering BT device is failed."
19         exit 1
20 fi
21
22 if [ -e /usr/sbin/hcidump -a ${HCIDUMP_ENABLE} = "true" ]
23 then
24         # When *#9900# is typed, this is executed to archive logs. #
25         /bin/mkdir -p ${LOGDUMP_DIR}
26         /bin/cp -f /usr/etc/bluetooth/bt-hci-logdump.sh ${LOGDUMP_PATH}
27
28         /bin/mkdir -p ${HCIDUMP_DIR}/old_hcidump
29 #       /bin/rm -f ${HCIDUMP_DIR}/old_hcidump/*
30         /bin/mv ${HCIDUMP_PATH}* ${HCIDUMP_DIR}/old_hcidump/
31         /usr/sbin/hcidump -w ${HCIDUMP_PATH}_`date +%s_%N` &    # You can get unique file name.
32 #       /usr/sbin/hcidump -w ${HCIDUMP_PATH} &
33 fi
34
35 echo "Configure BT device"
36 /usr/bin/hcitool cmd 0x3 0x0005 0x02 0x00 0x02
37
38 echo "Send BT edutm command"
39 /usr/bin/hcitool cmd 0x06 0x0003
40
41 # Execute BlueZ BT stack
42 echo "Run bluetoothd"
43 /usr/lib/bluetooth/bluetoothd &
44 /usr/bin/bt-service &
45 /bin/sleep 0.1
46
47 /usr/bin/hciconfig hci0 name TIZEN-Mobile
48
49 /usr/bin/hciconfig hci0 piscan
50
51 if [ -e "/sys/devices/hci0/idle_timeout" ]
52 then
53         echo "Set idle time"
54         echo 0 > /sys/devices/hci0/idle_timeout
55 fi
56
57 if [ -e /usr/etc/bluetooth/TIInit_* ]
58 then
59         echo "Reset device"
60         /usr/bin/hcitool cmd 0x3 0xFD0C
61 fi
62
63 echo "BT edutm done"
64
65 # result
66 exit 0