nerves_network v0.3.4 Nerves.Network

The Nerves.Network application handles the low level details of connecting to WiFi networks. To quickly get started, create a new Nerves project and add the following line someplace early on in your program:

Nerves.Network.setup "wlan0", ssid: "myssid", key_mgmt: :"WPA-PSK", psk: "secretsecret"

When you boot your Nerves image, Nerves.Network monitors for an interface called “wlan0” to be created. This occurs when you plug in a USB WiFi dongle. If you plug in more than one WiFi dongle, each one will be given a name like “wlan1”, etc. Those may be setup as well.

When not connected, Nerves.Network continually scans for the desired access point. Once found, it associates and runs DHCP to acquire an IP address.

Link to this section Summary

Functions

If ifname is a wireless LAN, scan for access points

Change the regulatory domain for wireless operations. This must be set to the two character alpha2 code for the country where this device is operating. See http://git.kernel.org/cgit/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt for the latest database and the frequencies allowed per country

Configure the specified interface. Settings contains one or more of the following

Convenience function for returning the current status of a network interface from SystemRegistry

Stop all control of ifname

Link to this section Functions

If ifname is a wireless LAN, scan for access points.

Link to this function set_regulatory_domain(country)

Change the regulatory domain for wireless operations. This must be set to the two character alpha2 code for the country where this device is operating. See http://git.kernel.org/cgit/linux/kernel/git/sforshee/wireless-regdb.git/tree/db.txt for the latest database and the frequencies allowed per country.

The default is to use the world regulatory domain (00).

You may also configure the regulatory domain in your app’s config/config.exs:

config :nerves_network,
  regulatory_domain: "US"
Link to this function setup(ifname, settings \\ [])

Configure the specified interface. Settings contains one or more of the following:

  • :ipv4_address_method - :dhcp, :static, or :linklocal
  • :ipv4_address - e.g., “192.168.1.5” (specify when :ipv4_address_method = :static)
  • :ipv4_subnet_mask - e.g., “255.255.255.0” (specify when :ipv4_address_method = :static)
  • :domain - e.g., “mycompany.com” (specify when :ipv4_address_method = :static)
  • :nameservers - e.g., [“8.8.8.8”, “8.8.4.4”] (specify when :ipv4_address_method = :static)
  • :ssid - “My WiFi AP” (specify if this is a wireless interface)
  • :key_mgmt - e.g., :"WPA-PSK" or :NONE
  • :psk - e.g., “my-secret-wlan-key”

Convenience function for returning the current status of a network interface from SystemRegistry.

Link to this function teardown(ifname)

Stop all control of ifname