This commit is contained in:
Connor Rigby 2017-10-04 12:56:15 -07:00
parent a7bfa81b4c
commit db10ad1810
2 changed files with 14 additions and 4 deletions

View file

@ -11,6 +11,8 @@ defmodule Farmbot.System.ConfigStorage.NetworkInterface do
field :ssid, :string
field :security, :string
field :psk, :string
field :ipv4_method, :string
end
@required_fields [:name, :type]

View file

@ -92,10 +92,18 @@ defmodule Farmbot.Target.Bootstrap.Configurator.Router do
defp input_network_configs([{iface, settings} | rest]) do
if settings["enabled"] == "on" do
%ConfigStorage.NetworkInterface{
type: settings["type"],
}
case settings["type"] do
"wireless" ->
%ConfigStorage.NetworkInterface{
type: "wireless",
ssid: Map.fetch!(settings, "ssid"),
psk: Map.fetch!(settings, "psk"),
ipv4_method: "dhcp"
}
"wired" ->
%ConfigStorage.NetworkInterface{type: "wired", ipv4_method: "dhcp"}
end
|> ConfigStorage.insert!()
end
input_network_configs(rest)
end