forked from tnaegeli/multiple_bebops
-
Notifications
You must be signed in to change notification settings - Fork 3
/
connect
executable file
·52 lines (41 loc) · 1.49 KB
/
connect
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
#!/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>]
<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" or "dhcp" to let the router DHCP server auto-assign an IP.
Default is "auto".
<droneip> (optional) Current drone's ip address.
Default is 192.168.1.1
EOF
}
ESSID=$1
PASSWORD=$3
ADDRESS=$5
DRONEIP=${7:-"192.168.1.1"}
DHCPC=""
if [[ -z $ADDRESS ]] || [[ $ADDRESS = "auto" ]] || [[ $ADDRESS = "dhcp" ]]; then
DHCPC="; wait 5; /sbin/udhcpc -i eth0"
ADDRESS="0.0.0.0"
fi
IFCONFIG="ifconfig eth0 $ADDRESS;"
if [[ -z $ESSID ]] || [[ -z $PASSWORD ]]; then
usage; exit 1
fi
set -ue
echo "ESSID: $ESSID"
echo "PASSWORD: $PASSWORD"
echo "ADDRESS: $ADDRESS"
echo "DRONE_IP: $DRONEIP"
{( echo "\
wpa_passphrase '$ESSID' '$PASSWORD' > /etc/wpa_supplicant.conf
{ $IFCONFIG iwconfig eth0 essid '$ESSID' && wpa_supplicant -B -Dwext -ieth0 -c/etc/wpa_supplicant.conf $DHCPC; } &
"; sleep 1; ) | telnet $DRONEIP > /dev/null; }