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