Wi-Fi Setup

By default, the Wi-Fi interface on the SNAPconnect E20 is not active on startup.

Enabling Wi-Fi

Edit the interfaces file at /etc/network/interfaces file using the editor of your choice.

Remove the # from the beginning of the following line:

#auto wlan0

On the next reboot, the Wi-Fi connection will automatically activate, though additional configuration is necessary for it to connect.

Connecting to an Access Point

Connecting to a access point using WPA encryption is fairly easy. You need to provide the /etc/wpa_supplicant.conf file with your desired network SSID and a passphrase key.

The easiest way to do this is to use the wpa_passphrase application:

sudo bash -c 'wpa_passphrase "myssid" "mypassword" >> /etc/wpa_supplicant.conf'

This command generates a passphrase key from your password and then appends the appropriate text to the /etc/wpa_supplicant.conf file.

After you do this, you should edit the /etc/wpa_supplicant.conf file to remove the line that includes the clear text of your passkey, and to make sure there are not issues with conflicting network entries. You may also need additional options, depending on your network setup. (Such configuration is beyond the scope of this document.)

You can now reboot (or use ifup wlan0) to bring up the interface and connect to the network.

Setting Up Access-Point Mode

You can configure your gateway to work as an access point for other Wi-Fi devices. This can be useful if you want to be able to connect directly to your gateway with a laptop or phone to administer your application.

Install udhcpd

Begin by making sure the udhcpd package is installed:

sudo apt-get install udhcpd

Set Your SSID and Passphrase

Generate your passphrase using the wpa_passphrase application. You can direct this output to a file for recall later, or track it in the method of your choice.

$ wpa_passphrase 'myssid' 'mypassword'
network={
    ssid="myssid"
    #psk="mypassword"
    psk=2f0568b3492812bd56b946dbaf3fd7dd669b9a4602a09aa6462ff057949b025c
}

Set up /etc/udhcpd.conf

The interface definition in the /etc/udhcpd.conf file defaults to eth0. Find the definition in the file (typically within the first dozen lines, but it may vary depending on your current configuration) and change it to wlan0 instead.

# The start and end of the IP lease block
start 192.168.0.20 #default: 192.168.0.20
end 192.168.0.254 #default: 192.168.0.254
# The interface that udhcpd will use
interface wlan0 #default:eth0

Set udhcpd to Run by Default

Edit the /etc/default/udhcpd file to change the DHCPD_ENABLED parameter from “no” to “yes”.

DHCPD_ENABLED="yes"

Assign a Static IP Address

Edit the /etc/network/interfaces file to assign a static IP address so the gateway can act as an access point. By default, the file contains this configuration text:

iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant.conf
    wpa-driver wext

You can either replace that text with the new configuration text, or comment those lines by inserting a # character at the beginning of each line, and then add your new configuration text:

iface wlan0 inet static
    address 192.168.0.1
    netmask 255.255.255.0

Specify the IP address you wish to use for your access point, 192.168.0.1 in the example above. You should choose an appropriate private network address, suitable for your needs.

Configure the LAN with iwpriv

Use the wpa_passphrase information you generated earlier as parameters for a call to iwpriv, specifying a channel and other parameters appropriate for your environment:

sudo iwpriv wlan0 AP_SET_CFG ASCII_CMD=AP_CFG,SSID="myssid",SEC="wpa2-psk",KEY=2f0568b3492812bd56b946dbaf3fd7dd669b9a4602a09aa6462ff057949b025c,CHANNEL=1,PREAMBLE=1,MAX_SCB=8,END

Start AP Mode

sudo iwpriv wlan0 AP_BSS_START

Stop AP Mode

sudo iwpriv wlan0 AP_BSS_STOP