From: Bernhard Tittelbach Date: Tue, 26 Mar 2019 12:03:26 +0000 (+0100) Subject: start stop X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=faacfda6875f406ba37b0f87e3f518ed2389fc4e;p=201903hackathon.git start stop --- diff --git a/bt_connect_bobbycar.service b/bt_connect_bobbycar.service new file mode 100644 index 0000000..557d3bd --- /dev/null +++ b/bt_connect_bobbycar.service @@ -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 + diff --git a/bt_connect_bobbycar.sh b/bt_connect_bobbycar.sh index 74d97a9..a4782d9 100755 --- a/bt_connect_bobbycar.sh +++ b/bt_connect_bobbycar.sh @@ -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 index 0000000..95e318f --- /dev/null +++ b/bt_disconnect_bobbycar.sh @@ -0,0 +1,3 @@ +#!/bin/zsh +local BOBBYCAR=30:AE:A4:15:24:72 +sudo bluetoothctl <<< "disconnect $BOBBYCAR"