Rehan
Adding new wifi without discarding existing
Hello,
I’m working on wlan with vintagenet.
I’m able to configure the interface for using multiple networks, however if i want to add new network, existing networks are discarded, is there any way to add new wifi without discarding existing ones?
This is how i configure 2 wifi networks, device is able to connect to whichever is available
VintageNet.configure("wlan0", %{
type: VintageNetWiFi,
vintage_net_wifi: %{
networks: [
%{
key_mgmt: :wpa_psk,
psk: <psk>,
ssid: "TEST1"
},
%{
key_mgmt: :wpa_psk,
psk: <psk>,
ssid: "Hotspot1"
}
]
},
ipv4: %{method: :dhcp}
})
Now if i try to add one more network using VintageNet.configure() existing networks are discarded. Any suggestion is welcomed
Regards,
Marked As Solved
seb3s
Hi,
something like this should help:
@wifi_ifname "wlan0"
def get_wifi_config, do: VintageNet.get_configuration(@wifi_ifname)
def configure_wifi(%{ssid: ssid, password: password}) do
%{vintage_net_wifi: %{networks: networks}} = config = get_wifi_config()
VintageNet.configure(
@wifi_ifname,
put_in(config, [:vintage_net_wifi, :networks], [
%{key_mgmt: :wpa_psk, ssid: ssid, psk: password}
| Enum.reject(networks, &(&1.ssid == ssid))
]),
persist: false
)
end
You can of course remove persist: false based on your needs.
Cheers,
Sébastien.
3
Also Liked
Popular in Questions
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
I would like to know what is the best IDE for elixir development?
New
Other popular topics
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New







