Advertisement
Guest User

Init blutooth without systemd

a guest
Jul 23rd, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.96 KB | None | 0 0
  1. #! /bin/sh
  2.  
  3. gpio_start()
  4. {
  5.     echo 10 > /sys/class/gpio/export
  6.    
  7.     if [ -d /sys/class/gpio/gpio10 ]
  8.     then
  9.         echo out > /sys/class/gpio/gpio10/direction
  10.         echo 0 > /sys/class/gpio/gpio10/value
  11.         echo 1 > /sys/class/gpio/gpio10/value
  12.  
  13.         echo "GPIO OK"
  14.     else
  15.         echo "GPIO error"
  16.     fi
  17.  
  18.     return 0
  19. }
  20.  
  21. modprobe bluetooth
  22. modprobe hci_uart
  23. modprobe bnep
  24. modprobe rfcomm
  25.  
  26. if [ -f "/lib/firmware/ap6212/bcm43438a0.hcd" ]
  27. then
  28.         mkdir -p /etc/firmware/ap6212
  29.         cp /lib/firmware/ap6212/bcm43438a0.hcd /etc/firmware/ap6212/4343A0.hcd
  30. fi
  31.  
  32.  
  33. PORT="ttyS1"
  34.  
  35. if [ @? ]
  36. then
  37.     btattach -B /dev/$PORT &
  38.  
  39.     sleep 0.5
  40.     rfcomm
  41.  
  42.     /usr/libexec/bluetooth/bluetoothd -d &
  43. fi
  44.  
  45. /usr/sbin/rfkill "unblock" "all"
  46.  
  47. if [ @? ]
  48. then
  49.     echo "BT unlocked"
  50.     devmem2 0x1f00060 b 1
  51.     gpio_start
  52.     sleep 0.5
  53.  
  54.     if [ -n $(hciconfig hci0 up) ]
  55.     then
  56.         echo "Bluetooth ready"
  57.         return 0
  58.     else
  59.         echo "Error bluetooth"
  60.         return 1
  61.     fi
  62.  
  63. else
  64.     echo "BT locked"
  65. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement