[ARDrone] Add modified script drone in branch
This commit is contained in:
parent
4ac4216ce0
commit
f14ae6e351
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Script to setup drone pairing
|
||||||
|
#
|
||||||
|
|
||||||
|
# Getting Iphone's MAC address from config.ini file.
|
||||||
|
NULL_MAC=00:00:00:00:00:00
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
if [ -s /data/config.ini ]
|
||||||
|
then
|
||||||
|
MAC_ADDR=`grep owner_mac /data/config.ini | awk -F "=" '{print $2}'`
|
||||||
|
else
|
||||||
|
MAC_ADDR=$NULL_MAC
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
MAC_ADDR=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Owner's MAC address is: $MAC_ADDR"
|
||||||
|
|
||||||
|
# [Stephane] Exits if owner MAC address is already being filtered
|
||||||
|
# (changing iptables rules too often may crash the drone for a undetermined reason)
|
||||||
|
CURRENTLY_ALLOWED_MAC_ADDR=`iptables -L | grep MAC | awk -F " " '{print $7}'`
|
||||||
|
if [ "$CURRENTLY_ALLOWED_MAC_ADDR" = "$MAC_ADDR" ]
|
||||||
|
then
|
||||||
|
echo "Drone is already paired with $MAC_ADDR"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $MAC_ADDR != $NULL_MAC ]
|
||||||
|
then
|
||||||
|
echo "Setting pairing for: $MAC_ADDR"
|
||||||
|
# Clearing all rules
|
||||||
|
iptables -P INPUT ACCEPT
|
||||||
|
iptables -F
|
||||||
|
# Allowing only owner's traffic
|
||||||
|
iptables -A INPUT -m mac --mac-source $MAC_ADDR -j ACCEPT
|
||||||
|
# allowing ICMP (ping), ftp, nfs and telnet traffic for everyone.
|
||||||
|
iptables -A INPUT --protocol icmp -j ACCEPT
|
||||||
|
#iptables -A INPUT --protocol tcp --dport 23 -j ACCEPT
|
||||||
|
iptables -A INPUT --protocol tcp --dport 21 -j ACCEPT
|
||||||
|
iptables -A INPUT --protocol tcp --dport 2049 -j ACCEPT
|
||||||
|
# Blocking all incoming traffic by default
|
||||||
|
iptables -P INPUT DROP
|
||||||
|
else
|
||||||
|
echo "Clearing pairing rule"
|
||||||
|
# Switching rad LED on
|
||||||
|
gpio 63 -d ho 1
|
||||||
|
|
||||||
|
# Clearing all rules
|
||||||
|
iptables -F
|
||||||
|
# Allows incoming connections from anywhere outside
|
||||||
|
iptables -P INPUT ACCEPT
|
||||||
|
|
||||||
|
# Switching rad LED off
|
||||||
|
gpio 63 -d ho 0
|
||||||
|
fi
|
|
@ -0,0 +1,110 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Script to see if an IP adress is already used or not
|
||||||
|
#
|
||||||
|
# Getting SSID from config.ini file.
|
||||||
|
|
||||||
|
#initializing random generator
|
||||||
|
cat /data/random_mac.txt > /dev/urandom
|
||||||
|
/bin/random_mac > /data/random_mac.txt
|
||||||
|
|
||||||
|
|
||||||
|
#echo 2 > /proc/cpu/alignment
|
||||||
|
#export WORKAREA=/
|
||||||
|
#export ATH_PLATFORM=ardrone
|
||||||
|
#/usr/sbin/recEvent /data/athdbg.log&
|
||||||
|
|
||||||
|
|
||||||
|
if [ -s /factory/mac_address.txt ]
|
||||||
|
then
|
||||||
|
MAC_ADDR=`cat /factory/mac_address.txt`
|
||||||
|
else
|
||||||
|
MAC_ADDR=`cat /data/random_mac.txt`
|
||||||
|
fi
|
||||||
|
|
||||||
|
loadAR6k.sh --setmac $MAC_ADDR
|
||||||
|
#loadtestcmd.sh
|
||||||
|
|
||||||
|
# Waiting 2s for the wifi chip to be ready
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# Increasing scan time to help detecting wifi networks
|
||||||
|
wmiconfig -i ath0 --scan --maxact=80
|
||||||
|
# Setting retry limits to 6
|
||||||
|
wmiconfig -i ath0 --setretrylimits 2 0 6 off
|
||||||
|
# Limiting available rates to 11, 24 or 54 Mb/s
|
||||||
|
wmiconfig -i ath0 --setfixrates 3 8 11
|
||||||
|
# Disabling powersaving
|
||||||
|
wmiconfig -i ath0 --power maxperf
|
||||||
|
|
||||||
|
|
||||||
|
SSID=`grep ssid_single_player /data/config.ini | awk -F "=" '{print $2}'`
|
||||||
|
|
||||||
|
if [ $SSID ]
|
||||||
|
then
|
||||||
|
echo "SSID=$SSID"
|
||||||
|
else
|
||||||
|
#default SSID.
|
||||||
|
SSID=ardrone_wifi
|
||||||
|
echo "SSID=$SSID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
export NETIF=ath0
|
||||||
|
RANDOM_CHAN=`/bin/channelselector`
|
||||||
|
|
||||||
|
echo "Creating/Joining Network $SSID"
|
||||||
|
|
||||||
|
#iwconfig ath0 mode ad-hoc
|
||||||
|
#iwconfig ath0 channel $RANDOM_CHAN
|
||||||
|
#iwconfig ath0 essid $SSID
|
||||||
|
#iwconfig ath0 channel 1
|
||||||
|
|
||||||
|
iwconfig ath0 mode ad-hoc essid owl channel auto
|
||||||
|
|
||||||
|
OK=0
|
||||||
|
BASE_ADRESS=192.168.1.
|
||||||
|
PROBE=1
|
||||||
|
|
||||||
|
while [ $OK -eq 0 ]
|
||||||
|
do
|
||||||
|
#configuring interface.
|
||||||
|
ifconfig ath0 $BASE_ADRESS$PROBE
|
||||||
|
ifconfig ath0:0 192.168.11.1
|
||||||
|
arping -I ath0 -q -f -D -w 2 $BASE_ADRESS$PROBE
|
||||||
|
|
||||||
|
if [ $? -eq 1 ]
|
||||||
|
then
|
||||||
|
#generating random odd IP address
|
||||||
|
PROBE=`/bin/random_ip`
|
||||||
|
else
|
||||||
|
OK=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
#Configuring DHCP server.
|
||||||
|
echo "Using address $BASE_ADRESS$PROBE"
|
||||||
|
echo "start $BASE_ADRESS`expr $PROBE + 1`" > /tmp/udhcpd.conf
|
||||||
|
echo "end $BASE_ADRESS`expr $PROBE + 4`" >> /tmp/udhcpd.conf
|
||||||
|
echo "interface ath0" >> /tmp/udhcpd.conf
|
||||||
|
echo "decline_time 1" >> /tmp/udhcpd.conf
|
||||||
|
echo "conflict_time 1" >> /tmp/udhcpd.conf
|
||||||
|
echo "opt subnet 255.255.255.0" >> /tmp/udhcpd.conf
|
||||||
|
echo "opt router $BASE_ADRESS$PROBE" >> /tmp/udhcpd.conf
|
||||||
|
echo "opt lease 1200" >> /tmp/udhcpd.conf
|
||||||
|
|
||||||
|
/bin/pairing_setup.sh
|
||||||
|
# Saving random info for initialization at next reboot
|
||||||
|
date > /dev/urandom
|
||||||
|
/bin/random_mac > /data/random_mac.txt
|
||||||
|
|
||||||
|
iwconfig ath0 rate 54M
|
||||||
|
iwconfig ath0 rate auto
|
||||||
|
|
||||||
|
telnetd -l /bin/sh
|
||||||
|
udhcpd /tmp/udhcpd.conf
|
||||||
|
iptables -t nat -A POSTROUTING -p UDP --sport 8884 -j SNAT --to 192.168.1.254:5554
|
||||||
|
iptables -t nat -A PREROUTING -p UDP -d 192.168.1.254 --dport 5554 -j DNAT --to 192.168.1.1:8884
|
||||||
|
iptables -t nat -A POSTROUTING -p UDP --sport 8886 -j SNAT --to 192.168.1.254:5556
|
||||||
|
iptables -t nat -A PREROUTING -p UDP -d 192.168.1.254 --dport 5556 -j DNAT --to 192.168.1.1:8886
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Initialization script for Arduino stuff
|
||||||
|
#
|
||||||
|
# Loads modules and launches proxy server application
|
||||||
|
# required for communication with Arduino module.
|
||||||
|
#
|
||||||
|
|
||||||
|
echo Enabling 5V
|
||||||
|
|
||||||
|
echo Enabling USB Port
|
||||||
|
gpio 127 -d ho 1
|
||||||
|
gpio 127 -d i
|
||||||
|
|
||||||
|
echo Loading dwc_otg.ko
|
||||||
|
insmod /data/dwc_otg.ko
|
||||||
|
|
||||||
|
echo Waiting 3s for the device to be ready
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
echo Setting correct baud rate of 38400 for /dev/ttyPA0
|
||||||
|
stty -F /dev/ttyPA0 raw speed 38400 -crtscts cs8 -cstopb -parenb
|
||||||
|
|
||||||
|
#echo Activate log
|
||||||
|
#cat /dev/ttyPA0 >> /data/video/gps.log.0 &
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# IP_ADDR - this target IP address using CIDR notation:
|
||||||
|
# <target-ip>/<target-bitmask>
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
echo init started...
|
||||||
|
|
||||||
|
/bin/mount -t tmpfs tmp /tmp
|
||||||
|
/bin/mount -t proc proc /proc
|
||||||
|
/bin/mount -o remount,rw /
|
||||||
|
/bin/mount -t tmpfs dev /dev
|
||||||
|
/bin/mkdir -p /dev/shm /dev/pts
|
||||||
|
/bin/mount -t devpts devpts /dev/pts
|
||||||
|
/bin/mount -t sysfs sys /sys
|
||||||
|
|
||||||
|
#don't allow overcommit (allocate more memory that the physical one)
|
||||||
|
echo 2 > /proc/sys/vm/overcommit_memory
|
||||||
|
echo 90 > /proc/sys/vm/overcommit_ratio
|
||||||
|
|
||||||
|
#in case of unaligned access print a message and send a SIGBUS
|
||||||
|
echo 5 > /proc/cpu/alignment
|
||||||
|
|
||||||
|
#reboot after 1s after a panic
|
||||||
|
echo 1 > /proc/sys/kernel/panic
|
||||||
|
|
||||||
|
#panic when an oops or BUG is encountered
|
||||||
|
#disable this for developer
|
||||||
|
echo 1 > /proc/sys/kernel/panic_on_oops
|
||||||
|
|
||||||
|
echo 4 > /sys/module/p6_camif/parameters/lines_per_irq
|
||||||
|
echo -1 > /proc/sys/kernel/sched_rt_runtime_us
|
||||||
|
|
||||||
|
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
|
||||||
|
/sbin/mdev -s
|
||||||
|
|
||||||
|
# Don't show kernel messages
|
||||||
|
dmesg -n1
|
||||||
|
|
||||||
|
/bin/mkdir -p /update
|
||||||
|
/bin/mount -a
|
||||||
|
/bin/mkdir -p /data/video
|
||||||
|
|
||||||
|
/bin/hostname -F /etc/hostname
|
||||||
|
/sbin/ifconfig lo 127.0.0.1 up
|
||||||
|
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
|
||||||
|
/bin/factory_reset_cb&
|
||||||
|
modprobe p6_sdhci
|
||||||
|
/bin/wifi_setup.sh
|
||||||
|
|
||||||
|
# Patch to enable button management.
|
||||||
|
ln -s /dev /dev/input
|
||||||
|
|
||||||
|
/data/gps.sh
|
||||||
|
|
||||||
|
#mount -o nolock,proto=tcp -t nfs 192.168.0.11:/mnt/video /home/default
|
||||||
|
/bin/check_update.sh
|
||||||
|
|
||||||
|
echo init exit
|
||||||
|
echo if you want to customize init look at target/generic/target_skeleton/etc files
|
||||||
|
echo if crtl+c does not work look at the Linux FAQ section.
|
Loading…
Reference in New Issue