-
Notifications
You must be signed in to change notification settings - Fork 1
/
ardroneconnect.sh
executable file
·72 lines (55 loc) · 1.67 KB
/
ardroneconnect.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
usage() {
cat << EOF
__ __ __ __ __
/\ |__) | \|__)/ \|\ ||_
/--\| \ . |__/| \ \__/| \||__
WPA/WPA2 support
This script connects the AR Drone to a WPA/WPA2 secured network.
Usage:
script/connect "<essid>" -p "<password>" [-a <address>] [-d <droneip>]
Note that order of arguments matters.
<essid>
Name of the WPA2 network to connect the drone to.
<password>
Password of the network.
<address>
(optional) Address to be set on the drone when connected to the
network. Use a different address than the router's default. Set to
"auto" (default) to let the router DHCP server auto-assign an IP.
<droneip>
(optional) Current drone's ip address. Default is 192.168.1.1
EOF
exit 1
}
ESSID=$1
PASSWORD=$3
DHCPC=""
DRONEIP=${7:-"192.168.1.1"}
ADDRESS=${5:-"auto"}
[[ -z $ESSID ]] && usage;
[[ -z $PASSWORD ]] && usage;
set -ue
echo "ESSID: $ESSID"
echo "PASSWORD: $PASSWORD"
echo "ADDRESS: $ADDRESS"
echo "DRONE_IP: $DRONEIP"
SCRIPT="\
wpa_passphrase \"$ESSID\" \"$PASSWORD\" >/etc/wpa_supplicant.conf || exit 1;\n\
echo \"create config...\";\n\
wpa_supplicant -B -D wext -i ath0 -dd -c /etc/wpa_supplicant.conf || exit 1;\n\
echo \"connect...\";\n\
\n\
sleep 5;\n\
if [[ \"$ADDRESS\" == \"auto\" ]]; then\n\
/sbin/udhcpc -i ath0;\n\
else\n\
ifconfig ath0 $ADDRESS || exit 1;\n\
fi\n\
echo \"assign ip...\";\n\
"
echo "echo -e '$SCRIPT' >/data/video/wpa-wifi.sh &&\
chmod +x /data/video/wpa-wifi.sh &&\
/data/video/wpa-wifi.sh &>/data/video/wpa-wifi.log &&\
wpi_cli status &>/data/video/wpa-wifi.log"\
| telnet $DRONEIP &>/dev/null