diff --git a/README.md b/README.md index 09acc0ff..6ae1abd7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/vintage_net/technology/wifi.ex b/lib/vintage_net/technology/wifi.ex index 30396a1c..b4c3bb86 100644 --- a/lib/vintage_net/technology/wifi.ex +++ b/lib/vintage_net/technology/wifi.ex @@ -17,7 +17,8 @@ defmodule VintageNet.Technology.WiFi do :bssid_whitelist, :bssid_blacklist, :priority, - :scan_ssid + :scan_ssid, + :frequency ] @moduledoc """ @@ -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), @@ -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 diff --git a/test/vintage_net/technology/wifi_test.exs b/test/vintage_net/technology/wifi_test.exs index 9e9cbf54..ccc287e2 100644 --- a/test/vintage_net/technology/wifi_test.exs +++ b/test/vintage_net/technology/wifi_test.exs @@ -1687,7 +1687,8 @@ defmodule VintageNet.Technology.WiFiTest do %{ mode: :ibss, ssid: "my_mesh", - key_mgmt: :none + key_mgmt: :none, + frequency: 2412 } ] }, @@ -1725,6 +1726,7 @@ defmodule VintageNet.Technology.WiFiTest do ssid="my_mesh" key_mgmt=NONE mode=1 + frequency=2412 } """} ],