Modify bt-stack-up.sh script for TM2 device
[platform/core/connectivity/bluetooth-tools.git] / scripts / wearable / bt-stack-up.sh
1 #!/bin/sh
2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
3
4 HCIDUMP_DIR="/opt/usr/media/.bluetooth"
5 HCIDUMP_FILENAME="bt_hcidump.log"
6 HCIDUMP_PATH="${HCIDUMP_DIR}/${HCIDUMP_FILENAME}"
7 LOGDUMP_DIR="/opt/etc/dump.d/module.d"
8 LOGDUMP_PATH="${LOGDUMP_DIR}/bt-hci-logdump.sh"
9 RFKILL=/usr/sbin/rfkill
10 GREP=/usr/bin/grep
11 HFP_HF=hfp_hf
12
13 echo "Check for bcm43012 device - TM2"
14 if (${RFKILL} list | ${GREP} bcm43012); then
15         echo "Solis TM2 device"
16         HFP_AG=hfp_ag
17 fi
18
19 if [ $HFP_HF ]
20 then
21 /usr/bin/bluetooth-hf-agent &
22 fi
23
24 if [ $HFP_AG ]
25 then
26 /usr/bin/bluetooth-ag-agent &
27 fi
28
29 #
30 # Script for executing Bluetooth stack
31 #
32
33 # Register BT Device
34 /usr/etc/bluetooth/bt-dev-start.sh
35
36 if !(/usr/bin/hciconfig | grep hci); then
37         echo "Registering BT device is failed."
38         exit 1
39 fi
40
41 debug_mode=`cat /sys/module/sec_debug/parameters/enable`
42 debug_mode_user=`cat /sys/module/sec_debug/parameters/enable_user`
43
44 if [ ${debug_mode} = '1' -o ${debug_mode_user} = '1' ]
45 then
46         if [ -e /usr/sbin/hcidump ]
47         then
48                 # When *#9900# is typed, this is executed to archive logs. #
49                 /bin/mkdir -p ${LOGDUMP_DIR}
50                 /bin/cp -f /usr/etc/bluetooth/bt-hci-logdump.sh ${LOGDUMP_PATH}
51
52                 /bin/mkdir -p ${HCIDUMP_DIR}/old_hcidump
53                 /bin/rm -f ${HCIDUMP_DIR}/old_hcidump/*
54                 /bin/mv ${HCIDUMP_PATH}* ${HCIDUMP_DIR}/old_hcidump/
55                 /usr/sbin/hcidump -w ${HCIDUMP_PATH} &
56         fi
57 elif [ -e ${HCIDUMP_DIR} ]
58 then
59         /bin/rm -rf ${HCIDUMP_DIR}
60 fi
61
62 # Execute BlueZ BT stack
63 echo "Run bluetoothd"
64 /usr/libexec/bluetooth/bluetoothd -d -C &
65 /usr/bin/dbus-send --print-reply --system --type=method_call \
66                 --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 \
67                 org.freedesktop.systemd1.Manager.StartUnit \
68                 string:'wms.service' string:'fail'
69
70 exit 0