# GAPTER: Network Configuration and Connection¶

To provide flexibility to end-users, Gapter provides two possible network configuration modes:

• WiFi Hotspot mode: In this mode, the copter creates an adhoc network named gapternet that the user can connect to it through its compter or laptop using ssh.
• WiFi infrastructure mode: in this mode, the copter connects to a WiFi router network that must be specified in advance. Users then can connect to the copter using ssh.

Note

If you want to connect Gapter to Internet, then you must use the infrastructure mode. If you want to have point-to-point communication with Gapter, then use the WiFi Hotspot mode.

## WiFi Hotspot Mode¶

By default, Gapter comes with a WiFi hotspot. In this case, to connect to Gapter, you need to look for available WiFi networks, and connect to gapternet network.

Warning

Remember that in this mode, there is no Internet connection.

Once this is done, you just need to use ssh to connect to the drone as follow through a terminal.

ssh gapter@10.0.0.1


Note that the default ip address of gapter is 10.0.0.1, and your laptop connects to that gapternet, it will be assigned th IP address 10.0.0.2. You will be request for a password. The password is gaitech.

Now you are connected to the copter and you can navigate inside the ubuntu file system, run ROS programs, etc.

As mentioned before, this mode does not have Internet connection. So, you cannot do any operation that requires Internet. If you need Internet to download new packages or software inside Gapter, you need to configure the WiFi infrastructure mode as explained below.

## WiFi Infrastructure Mode¶

To work in WiFi infrastructure mode, you first need to have a WiFi router to which the copter will connect.

The connection to the WiFi network will use wpa_supplicant network configuration tool.

### STEP1. Specify the WiFi Network¶

First, connect to Gapter in hotspot mode, and in the terminal write:

wpa_passphrase network-ssid network-password


Warning

Change the name of the ssid and the password of the network, with your network credentials.

You will get an output similar to

 network={
ssid="ssid-name"
}


Then, save this into a file called wpa_supplicant.conf as follows:

sudo nano /boot/wpa_supplicant.conf


The nano terminal command editor will open, and you need to edit or copy/paste the network information into that file.

Note

We saved wpa_supplicant.conf in the /boot/ directory so that you can edit this file from your laptop on the MicroSD card without having to login again to the copter and change the network configuration of the WiFi infrastructure network. To do so, just insert the MicroSD card into your laptop, edit the file by putting the information of the new network you want to connect to, and put the MicroSD card back to the copter. In the next restart, the copter will automatically connect to the new WiFi network.

### STEP2. Modify Network Interfaces¶

Gapter was pre-configured to work in a WiFi hostpost. We need to change the interfaces defined in /etc/network/interfaces to enable the infastructure mode. When you are connected to Gapter in Hotspot mode, in the terminal edit the /etc/network/interfaces file as follow:

sudo nano /etc/network/interfaces


You will the following configuration that corresponds to the default hotspot mode:

#for loopback interface
auto lo
iface lo inet loopback

#for ethernet
auto eth0
iface eth0 inet dhcp

#for wifi in hotspot mode
auto wlan0
iface wlan0 inet static


To enable the WiFi infrastructure, we need to change the specification of wlan0 as follow

#for loopback interface
auto lo
iface lo inet loopback

#for ethernet
auto eth0
iface eth0 inet dhcp

#for wifi in hotspot mode
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /boot/wpa_supplicant.conf

#default route
iface default inet dhcp


With these changes, when you restart Gapter, it will automatically connect to the WiFi network defined in /boot/wpa_supplicant.conf. The IP address of the copter will be assigned automatically by the WiFi router, as DHCP is used.

It is possible to define a static or manual IP address, byt DHCP dynamic IP address assignment is recommended. Now, your drone is connected to Internet and you can download any software or package from Internet. In addition, you can make your drone streams MAVLink data to a server on the Internet.

Note

When WiFi instructure is configured, remember that you can easily modify the network to which you want to connect, by simply inserting the MicroSD card into your laptop and access the file /boot/wpa_supplicant.conf and modify network setting by editingt it. In the next restart, Gapter will automatically connect to the new network.