Skip to content

Commit ce09f03

Browse files
authored
rc.local script that starts BLE programming running at boot
be careful, paths and such need careful look to make sure what user is running. Also, this setup uses TMUX to keep the program running, not the best way.
1 parent 164c3ed commit ce09f03

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

rc.local

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
########!/bin/sh -e
4+
#
5+
# rc.local
6+
#
7+
# This script is executed at the end of each multiuser runlevel.
8+
# Make sure that the script will "exit 0" on success or any other
9+
# value on error.
10+
#
11+
# In order to enable or disable this script just change the execution
12+
# bits.
13+
#
14+
# By default this script does nothing.
15+
16+
# Print the IP address
17+
_IP=$(hostname -I) || true
18+
if [ "$_IP" ]; then
19+
printf "My IP address is %s\n" "$_IP"
20+
fi
21+
22+
# wait for networks to start
23+
24+
STATE="error";
25+
26+
while [ $STATE == "error" ]; do
27+
#do a ping and check that its not a default message or change to grep for something else
28+
STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)
29+
30+
#sleep for 2 seconds and try again
31+
sleep 2
32+
done
33+
34+
su pi -c 'tmux new-session -d -s ble'
35+
su pi -c 'tmux send-keys sudo Space /home/pi/atc-govee/hack_ble.sh C-m'
36+
37+
38+
exit 0
39+

0 commit comments

Comments
 (0)