Skip to content

Commit

Permalink
Revert quick_configure/2 to WPA2, but add option
Browse files Browse the repository at this point in the history
WPA3 support has been very problematic on some Nerves-supported hardware
to the point where it causes more harm than good. This change reverts
the `quick_configure/2` implementation to use WPA2 when a password is
supplied. If you have hardware that does support WPA3, it's possible to
use the generic WiFi configuration by updating the application
environment:

```
config :vintage_net_wifi, :quick_configure, &VintageNetWiFi.Cookbook.generic/2
```

Here's a short list of hardware support:

* All Raspberry Pi's handle the generic configuration fine, but don't
  support WPA3.
* The BeagleBones with built-in WiFi using the WiLink8 module will
  try to use WPA3 whenever it's available, but fail to connect.
* GRiSP2 won't connect to WPA2 networks with the generic configuration
  even though WPA3 isn't in use at all.
* The NXP 88W8987 appears to work perfectly with the generic
  configuration and connects to both WPA3 and WPA2 APs
  • Loading branch information
fhunleth committed Apr 7, 2024
1 parent d68513f commit 0301caf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end
The easiest way to configure WiFi is to using
`VintageNetWiFi.quick_configure/2`. For example:

```
```elixir
iex> VintageNetWiFi.quick_configure("my_access_point", "secret_passphrase")
:ok
```
Expand All @@ -56,6 +56,9 @@ The second easiest way to create WiFi configurations is to use the helper
functions in `VintageNetWiFi.Cookbook`. Check out the module documentation for
the various configurations.

See the `VintageNetWiFi.quick_configure/2` documentation for details on WPA3
support.

## Advanced usage

WiFi network interfaces typically have names like `"wlan0"` or `"wlan1"` when
Expand Down
17 changes: 16 additions & 1 deletion lib/vintage_net_wifi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,18 @@ defmodule VintageNetWiFi do
other special configuration handling, you'll need to call
`VintageNet.configure/3` instead. See `VintageNetWiFi.Cookbook` for help with
creating configurations or manually construct the configuration map.
> #### WiFi Authentication {: .info}
>
> VintageNetWiFi doesn't know whether the WiFi hardware you're using fully
> supports WPA3 authentication. To avoid hard to understand errors,
> `quick_configure/2` defaults to WPA2. If you have hardware that supports
> WPA3 and would like to use WPA2/WPA3 generic configurations, update your
> `config.exs` to:
>
> ```
> config :vintage_net_wifi, :quick_configure, &VintageNetWiFi.Cookbook.generic/2
> ```
"""
@spec quick_configure(String.t(), String.t() | nil) :: :ok | {:error, term()}
def quick_configure(ssid, passphrase \\ nil)
Expand All @@ -855,7 +867,10 @@ defmodule VintageNetWiFi do
end

def quick_configure(ssid, passphrase) do
with {:ok, config} <- Cookbook.generic(ssid, passphrase) do
cookbook_strategy =
Application.get_env(:vintage_net_wifi, :quick_configure, &Cookbook.wpa_psk/2)

with {:ok, config} <- cookbook_strategy.(ssid, passphrase) do
VintageNet.configure("wlan0", config)
end
end
Expand Down

0 comments on commit 0301caf

Please sign in to comment.