• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/system/bin/sh
2
3BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
4LOG_TAG="mako-bluetooth"
5LOG_NAME="${0}:"
6
7loge ()
8{
9  /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
10}
11
12logi ()
13{
14  /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
15}
16
17failed ()
18{
19  loge "$1: exit code $2"
20  exit $2
21}
22
23# Note that "hci_qcomm_init -e" prints expressions to set the shell variables
24# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS.
25
26POWER_CLASS=`getprop qcom.bt.dev_power_class`
27TRANSPORT=`getprop ro.qualcomm.bt.hci_transport`
28DUTADDR=`getprop net.btdut.address`
29
30#find the transport type
31logi "Transport : $TRANSPORT"
32logi "DUTADDR : $DUTADDR"
33
34#load bd addr
35if [$DUTADDR == ""]
36then
37BDADDR=`/system/bin/bdAddrLoader -f /persist/bluetooth/.bdaddr -h -x`
38else
39BDADDR=`/system/bin/bdAddrLoader -p net.btdut.address -s -x`
40fi
41
42setprop bluetooth.status off
43
44logi "BDADDR: $BDADDR"
45
46case $POWER_CLASS in
47  1) PWR_CLASS="-p 0" ;
48     logi "Power Class: 1";;
49  2) PWR_CLASS="-p 1" ;
50     logi "Power Class: 2";;
51  3) PWR_CLASS="-p 2" ;
52     logi "Power Class: CUSTOM";;
53  *) PWR_CLASS="";
54     logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
55     logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";;
56esac
57
58if [$BDADDR == ""]
59then
60logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS -vv
61else
62logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS -vv
63fi
64
65case $? in
66  0) logi "Bluetooth QSoC firmware download succeeded, $PWR_CLASS $BDADDR $TRANSPORT";;
67  *) failed "Bluetooth QSoC firmware download failed" $?;
68     setprop bluetooth.status off;
69     exit $?;;
70esac
71
72setprop bluetooth.status on
73
74logi "start bluetooth smd transport"
75
76exit 0
77