Skip to content

Commit

Permalink
Add frequency to WiFi parameters
Browse files Browse the repository at this point in the history
This is needed for the `:ibss` mode so that the first one on the network
can choose a channel.
  • Loading branch information
fhunleth committed Oct 29, 2019
1 parent 42fe81a commit 52ab48a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ The `:wifi` key has the following common fields:
* `:scan_ssid` - Scan with SSID-specific Probe Request frames (this can be
used to find APs that do not accept broadcast SSID or use multiple SSIDs;
this will add latency to scanning, so enable this only when needed)
* `:frequency` - When in `:ibss` mode, use this channel frequency (in MHz).
For example, specify 2412 for channel 1.

See the [official
docs](https://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf) for
Expand Down
8 changes: 7 additions & 1 deletion lib/vintage_net/technology/wifi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ defmodule VintageNet.Technology.WiFi do
:bssid_whitelist,
:bssid_blacklist,
:priority,
:scan_ssid
:scan_ssid,
:frequency
]

@moduledoc """
Expand Down Expand Up @@ -340,6 +341,7 @@ defmodule VintageNet.Technology.WiFi do
into_config_string(wifi, :bssid_blacklist),
into_config_string(wifi, :wps_disabled),
into_config_string(wifi, :mode),
into_config_string(wifi, :frequency),

# WPA-PSK settings
into_config_string(wifi, :psk),
Expand Down Expand Up @@ -444,6 +446,10 @@ defmodule VintageNet.Technology.WiFi do
"priority=#{value}"
end

defp wifi_opt_to_config_string(_wifi, :frequency, value) do
"frequency=#{value}"
end

defp wifi_opt_to_config_string(_wifi, :identity, value) do
"identity=#{inspect(value)}"
end
Expand Down
4 changes: 3 additions & 1 deletion test/vintage_net/technology/wifi_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,8 @@ defmodule VintageNet.Technology.WiFiTest do
%{
mode: :ibss,
ssid: "my_mesh",
key_mgmt: :none
key_mgmt: :none,
frequency: 2412
}
]
},
Expand Down Expand Up @@ -1725,6 +1726,7 @@ defmodule VintageNet.Technology.WiFiTest do
ssid="my_mesh"
key_mgmt=NONE
mode=1
frequency=2412
}
"""}
],
Expand Down

0 comments on commit 52ab48a

Please sign in to comment.