start stop
authorBernhard Tittelbach <bernhard@tittelbach.org>
Tue, 26 Mar 2019 12:03:26 +0000 (13:03 +0100)
committerBernhard Tittelbach <bernhard@tittelbach.org>
Tue, 26 Mar 2019 12:03:26 +0000 (13:03 +0100)
bt_connect_bobbycar.service [new file with mode: 0644]
bt_connect_bobbycar.sh
bt_disconnect_bobbycar.sh [new file with mode: 0755]

diff --git a/bt_connect_bobbycar.service b/bt_connect_bobbycar.service
new file mode 100644 (file)
index 0000000..557d3bd
--- /dev/null
@@ -0,0 +1,18 @@
+[Unit]
+Description=start bt_connect_bobbycar.sh
+Requires=bluetooth.target
+After=bluetooth.target
+
+[Service]
+Type=simple
+Restart=always
+RestartSec=5
+User=pi
+WorkingDirectory=/home/pi/2019-03-letsCluster-Hackathon/201903hackathon
+ExecStart=/home/pi/2019-03-letsCluster-Hackathon/201903hackathon/bt_connect_bobbycar.sh
+ExecStop=/home/pi/2019-03-letsCluster-Hackathon/201903hackathon/bt_disconnect_bobbycar.sh
+SyslogIdentifier=%i
+
+[Install]
+WantedBy=multi-user.target
+
index 74d97a9..a4782d9 100755 (executable)
@@ -1,7 +1,11 @@
 #!/bin/zsh
 local BOBBYCAR=30:AE:A4:15:24:72
+local RFDEV=/dev/rfcomm1
+sudo bluetoothctl <<< "disconnect $BOBBYCAR"
+sleep 5
 sudo bluetoothctl <<< "connect $BOBBYCAR"
+sudo bluetoothctl <<< "trust $BOBBYCAR"
+sleep 8
+sudo rfcomm bind $RFDEV $BOBBYCAR  1
 sleep 3
-sudo rfcomm bind /dev/rfcomm1 $BOBBYCAR  1
-sleep 3
-./cpp/openCVnaiveObstacleAvoidance/openCVnaiveObstacleAvoidance > /dev/rfcomm1
\ No newline at end of file
+./cpp/openCVnaiveObstacleAvoidance/openCVnaiveObstacleAvoidance > $RFDEV
diff --git a/bt_disconnect_bobbycar.sh b/bt_disconnect_bobbycar.sh
new file mode 100755 (executable)
index 0000000..95e318f
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/zsh
+local BOBBYCAR=30:AE:A4:15:24:72
+sudo bluetoothctl <<< "disconnect $BOBBYCAR"