mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-29 02:38:07 +08:00
[ardrone2] add support for olsr
This commit is contained in:
@@ -122,6 +122,17 @@ def ardrone2_install_network_script():
|
||||
print(parrot_utils.execute_command(tn,"mv /data/video/wifi_setup.sh /bin/wifi_setup.sh"))
|
||||
print(parrot_utils.execute_command(tn,"chmod 777 /bin/wifi_setup.sh"))
|
||||
|
||||
# Install olsr deamon
|
||||
def ardrone2_install_olsrd():
|
||||
print('Uploading olsr deamon')
|
||||
parrot_utils.uploadfile(ftp, "olsrd", file("ardrone2/olsrd", "rb"))
|
||||
parrot_utils.uploadfile(ftp, "olsrd.conf", file("ardrone2/olsrd.conf", "rb"))
|
||||
print(parrot_utils.execute_command(tn,"mv /data/video/olsrd /bin/olsrd"))
|
||||
print(parrot_utils.execute_command(tn,"chmod 777 /bin/olsrd"))
|
||||
print(parrot_utils.execute_command(tn,"mkdir -p /etc/olsrd"))
|
||||
print(parrot_utils.execute_command(tn,"mv /data/video/olsrd.conf /etc/olsrd"))
|
||||
print(parrot_utils.execute_command(tn,"rm -f /var/run && ln -s /tmp /var/run")) # olsrd needs /var/run folder, symlinked to /tmp
|
||||
|
||||
# Set network SSID
|
||||
def ardrone2_set_ssid(name):
|
||||
write_to_config('ssid_single_player', name)
|
||||
@@ -136,7 +147,7 @@ def ardrone2_set_ip_address(address):
|
||||
|
||||
# Set wifi mode (0: master, 1: ad-hoc, 2: managed, *: master)
|
||||
def ardrone2_set_wifi_mode(mode):
|
||||
modes = { 'master' : '0', 'ad-hoc' : '1', 'managed' : '2' }
|
||||
modes = { 'master' : '0', 'ad-hoc' : '1', 'managed' : '2', 'ad-hoc-olsr' : '3' }
|
||||
try:
|
||||
val = modes[mode]
|
||||
except:
|
||||
@@ -145,6 +156,11 @@ def ardrone2_set_wifi_mode(mode):
|
||||
write_to_config('wifi_mode', val)
|
||||
print('The Wifi mode of the ARDrone2 is changed to ' + mode + ' (' + val + ')')
|
||||
|
||||
# Set network channel
|
||||
def ardrone2_set_wifi_channel(chan):
|
||||
write_to_config('wifi_channel', chan)
|
||||
print('The network channel of the ARDrone 2 is changed to ' + chan)
|
||||
|
||||
def ardrone2_status():
|
||||
config_ini = parrot_utils.execute_command(tn,'cat /data/config.ini')
|
||||
|
||||
@@ -224,7 +240,8 @@ subparser_wifimode.add_argument('mode', help='the new Wifi mode', choices=['mast
|
||||
subparser_configure_network = subparsers.add_parser('configure_network', help='Configure the network on the ARDrone 2')
|
||||
subparser_configure_network.add_argument('name', help='the new network ID(SSID)')
|
||||
subparser_configure_network.add_argument('address', help='the new IP address')
|
||||
subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed'])
|
||||
subparser_configure_network.add_argument('mode', help='the new Wifi mode', choices=['master', 'ad-hoc', 'managed', 'ad-hoc-olsr'])
|
||||
subparser_configure_network.add_argument('--channel', help='the wifi channel (auto or 1 to 11)', default='auto')
|
||||
subparser_install_autostart = subparsers.add_parser('install_autostart', help='Install custom autostart script and set what to start on boot for the ARDrone 2')
|
||||
subparser_install_autostart.add_argument('type', choices=['native', 'paparazzi_raw', 'paparazzi_sdk'],
|
||||
help='what to start on boot')
|
||||
@@ -285,6 +302,7 @@ elif args.command == 'configure_network':
|
||||
print('Host:\t\t' + args.host + ' (' + read_from_config('static_ip_address_base', config_ini) +
|
||||
read_from_config('static_ip_address_probe', config_ini) + ' after boot)')
|
||||
print('Mode:\t\t' + read_from_config('wifi_mode', config_ini))
|
||||
print('Channel:\t' + read_from_config('wifi_channel', config_ini))
|
||||
print('=============================')
|
||||
if check_wifi_setup():
|
||||
print('Custom Wifi script already installed')
|
||||
@@ -293,15 +311,19 @@ elif args.command == 'configure_network':
|
||||
else:
|
||||
if raw_input("Shall I install custom Wifi script (recommanded) (y/N) ").lower() == 'y':
|
||||
ardrone2_install_network_script()
|
||||
if raw_input("Shall I install olsrd (ad-hoc wireless mesh routing deamon) (y/N) ").lower() == 'y':
|
||||
ardrone2_install_olsrd()
|
||||
ardrone2_set_ssid(args.name)
|
||||
ardrone2_set_ip_address(args.address)
|
||||
ardrone2_set_wifi_mode(args.mode)
|
||||
ardrone2_set_wifi_channel(args.channel)
|
||||
config_ini = parrot_utils.execute_command(tn,'cat /data/config.ini')
|
||||
print('== New network setup after boot ==')
|
||||
print('Network id:\t' + read_from_config('ssid_single_player', config_ini))
|
||||
print('Host:\t\t' + read_from_config('static_ip_address_base', config_ini) +
|
||||
read_from_config('static_ip_address_probe', config_ini))
|
||||
print('Mode:\t\t' + read_from_config('wifi_mode', config_ini))
|
||||
print('Channel:\t' + read_from_config('wifi_channel', config_ini))
|
||||
print('==================================')
|
||||
|
||||
if raw_input("Shall I restart the ARDrone 2? (y/N) ").lower() == 'y':
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,214 @@
|
||||
#
|
||||
# OLSR.org routing daemon config file
|
||||
# This file contains the necessary config options
|
||||
# for an RFC compatible mesh
|
||||
# (for other options see olsrd.conf.default.full)
|
||||
#
|
||||
# Lines starting with a # are discarded
|
||||
#
|
||||
|
||||
#### ATTENTION for IPv6 users ####
|
||||
# Because of limitations in the parser IPv6 addresses must NOT
|
||||
# begin with a ":", so please add a "0" as a prefix.
|
||||
|
||||
###########################
|
||||
### Basic configuration ###
|
||||
###########################
|
||||
# keep this settings at the beginning of your first configuration file
|
||||
|
||||
# Debug level (0-9)
|
||||
# If set to 0 the daemon runs in the background, unless "NoFork" is set to true
|
||||
# (Default is 1)
|
||||
|
||||
DebugLevel 0
|
||||
|
||||
# IP version to use (4 or 6)
|
||||
# (Default is 4)
|
||||
|
||||
# IpVersion 4
|
||||
|
||||
#################################
|
||||
### OLSRd agent configuration ###
|
||||
#################################
|
||||
# this parameters control the settings of the routing agent which are not
|
||||
# related to the OLSR protocol and it's extensions
|
||||
|
||||
# FIBMetric controls the metric value of the host-routes OLSRd sets.
|
||||
# - "flat" means that the metric value is always 2. This is the preferred value
|
||||
# because it helps the linux kernel routing to clean up older routes
|
||||
# - "correct" use the hopcount as the metric value.
|
||||
# - "approx" use the hopcount as the metric value too, but does only update the
|
||||
# hopcount if the nexthop changes too
|
||||
# (Default is "flat")
|
||||
|
||||
# FIBMetric "flat"
|
||||
|
||||
#######################################
|
||||
### Linux specific OLSRd extensions ###
|
||||
#######################################
|
||||
# these parameters are only working on linux at the moment, but might become
|
||||
# useful on BSD in the future
|
||||
|
||||
# Activates (in IPv6 mode) the automatic use of NIIT
|
||||
# (see README-Olsr-Extensions)
|
||||
# (default is "yes")
|
||||
|
||||
UseNiit no
|
||||
|
||||
# Activates the smartgateway ipip tunnel feature.
|
||||
# See README-Olsr-Extensions for a description of smartgateways.
|
||||
# (default is "yes")
|
||||
|
||||
SmartGateway no
|
||||
|
||||
##############################
|
||||
### OLSR protocol settings ###
|
||||
##############################
|
||||
|
||||
# For testing purposes it may be nice to use another port for olsrd
|
||||
# for using another port than the IANA assigned one
|
||||
# for a production network, there should be a good reason!!
|
||||
# valid values are integers >1, please be careful with using reserved
|
||||
# port numbers
|
||||
# (default is 698, the IANA assigned olsr-port)
|
||||
|
||||
# OlsrPort 698
|
||||
|
||||
# The fixed willingness to use (0-7)
|
||||
# If not set willingness will be calculated
|
||||
# dynamically based on battery/power status
|
||||
# (default is 3)
|
||||
|
||||
# Willingness 3
|
||||
|
||||
# HNA (Host network association) allows the OLSR to announce
|
||||
# additional IPs or IP subnets to the net that are reachable
|
||||
# through this node.
|
||||
# Syntax for HNA4 is "network-address network-mask"
|
||||
# Syntax for HNA6 is "network-address prefix-length"
|
||||
# (default is no HNA)
|
||||
Hna4
|
||||
{
|
||||
# Internet gateway
|
||||
# 0.0.0.0 0.0.0.0
|
||||
# specific small networks reachable through this node
|
||||
# 15.15.0.0 255.255.255.0
|
||||
}
|
||||
Hna6
|
||||
{
|
||||
# Internet gateway
|
||||
# 0:: 0
|
||||
# specific small networks reachable through this node
|
||||
# fec0:2200:106:0:0:0:0:0 48
|
||||
}
|
||||
|
||||
# Hysteresis for link sensing (only for hopcount metric)
|
||||
# Hysteresis adds more robustness to the link sensing
|
||||
# but delays neighbor registration.
|
||||
# (defaults to yes)
|
||||
|
||||
# UseHysteresis yes
|
||||
|
||||
# Hysteresis parameters (only for hopcount metric)
|
||||
# Do not alter these unless you know what you are doing!
|
||||
# Set to auto by default. Allowed values are floating point
|
||||
# values in the interval 0,1
|
||||
# THR_LOW must always be lower than THR_HIGH!!
|
||||
# (default is 0.5/0.8/0.3)
|
||||
|
||||
# HystScaling 0.50
|
||||
# HystThrHigh 0.80
|
||||
# HystThrLow 0.30
|
||||
|
||||
# TC redundancy
|
||||
# Specifies how much neighbor info should be sent in
|
||||
# TC messages. Because of a design problem in the 0.5.x
|
||||
# dijkstra implementation this value must be set to 2.
|
||||
# 2 - send all neighbors
|
||||
# (default is 2)
|
||||
|
||||
# TcRedundancy 2
|
||||
|
||||
# MPR coverage specifies how many MPRs a node should
|
||||
# try select to reach every 2 hop neighbor. Because of
|
||||
# a design problem in the 0.5.x dijkstra algorithm this
|
||||
# value should be set to 7.
|
||||
# (default is 7)
|
||||
|
||||
# MprCoverage 7
|
||||
|
||||
################################
|
||||
### OLSR protocol extensions ###
|
||||
################################
|
||||
|
||||
# Link quality level switch between hopcount and
|
||||
# cost-based (mostly ETX) routing. Because of
|
||||
# a design problem in the 0.5.x dijkstra algorithm this
|
||||
# value should not be set to 1.
|
||||
# 0 = do not use link quality
|
||||
# 2 = use link quality for MPR selection and routing
|
||||
# (default is 2)
|
||||
|
||||
LinkQualityLevel 2
|
||||
|
||||
LinkQualityAlgorithm "etx_ff"
|
||||
|
||||
# Fisheye mechanism for TCs (0 meansoff, 1 means on)
|
||||
# (default is 1)
|
||||
|
||||
LinkQualityFishEye 0
|
||||
|
||||
#####################################
|
||||
### Example plugin configurations ###
|
||||
#####################################
|
||||
# Olsrd plugins to load
|
||||
# This must be the absolute path to the file
|
||||
# or the loader will use the following scheme:
|
||||
# - Try the paths in the LD_LIBRARY_PATH
|
||||
# environment variable.
|
||||
# - The list of libraries cached in /etc/ld.so.cache
|
||||
# - /lib, followed by /usr/lib
|
||||
#
|
||||
# the examples in this list are for linux, so check if the plugin is
|
||||
# available if you use windows/BSD.
|
||||
# each plugin should have a README file in it's lib subfolder
|
||||
|
||||
# LoadPlugin "olsrd_txtinfo.dll"
|
||||
#LoadPlugin "olsrd_txtinfo.so.0.1"
|
||||
#{
|
||||
# the default port is 2006 but you can change it like this:
|
||||
#PlParam "port" "8080"
|
||||
|
||||
# You can set a "accept" single address to allow to connect to
|
||||
# txtinfo. If no address is specified, then localhost (127.0.0.1)
|
||||
# is allowed by default. txtinfo will only use the first "accept"
|
||||
# parameter specified and will ignore the rest.
|
||||
|
||||
# to allow a specific host:
|
||||
#PlParam "accept" "172.29.44.23"
|
||||
# if you set it to 0.0.0.0, it will accept all connections
|
||||
#PlParam "accept" "0.0.0.0"
|
||||
#}
|
||||
|
||||
######################################
|
||||
### OLSRd Interfaces configuration ###
|
||||
######################################
|
||||
# multiple interfaces can be specified for a single configuration block
|
||||
# multiple configuration blocks can be specified
|
||||
|
||||
# WARNING, don't forget to insert your interface names here !
|
||||
Interface "ath0"
|
||||
{
|
||||
# Emission intervals in seconds.
|
||||
# If not defined, Freifunk network defaults are used
|
||||
# (default is 2.0/20.0 for Hello and 5.0/300.0 for Tc/Mid/Hna)
|
||||
|
||||
# HelloInterval 2.0
|
||||
# HelloValidityTime 6.0
|
||||
# TcInterval 5.0
|
||||
# TcValidityTime 30.0
|
||||
# MidInterval 5.0
|
||||
# MidValidityTime 30.0
|
||||
# HnaInterval 5.0
|
||||
# HnaValidityTime 30.0
|
||||
}
|
||||
@@ -20,6 +20,9 @@ export ATH_MODULE_ARGS="ifname=$NETIF"
|
||||
|
||||
WIFI_MODE=`grep wifi_mode /data/config.ini | awk -F "=" '{ gsub(/ */,"",$2); print $2}'`
|
||||
|
||||
# ad-hoc wireless mesh routing daemon disabled by default
|
||||
OLSR=false
|
||||
|
||||
case $WIFI_MODE in
|
||||
0)
|
||||
WIFI_MODE=master
|
||||
@@ -30,6 +33,10 @@ case $WIFI_MODE in
|
||||
2)
|
||||
WIFI_MODE=managed
|
||||
;;
|
||||
3)
|
||||
WIFI_MODE=ad-hoc
|
||||
OLSR=true
|
||||
;;
|
||||
*)
|
||||
WIFI_MODE=master
|
||||
;;
|
||||
@@ -84,7 +91,17 @@ SSID=ardrone2_wifi
|
||||
echo "SSID=\"$SSID\""
|
||||
fi
|
||||
|
||||
RANDOM_CHAN=`grep wifi_channel /data/config.ini | awk -F "=" '{print $2}'`
|
||||
RANDOM_CHAN=`echo $RANDOM_CHAN`
|
||||
# Default random channel
|
||||
if [ -n "$RANDOM_CHAN" ]
|
||||
then
|
||||
echo "RANDOM_CHAN=$RANDOM_CHAN"
|
||||
else
|
||||
#default RANDOM_CHAN.
|
||||
RANDOM_CHAN=auto
|
||||
echo "RANDOM_CHAN=\"$RANDOM_CHAN\""
|
||||
fi
|
||||
|
||||
|
||||
echo "Creating $WIFI_MODE Network $SSID"
|
||||
@@ -181,11 +198,17 @@ echo $MAC_ADDR `date` `/bin/random_mac` > /dev/urandom
|
||||
telnetd -l /bin/sh
|
||||
|
||||
# Check if not booting in master mode
|
||||
if [ "$WIFI_MODE" != "managed" ]
|
||||
if [ "$WIFI_MODE" != "managed" ] && [ "$OLSR" != "true" ]
|
||||
then
|
||||
udhcpd /tmp/udhcpd.conf
|
||||
fi
|
||||
|
||||
# Check OLSR deamon should be started
|
||||
if [ "$OLSR" = "true" ] && [ -f "/bin/olsrd" ] && [ -f "/etc/olsrd/olsrd.conf" ]
|
||||
then
|
||||
olsrd
|
||||
fi
|
||||
|
||||
# Adding route for multicast-packet
|
||||
route add -net 224.0.0.0 netmask 240.0.0.0 dev $NETIF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user