nerves_wpa_supplicant v0.3.1 Nerves.WpaSupplicant

Link to this section Summary

Functions

Get the interface name from the wpa_supplicant state

Send a request to the wpa_supplicant

This is a helper function that will initiate a scan, wait for the scan to complete and return a list of all of the available access points. This can take a while if the wpa_supplicant hasn’t scanned for access points recently

Tell the wpa_supplicant to connect to the specified network. Invoke like this

Start and link a Nerves.WpaSupplicant that uses the specified control socket

Return the current status of the wpa_supplicant. It wraps the STATUS command

Stop the Nerves.WpaSupplicant control interface

Link to this section Functions

Get the interface name from the wpa_supplicant state

Link to this function request(pid, command)

Send a request to the wpa_supplicant.

Example

iex> Nerves.WpaSupplicant.request(pid, :PING)
:PONG

This is a helper function that will initiate a scan, wait for the scan to complete and return a list of all of the available access points. This can take a while if the wpa_supplicant hasn’t scanned for access points recently.

Link to this function set_network(pid, options)

Tell the wpa_supplicant to connect to the specified network. Invoke like this:

iex> Nerves.WpaSupplicant.set_network(pid, ssid: "MyNetworkSsid", key_mgmt: :WPA_PSK, psk: "secret")

or like this:

iex> Nerves.WpaSupplicant.set_network(pid, %{ssid: "MyNetworkSsid", key_mgmt: :WPA_PSK, psk: "secret"})

Many options are supported, but it is likely that ssid and psk are the most useful. The full list can be found in the wpa_supplicant documentation. Here’s a list of some common ones:

Option                | Description
----------------------|------------
:ssid                 | Network name. This is mandatory.
:key_mgmt             | The security in use. This is mandatory. Set to :NONE, :WPA_PSK
:proto                | Protocol use use. E.g., :WPA2
:psk                  | WPA preshared key. 8-63 chars or the 64 char one as processed by `wpa_passphrase`
:bssid                | Optional BSSID. If set, only associate with the AP with a matching BSSID
:mode                 | Mode: 0 = infrastructure (default), 1 = ad-hoc, 2 = AP
:frequency            | Channel frequency. e.g., 2412 for 802.11b/g channel 1
:wep_key0..3          | Static WEP key
:wep_tx_keyidx        | Default WEP key index (0 to 3)

Note that this is a helper function that wraps several low-level calls and is limited to specifying only one network at a time. If you’d like to register multiple networks with the supplicant, send the ADD_NETWORK, SET_NETWORK, SELECT_NETWORK messages manually.

Returns :ok or {:error, key, reason} if a key fails to set.

Link to this function start_link(ifname, control_socket_path, opts \\ [])

Start and link a Nerves.WpaSupplicant that uses the specified control socket.

Return the current status of the wpa_supplicant. It wraps the STATUS command.

Stop the Nerves.WpaSupplicant control interface