ee56a9d8060474bf7730dff76cba233a030affd0
[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
10 /usr/bin/bluetooth-hf-agent &
11 #
12 # Script for executing Bluetooth stack
13 #
14
15 # Register BT Device
16 /usr/etc/bluetooth/bt-dev-start.sh
17
18 if !(/usr/bin/hciconfig | grep hci); then
19         echo "Registering BT device is failed."
20         exit 1
21 fi
22
23 debug_mode=`cat /sys/module/sec_debug/parameters/enable`
24 debug_mode_user=`cat /sys/module/sec_debug/parameters/enable_user`
25
26 if [ ${debug_mode} = '1' -o ${debug_mode_user} = '1' ]
27 then
28         if [ -e /usr/sbin/hcidump ]
29         then
30                 # When *#9900# is typed, this is executed to archive logs. #
31                 /bin/mkdir -p ${LOGDUMP_DIR}
32                 /bin/cp -f /usr/etc/bluetooth/bt-hci-logdump.sh ${LOGDUMP_PATH}
33
34                 /bin/mkdir -p ${HCIDUMP_DIR}/old_hcidump
35                 /bin/rm -f ${HCIDUMP_DIR}/old_hcidump/*
36                 /bin/mv ${HCIDUMP_PATH}* ${HCIDUMP_DIR}/old_hcidump/
37                 /usr/sbin/hcidump -w ${HCIDUMP_PATH} &
38         fi
39 elif [ -e ${HCIDUMP_DIR} ]
40 then
41         /bin/rm -rf ${HCIDUMP_DIR}
42 fi
43
44 # Execute BlueZ BT stack
45 echo "Run bluetoothd"
46 /usr/libexec/bluetooth/bluetoothd -d -C &
47 /usr/bin/dbus-send --print-reply --system --type=method_call \
48                 --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 \
49                 org.freedesktop.systemd1.Manager.StartUnit \
50                 string:'wms.service' string:'fail'
51
52 exit 0