Home | History | Annotate | Download | only in mako
      1 #!/system/bin/sh
      2 
      3 BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
      4 LOG_TAG="mako-bluetooth"
      5 LOG_NAME="${0}:"
      6 
      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`
     28 DUTADDR=`getprop net.btdut.address`
     29 
     30 #find the transport type
     31 logi "Transport : $TRANSPORT"
     32 logi "DUTADDR : $DUTADDR"
     33 
     34 #load bd addr
     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
     41 
     42 setprop bluetooth.status off
     43 
     44 logi "BDADDR: $BDADDR"
     45 
     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 
     58 if [$BDADDR == ""]
     59 then
     60 logwrapper /system/bin/hci_qcomm_init -e $PWR_CLASS -vv
     61 else
     62 logwrapper /system/bin/hci_qcomm_init -b $BDADDR -e $PWR_CLASS -vv
     63 fi
     64 
     65 case $? 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 $?;;
     70 esac
     71 
     72 setprop bluetooth.status on
     73 
     74 logi "start bluetooth smd transport"
     75 
     76 exit 0
     77