Getting WiFi in Snappy Ubuntu Core with Erle-Brain

Ubuntu
03/05/2015

This blog post explains how to connect to the Internet wirelessly using Erle-Brain running Snappy Ubuntu Core. In order to do so (WiFi mode infrastructure) we’ll use wpa_supplicant.

You’ll need the following armhf packages:

  • - libpcsclite1_1.8.11-3ubuntu1_armhf.deb
  • - libreadline5_5.2+dfsg-2_armhf.deb
  • - wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb

You can easily install these deb packages by typing:

dpkg -i <package-name>

Once the packages are installed, you’ll notice that wpa_supplicant is in the path. Let’s make a script that helps automating the process of connecting to a network. Check the name of your wireless interface:

(ErleRobotics)root@localhost:/home/ubuntu# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:187347 errors:0 dropped:0 overruns:0 frame:0
          TX packets:187347 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:14804850 (14.8 MB)  TX bytes:14804850 (14.8 MB)

usb0      Link encap:Ethernet  HWaddr 06:59:8e:d4:75:da  
          inet addr:192.168.7.2  Bcast:192.168.7.255  Mask:255.255.255.0
          inet6 addr: fe80::459:8eff:fed4:75da/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:93258 errors:0 dropped:0 overruns:0 frame:0
          TX packets:92164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5366538 (5.3 MB)  TX bytes:7672724 (7.6 MB)

wlan0     Link encap:Ethernet  HWaddr 80:1f:02:f9:1f:75  
          inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::821f:2ff:fef9:1f75/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1243 errors:0 dropped:317 overruns:0 frame:0
          TX packets:1235 errors:0 dropped:32 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:417444 (417.4 KB)  TX bytes:818244 (818.2 KB)


We’ll be using wlan0. Create the following script named wifi.sh:

wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf &
dhclient wlan0

Make sure that you configure your wpa_supplicant.conf appropriately. Here’s a guideline but it’ll depend on your router configuration:

ctrl_interface=/var/run/wpa_supplicant
# Unsecure Network
network={
    ssid=""
    key_mgmt=NONE
    priority=
}
# WEP Network
network={
    ssid=""
    key_mgmt=NONE
    wep_key0=""
    priority=
}
# WPA Network
network={
    ssid=""
    psk=""
    priority=
}

Once the interface has been properly configured just launch wifi.sh:

(ErleRobotics)root@localhost:/home/ubuntu# source wifi.sh
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
Trying to associate with 00:13:13:00:3a:01 (SSID='erle-net' freq=2432 MHz)
Association request to the driver failed
Associated with 00:13:13:00:3a:01
CTRL-EVENT-CONNECTED - Connection to 00:13:13:00:3a:01 completed (auth) [id=0 id_str=]

That should do it:

(ErleRobotics)root@localhost:/home/ubuntu# ping google.com
PING google.com (173.194.32.225) 56(84) bytes of data.
64 bytes from ber01s09-in-f1.1e100.net (173.194.32.225): icmp_seq=1 ttl=51 time=121 ms
64 bytes from ber01s09-in-f1.1e100.net (173.194.32.225): icmp_seq=2 ttl=51 time=46.1 ms
64 bytes from ber01s09-in-f1.1e100.net (173.194.32.225): icmp_seq=3 ttl=51 time=39.2 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms

If you wish to get a Ubuntu drone that has this an many more capabilities make sure to check Erle-Copter Ubuntu Core special edition.


0 Comments

add comment

— Add comment