Skip to content

Wireless Configurations

Vasco Craveiro Costa edited this page Jan 22, 2017 · 14 revisions

In order to configure the ad-hoc network, create the following shell script in /home/pi/src/initNetworkScript.sh, substituting XX by the drone's number (don't forget to set executable flag with chmod +x /home/pi/src/initNetworkScript.sh):

# Variables
CHANNEL=7
PASSWORD="barco"	# 5 character length password
IP_ADDR="192.168.3.XX"
ESSID="biomachineslab"

# Functions
createAdHocNetwork(){
    printf "[rc.local] Creating ad-hoc network.... "
    ifconfig wlan0 down
    iwconfig wlan0 mode ad-hoc
    iwconfig wlan0 key s:$PASSWORD	#WEP key
    iwconfig wlan0 essid $ESSID		#SSID
    iwconfig wlan0 channel $CHANNEL
    ifconfig wlan0 up
    ifconfig wlan0 $IP_ADDR netmask 255.255.255.0
    printf "Ad-hoc network created\n"
}

# Script
printf "[rc.local] Running script.....\n"
createAdHocNetwork

exit 0

Pay atention that the IP address should be changed, in case you have multiple drones connected to the same ad-hoc.

Reference