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 believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Other popular topics
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
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 records...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









