jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 1 | #!/system/bin/sh |
| 2 | |
| 3 | BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto |
| 4 | LOG_TAG="mako-bluetooth" |
| 5 | LOG_NAME="${0}:" |
| 6 | |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 7 | loge () |
| 8 | { |
| 9 | /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@" |
| 10 | } |
| 11 | |
| 12 | logi () |
| 13 | { |
| 14 | /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@" |
| 15 | } |
| 16 | |
| 17 | failed () |
| 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 | |
| 26 | POWER_CLASS=`getprop qcom.bt.dev_power_class` |
| 27 | TRANSPORT=`getprop ro.qualcomm.bt.hci_transport` |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 28 | DUTADDR=`getprop net.btdut.address` |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 29 | |
| 30 | #find the transport type |
| 31 | logi "Transport : $TRANSPORT" |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 32 | logi "DUTADDR : $DUTADDR" |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 33 | |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 34 | #load bd addr |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 35 | if [$DUTADDR == ""] |
| 36 | then |
| 37 | BDADDR=`/system/bin/bdAddrLoader -f /persist/bluetooth/.bdaddr -h -x` |
| 38 | else |
| 39 | BDADDR=`/system/bin/bdAddrLoader -p net.btdut.address -s -x` |
| 40 | fi |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 41 | |
Jeonghoon lim | 0a3bd80 | 2012-08-14 18:08:24 -0700 | [diff] [blame] | 42 | setprop bluetooth.status off |
| 43 | |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 44 | logi "BDADDR: $BDADDR" |
| 45 | |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 46 | case $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>";; |
| 56 | esac |
| 57 | |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 58 | if [$BDADDR == ""] |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 59 | then |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 60 | logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS -vv |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 61 | else |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 62 | logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS -vv |
jeonghoon.lim | 85ddb8c | 2012-07-20 11:35:54 +0900 | [diff] [blame] | 63 | fi |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 64 | |
| 65 | case $? in |
jeonghoon.lim | 668b0cc | 2012-08-23 13:10:57 +0900 | [diff] [blame] | 66 | 0) logi "Bluetooth QSoC firmware download succeeded, $PWR_CLASS $BDADDR $TRANSPORT";; |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 67 | *) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init; |
Jeonghoon lim | 0a3bd80 | 2012-08-14 18:08:24 -0700 | [diff] [blame] | 68 | setprop bluetooth.status off; |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 69 | exit $exit_code_hci_qcomm_init;; |
| 70 | esac |
| 71 | |
Jeonghoon lim | 0a3bd80 | 2012-08-14 18:08:24 -0700 | [diff] [blame] | 72 | setprop bluetooth.status on |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 73 | |
Jeonghoon lim | 0a3bd80 | 2012-08-14 18:08:24 -0700 | [diff] [blame] | 74 | logi "start bluetooth smd transport" |
jeonghoon.lim | 6a2ca5a | 2012-07-13 13:00:37 -0700 | [diff] [blame] | 75 | |
| 76 | exit 0 |