Configure WiFi
Mix.install([
  {:vintage_net_wifi, "~> 0.11"}
])Finding access points
Nerves uses vintage_net_wifi to
configure WiFi networking. This notebook uses the quick_ functions to
simplify common tasks. If you’re trying to connect to an enterprise network,
this may not work for you.
Step 1 is to see what WiFi networks are available.
VintageNetWiFi.quick_scan/0 returns a lot of information, so lets filter it
to get a list of SSIDs (rerun if your network doesn’t should up in time):
networks =
  VintageNetWiFi.quick_scan()
  |> Enum.map(fn %{ssid: ssid, signal_percent: signal_percent} ->
    %{ssid: ssid, signal_percent: signal_percent}
  end)
  |> Enum.sort(&(&1.signal_percent >= &2.signal_percent))
  |> Enum.uniq_by(& &1.ssid)Connect to a network
Next, lets connect to one of the WiFi networks. Select the SSID and enter the password.
selectable_networks =
  [{"", "SSIDs:"}] ++ Enum.map(networks, fn network -> {network.ssid, network.ssid} end)
selected_network =
  Kino.Input.select("Select WiFi Network", selectable_networks)
  |> Kino.render()
psk_input = Kino.Input.password("Enter WiFi password")Verify that the information is correct and then evaluate the following code block to set it.
ssid = Kino.Input.read(selected_network) |> String.trim()
psk = Kino.Input.read(psk_input) |> String.trim()
if ssid != "" do
  VintageNetWiFi.quick_configure(ssid, psk)
else
  IO.puts("Skipping WiFi configuration.")
endCheck the connection
The final step is to check whether everything worked. VintageNet.info/0 is an
easy way of checking overall network connectivity on a device, so run it.
Hopefully, you’ll see a section for "wlan0" and a connection status of
:internet. You may need to scroll down.
VintageNet.info()Next up…
See VintageNet to learn more about networking in Nerves.