Advertisement
Guest User

Untitled

a guest
Jun 5th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Maximum number of attempts to enable hcismd to try to get
  4. # hci0 to come online. Writing to sysfs too early seems to
  5. # not work, so we loop.
  6. MAXTRIES=15
  7.  
  8. #setprop bluetooth.hciattach true
  9. i=1
  10. while [ ! $i -gt $MAXTRIES ] ; do
  11. echo 1 > /sys/module/hci_smd/parameters/hcismd_set
  12. if [ -e /sys/class/bluetooth/hci0 ] ; then
  13. # found hci0, exit successfully
  14. echo 0 > /sys/module/hci_smd/parameters/hcismd_set
  15. bt_mac=$(/system/bin/hci_qcomm_init -e -p 2 -P 2 -d /dev/ttyHSL0 2>1 | grep -oP '([0-9a-f]{2}:){5}([0-9a-f]{2})')
  16. echo "BT MAC: $bt_mac"
  17. if [ ! -z "$bt_mac" ] ; then
  18. echo $bt_mac > /var/lib/bluetooth/board-address
  19. echo "BT MAC: $bt_mac"
  20. fi
  21. echo 1 > /sys/module/hci_smd/parameters/hcismd_set
  22. exit 0
  23. fi
  24. sleep 1
  25. if [ $i == $MAXTRIES ] ; then
  26. # must have gotten through all our retries, fail
  27. exit 1
  28. fi
  29.  
  30. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement